Commit Graph
257 Commits
Author SHA1 Message Date
Arnaud Bienner e2d9241a0b Bug 2039187 - linters: fix race condition when --fix option is specified r=linter-reviewers,sergesanspaille
Differential Revision: https://phabricator.services.mozilla.com/D300236
2026-06-11 08:11:04 +00:00
Malte Jürgens e588b1f3b0 Bug 2027107 - Allow --include-third-party to also be configured in linter .yml files r=linter-reviewers,sergesanspaille
This way linters that require it can be directly configured to be also run on
otherwise excluded thiry-party directories. Previously this was only possible
through the --include-third-party command line option.

Differential Revision: https://phabricator.services.mozilla.com/D290893
2026-04-02 14:00:35 +00:00
Alex Hochheiden fa6096d23e Bug 1964759 - Preserve compound file suffixes for temp files in mozlint during jj fix r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D288971
2026-03-24 06:20:59 +00:00
Jon Oliver 8536d384a8 Bug 2015653 - Add support for --skip-rollouts flag for stylelint r=frontend-codestyle-reviewers,mossop
--skip-rollouts ignores the stylelint rollouts file so that errors can be reviewed for ignored files

Differential Revision: https://phabricator.services.mozilla.com/D282547
2026-02-10 14:23:08 +00:00
Jan de Mooij a015b25b04 Bug 1977910 - Remove file-exists check for mach lint --stdin-filename argument. r=ahal
This check could cause false-positives, for example when using `jj fix` on a
patch in the stack that adds a new file but that's not currently applied to
the working directory.

Differential Revision: https://phabricator.services.mozilla.com/D278612
2026-01-13 10:00:35 +00:00
Alex Hochheiden 02333707ab Bug 2006716 - Reformat entire repo with ruff-format (black replacement) r=ahal,sylvestre,linter-reviewers,perftest-reviewers,mozperftest-reviewers,geckoview-reviewers,extension-reviewers,media-playback-reviewers,webrtc-reviewers,releng-reviewers,sessionstore-reviewers,win-reviewers,dom-storage-reviewers,translations-reviewers,omc-reviewers,android-reviewers,home-newtab-reviewers,toolkit-telemetry-reviewers,firefox-style-system-reviewers,layout-reviewers,dom-worker-reviewers,geckodriver-reviewers,Sasha,emz,fchasen,sthompson,dholbert,sparky,padenot,emilio,Gijs,mconley,tcampbell,mjf,emcminn,willdurand,gstoll,jgraham,asuth
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D276894
2026-01-08 21:15:53 +00:00
Alex Hochheiden a1a75a53ed Bug 2006716 - Migrate [isort] to [lint.isort] to fix deprecation warning r=mozperftest-reviewers,sparky
```
warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `python/lldbutils/.ruff.toml`:
ruff-format (91) |   - 'isort' -> 'lint.isort'
```

Differential Revision: https://phabricator.services.mozilla.com/D278037
2026-01-07 21:44:02 +00:00
Atila Butkovits ce6aff66e2 Revert "Bug 2006716 - Remove unused default_bindir() from ruff.py r=ahal,linter-reviewers" for causing failures at tp5n-pageset.manifest.
This reverts commit a198379dd7.

Revert "Bug 2006716 - Add `ruff-format` linter r=ahal,linter-reviewers"

This reverts commit 8e2f1e924b.

Revert "Bug 2006716 - Remove `black` linter r=ahal,linter-reviewers"

This reverts commit 857218c417.

Revert "Bug 2006716 - Fix `ruff` linter `stderr` callback broken in D190696 r=ahal,linter-reviewers"

This reverts commit da4a569cfb.

Revert "Bug 2006716 - Update `ruff` to version `0.14.9` and use consistent versions in `lint.txt` and `python-test.txt` r=ahal,linter-reviewers"

This reverts commit 0781186b2e.

Revert "Bug 2006716 - Reformat entire repo with `ruff-format` (`black` replacement) r=ahal,sylvestre,linter-reviewers,perftest-reviewers,mozperftest-reviewers,geckoview-reviewers,extension-reviewers,media-playback-reviewers,webrtc-reviewers,releng-reviewers,sessionstore-reviewers,win-reviewers,dom-storage-reviewers,translations-reviewers,omc-reviewers,android-reviewers,home-newtab-reviewers,toolkit-telemetry-reviewers,firefox-style-system-reviewers,layout-reviewers,dom-worker-reviewers,geckodriver-reviewers,Sasha,emz,fchasen,sthompson,dholbert,sparky,padenot,emilio,Gijs,mconley,tcampbell,mjf,emcminn,willdurand,gstoll,jgraham,asuth"

This reverts commit b2b8db2859.
2026-01-07 21:34:31 +00:00
Alex Hochheiden b2b8db2859 Bug 2006716 - Reformat entire repo with ruff-format (black replacement) r=ahal,sylvestre,linter-reviewers,perftest-reviewers,mozperftest-reviewers,geckoview-reviewers,extension-reviewers,media-playback-reviewers,webrtc-reviewers,releng-reviewers,sessionstore-reviewers,win-reviewers,dom-storage-reviewers,translations-reviewers,omc-reviewers,android-reviewers,home-newtab-reviewers,toolkit-telemetry-reviewers,firefox-style-system-reviewers,layout-reviewers,dom-worker-reviewers,geckodriver-reviewers,Sasha,emz,fchasen,sthompson,dholbert,sparky,padenot,emilio,Gijs,mconley,tcampbell,mjf,emcminn,willdurand,gstoll,jgraham,asuth
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D276894
2026-01-07 18:08:27 +00:00
Alexandru Marc d296caccba Revert "Bug 2006716 - Remove unused default_bindir() from ruff.py r=ahal,linter-reviewers" for causing toolchain bustages
This reverts commit 76033c983e.

Revert "Bug 2006716 - Add `ruff-format` linter r=ahal,linter-reviewers"

This reverts commit 19fd8c23ca.

Revert "Bug 2006716 - Remove `black` linter r=ahal,linter-reviewers"

This reverts commit 0b01c783a6.

Revert "Bug 2006716 - Fix `ruff` linter `stderr` callback broken in D190696 r=ahal,linter-reviewers"

This reverts commit 72cab75517.

Revert "Bug 2006716 - Update `ruff` to version `0.14.9` and use consistent versions in `lint.txt` and `python-test.txt` r=ahal,linter-reviewers"

This reverts commit a434d066ce.

Revert "Bug 2006716 - Reformat entire repo with `ruff-format` (`black` replacement) r=ahal,sylvestre,linter-reviewers,perftest-reviewers,mozperftest-reviewers,geckoview-reviewers,extension-reviewers,media-playback-reviewers,webrtc-reviewers,releng-reviewers,sessionstore-reviewers,win-reviewers,dom-storage-reviewers,translations-reviewers,omc-reviewers,android-reviewers,home-newtab-reviewers,toolkit-telemetry-reviewers,firefox-style-system-reviewers,layout-reviewers,dom-worker-reviewers,geckodriver-reviewers,Sasha,emz,fchasen,sthompson,dholbert,sparky,padenot,emilio,Gijs,mconley,tcampbell,mjf,emcminn,willdurand,gstoll,jgraham,asuth"

This reverts commit 3ed06912eb.
2026-01-07 00:54:28 +00:00
Alex Hochheiden 3ed06912eb Bug 2006716 - Reformat entire repo with ruff-format (black replacement) r=ahal,sylvestre,linter-reviewers,perftest-reviewers,mozperftest-reviewers,geckoview-reviewers,extension-reviewers,media-playback-reviewers,webrtc-reviewers,releng-reviewers,sessionstore-reviewers,win-reviewers,dom-storage-reviewers,translations-reviewers,omc-reviewers,android-reviewers,home-newtab-reviewers,toolkit-telemetry-reviewers,firefox-style-system-reviewers,layout-reviewers,dom-worker-reviewers,geckodriver-reviewers,Sasha,emz,fchasen,sthompson,dholbert,sparky,padenot,emilio,Gijs,mconley,tcampbell,mjf,emcminn,willdurand,gstoll,jgraham,asuth
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D276894
2026-01-07 00:32:15 +00:00
Alex Hochheiden c936a9217d Bug 2003412 - Fix PLW1508 warnings: Use string default for os.getenv r=emilio,android-reviewers,jdescottes,tcampbell
https://docs.astral.sh/ruff/rules/invalid-envvar-default/

Differential Revision: https://phabricator.services.mozilla.com/D274700
2025-12-10 06:06:22 +00:00
Alex Hochheiden 040998e094 Bug 2003412 - Fix PLR1704 warnings: Avoid redefining argument with local variable r=emilio,perftest-reviewers,mozperftest-reviewers,taskgraph-reviewers,releng-reviewers,toolkit-telemetry-reviewers,jdescottes,bhearsum,sparky
https://docs.astral.sh/ruff/rules/redefined-argument-from-local/

Differential Revision: https://phabricator.services.mozilla.com/D274691
2025-12-10 06:05:58 +00:00
Dave Townsend e3c88f4aad Bug 1997884: Fix passing extra arguments to eslint. r=linter-reviewers,ahal
Differential Revision: https://phabricator.services.mozilla.com/D271041
2025-11-04 10:32:54 +00:00
Rob Wu 635882703d Bug 1989006 - Pass pid field expected by logger r=linter-reviewers,Standard8
`%(pid)` is set as the Formatter by _setup_logger at
https://searchfox.org/firefox-main/rev/ff87356d65bc2e9e7349ac3a24276696434f27fc/python/mozlint/mozlint/roller.py#51

... but it is missing from the record set by
https://searchfox.org/firefox-main/rev/ff87356d65bc2e9e7349ac3a24276696434f27fc/python/mozlint/mozlint/roller.py#234

... which results in `KeyError: 'pid'` as seen in the bug.

Differential Revision: https://phabricator.services.mozilla.com/D265084
2025-09-19 01:40:09 +00:00
Mark Banner 9ef4411d1c Bug 1985946 - Fix verbose logging from sub-processes when running 'mach lint'. r=linter-reviewers,sylvestre
This also adds some simple logging of exceptions raised from the sub-process. Whilst it doesn't cause the process to fail
it does at least mean the error is logged rather than thrown away.

Differential Revision: https://phabricator.services.mozilla.com/D263078
2025-09-02 12:08:00 +00:00
Andrew Halberstadt 8c28078763 Bug 1977636 - [lint] Display source context in default formatter, r=linter-reviewers,sylvestre
Some linters include source code as context, often with little ascii
arrows that point at the problem. This can be invaluable for figuring
out where the problem is.

We have an attribute to store this information in the `Issue` class, but
unfortunately none of the mozlint formatters display it!

This gets the default formatter to attempt displaying the source, with
some basic colorization. The colorization is dependent on the format of
each linter, so it may need to be adjusted as we add different linters.

Differential Revision: https://phabricator.services.mozilla.com/D257531
2025-07-30 22:55:55 +00:00
Andrew Halberstadt 8171cde538 Bug 1972466 - [mozlint] Error out without traceback if all linters were skipped due to setup, r=linter-reviewers,sylvestre
Differential Revision: https://phabricator.services.mozilla.com/D254229
2025-06-19 19:22:28 +00:00
Alex Hochheiden 402ee7c138 Bug 1966763 - Fix UP035 and UP033 ruff warnings caused by Python 3.9 version bump r=ahal,firefox-build-system-reviewers,linter-reviewers,taskgraph-reviewers,releng-reviewers,translations-reviewers,omc-reviewers,glandium,jcristau,pdahiya,gregtatum
Some were automatic fixes, but most were done manually.

Differential Revision: https://phabricator.services.mozilla.com/D253375
2025-06-13 17:39:49 +00:00
Sebastian Hengst 2dc897c5d7 Bug 1964657 - also fix linter output handling for iso8859-1 encoding. r=ahal
Differential Revision: https://phabricator.services.mozilla.com/D248273
2025-05-08 08:06:18 +00:00
Ben Dean-Kawamura a4d7085661 Bug 1960928 - ./mach lint clippy updates, r=ahal,taskgraph-reviewers
Make clippy a global linter.  This means it only runs once per
workspace, which is good because `cargo` handles parallelization
internally.  There's no reason to split things out into multiple commands.

Updated the global linter config handling to pass a list of files.  This
is needed for clippy and we can just ignore them for the android lints.

Updated the clippy linter to work with crates outside of `gkrust`.  For
these crates, we call `cargo clippy` directly and does not filter by
path name.  These crates need to be listed in `tools/lint/clippy.yml`,
currently this is only `uniffi-bindgen-gecko-js`, but it's easy to add
more.

Fixed some lint warnings in the `mozlint` package itself.

Differential Revision: https://phabricator.services.mozilla.com/D246488
2025-04-29 20:33:42 +00:00
Mark Banner 567d13de23 Bug 1950917 - Avoid warning about linting the entire repo when only running setup. r=linter-reviewers,ahal
Differential Revision: https://phabricator.services.mozilla.com/D246887
2025-04-28 20:45:07 +00:00
Beth Rennie 78f943689e Bug 1948069 - Fix pipelint on Windows r=ahal
The pipelint tool was not working correctly on Windows for three reasons:

1. The module was being imported into every child process spawned by the
   lint roller's multiprocessing executor. Because the import of
   pipelint has side-effects (the actual running of mach lint on the
   input), each child process would end up recursively triggering these
   side-effects and causing exponential process growth until they all
   eventually crashed.

   To address this we now have the logic of the pipelint script behind a
   `if __name__ == "__main__" guard.

2. We were keeping the file handle open before we called into mach,
   which resulted in a permissions error trying to read from the file
   handle after mach had finished.

   To address this we now immediately close the file before invoking
   `mach lint` and re-open it for reading after.

3. We were using default newline handling inside `pipelint` and
   `mozlint`, which resulted in LFs being translated to CRLFs
   automatically in all the intermediate temporary files.

   To address this, we open files for reading and writing in binary mode
   so that we deal directly with the underlying bytes instead of
   particular interpretations of bytes (e.g., newlines, CP252 vs UTF-8),
   including `stdin` (when reading file input from `jj`) and `stdout`
   (when outputting the final formatted files).

Differential Revision: https://phabricator.services.mozilla.com/D244513
2025-04-23 18:04:21 +00:00
Butkovits Atila e96815c669 Backed out changeset f5a67487d18f (bug 1948069) for causing lint failures. CLOSED TREE 2025-04-23 04:21:43 +03:00
Beth Rennie 1189569e61 Bug 1948069 - Fix pipelint on Windows r=ahal
The pipelint tool was not working correctly on Windows for three reasons:

1. The module was being imported into every child process spawned by the
   lint roller's multiprocessing executor. Because the import of
   pipelint has side-effects (the actual running of mach lint on the
   input), each child process would end up recursively triggering these
   side-effects and causing exponential process growth until they all
   eventually crashed.

   To address this we now have the logic of the pipelint script behind a
   `if __name__ == "__main__" guard.

2. We were keeping the file handle open before we called into mach,
   which resulted in a permissions error trying to read from the file
   handle after mach had finished.

   To address this we now immediately close the file before invoking
   `mach lint` and re-open it for reading after.

3. We were using default newline handling inside `pipelint` and
   `mozlint`, which resulted in LFs being translated to CRLFs
   automatically in all the intermediate temporary files.

   To address this, we open files for reading and writing in binary mode
   so that we deal directly with the underlying bytes instead of
   particular interpretations of bytes (e.g., newlines, CP252 vs UTF-8),
   including `stdin` (when reading file input from `jj`) and `stdout`
   (when outputting the final formatted files).

Differential Revision: https://phabricator.services.mozilla.com/D244513
2025-04-23 00:10:33 +00:00
Marco Castelluccio dfe25adebc Bug 1959710 - For line-based linters, read files and apply lint one line at a time instead of first reading the whole file in memory. r=linter-reviewers,ahal DONTBUILD
Differential Revision: https://phabricator.services.mozilla.com/D245085
2025-04-15 21:44:16 +00:00
Alex Hochheiden 9e91a1f021 Bug 1715287 - [lint] Enable remaining pyupgrade rules and lint tree r=linter-reviewers,webdriver-reviewers,translations-reviewers,whimboo,sylvestre
Differential Revision: https://phabricator.services.mozilla.com/D245320
2025-04-13 17:48:23 +00:00
Andrew Halberstadt 8c3016253e Bug 1944916 - [mozlint] Improve some error messages, r=linter-reviewers,sylvestre
Differential Revision: https://phabricator.services.mozilla.com/D236878
2025-02-06 19:54:47 +00:00
Andrew Halberstadt 629c3f0c5a Bug 1944916 - [mozlint] Add ability to lint files from stdin to mozlint, r=linter-reviewers,sylvestre
This allows `./mach lint` to be used with integrations that expect to
pass in file contents on stdin and get a fixed version of the file on
stdout.

Differential Revision: https://phabricator.services.mozilla.com/D236224
2025-02-06 19:54:47 +00:00
Andrew Halberstadt 5a57d31223 Bug 1944916 - [mozlint] Run all console output through the logger, r=linter-reviewers,sylvestre
This ensures consistency in output between the parent and subprocess. It
also adjusts the formatting by log level, so we only get the more
detailed format when `--verbose` is enabled.

Differential Revision: https://phabricator.services.mozilla.com/D236252
2025-02-06 19:54:46 +00:00
Andrew Halberstadt e6bfcad702 Bug 1944916 - [mozlint] Fix path filtering edge case, r=linter-reviewers,sylvestre
Under the old logic, if a linter has a file directly in its include config, e.g:

```
include: [path/to/some/file.py]
```

Then it would always get linted, even if the user never specified it on
the cli. This is a bug.

Differential Revision: https://phabricator.services.mozilla.com/D236251
2025-02-06 15:19:07 +00:00
Andrew Halberstadt 536cd1c1cf Bug 1571684 - [mozlint] Stop logging Android lint setup failures, r=linter-reviewers,sylvestre
Differential Revision: https://phabricator.services.mozilla.com/D236223
2025-02-03 19:56:10 +00:00
Tooru Fujisawa 94bba12a39 Bug 1936051 - Part 15: Remove JSM handling from eslint config. r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D233741
2025-01-23 12:09:37 +00:00
Sylvestre Ledru 2ca9d22cf4 Bug 1921433 - reformat with black 24.8.0 r=linter-reviewers,webdriver-reviewers,perftest-reviewers,taskgraph-reviewers,releng-reviewers,dom-storage-reviewers,janv,jmaher,whimboo,afinder,ahal
Differential Revision: https://phabricator.services.mozilla.com/D223963
2024-11-03 20:28:59 +00:00
Jesse Schwartzentruber 301ec15a92 Bug 1903620 - Calculate jobs using CPU affinity in mach. r=firefox-build-system-reviewers,glandium
Differential Revision: https://phabricator.services.mozilla.com/D214289
2024-06-25 13:53:13 +00:00
ahochheiden d0a30e9392 Bug 1898817 - Replace distutils.spawn.find_executable with shutil.which within mozlint r=ahal
Differential Revision: https://phabricator.services.mozilla.com/D211630
2024-06-21 17:30:03 +00:00
Noemi Erli 35f162af9c Backed out 8 changesets (bug 1899681, bug 1888570, bug 1898817) as requested by the dev CLOSED TREE
Backed out changeset 5be4d65a269f (bug 1899681)
Backed out changeset 4b2b91958615 (bug 1898817)
Backed out changeset 91cfbbe6cacd (bug 1898817)
Backed out changeset 689cadd510e1 (bug 1888570)
Backed out changeset dee593604635 (bug 1888570)
Backed out changeset 2fc073aab920 (bug 1898817)
Backed out changeset c68493490b5c (bug 1898817)
Backed out changeset eb50a220de69 (bug 1898817)
2024-06-12 21:19:10 +03:00
ahochheiden a7f90e7ba4 Bug 1898817 - Replace distutils.spawn.find_executable with shutil.which within mozlint r=ahal
Differential Revision: https://phabricator.services.mozilla.com/D211630
2024-06-12 16:10:34 +00:00
Nick Alexander c1d63c5fb2 Bug 1896514 - Make mach lint accommodate Windows drive case differences. r=ahal
We hand-roll to avoid `os.path.realpath` invoking potentially
expensive filesystem APIs.

Differential Revision: https://phabricator.services.mozilla.com/D210230
2024-05-28 20:29:38 +00:00
Gijs Kruitbosch 2b6df36c8c Bug 1856535 - allow linters to work by excluding extensions instead of including them, r=ahal
Differential Revision: https://phabricator.services.mozilla.com/D202635
2024-03-13 09:40:27 +00:00
Joel Maher 93a74ef1b8 Bug 1869430 - Batch 19.2 convert python unittest .ini -> .toml. r=gbrown,taskgraph-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D196124
2023-12-12 17:40:03 +00:00
Ray Kraesig 29050fe320 Bug 1866176 - normalize paths in FileFinder r=ahal,firefox-build-system-reviewers,glandium
On Windows, paths provided to FileFinder may contain backslashes, which
will cause uses of `mozpath.match` later on to fail when they try to
compare mixed-path values. To avoid this, normalize those paths on
receipt.

(Also, silence a lint by pulling the global `args` variable into a
function, so that it is no longer occluded by the various function
parameters named `args`.)

Differential Revision: https://phabricator.services.mozilla.com/D194448
2023-12-04 17:14:29 +00:00
Andrew Halberstadt 255518ea5c Bug 1867990 - Fix black formatting errors that snuck in due to regression, r=linter-reviewers,taskgraph-reviewers,releng-reviewers,bhearsum,sylvestre
These were not caught due to bug 1865672.

Depends on D195431

Differential Revision: https://phabricator.services.mozilla.com/D195432
2023-12-04 14:51:39 +00:00
Sandor Molnar afcfb9aad7 Backed out changeset fec3dc168176 (bug 1866176) for causing bug 1867494 CLOSED TREE 2023-11-30 14:38:22 +02:00
Ray Kraesig 0c19f4087a Bug 1866176 - normalize paths in FileFinder r=ahal,firefox-build-system-reviewers,glandium
On Windows, paths provided to FileFinder may contain backslashes, which
will cause uses of `mozpath.match` later on to fail when they try to
compare mixed-path values. To avoid this, normalize those paths on
receipt.

(Also, silence a lint by pulling the global `args` variable into a
function, so that it is no longer occluded by the various function
parameters named `args`.)

Differential Revision: https://phabricator.services.mozilla.com/D194448
2023-11-29 17:45:31 +00:00
serge-sans-paille 37e171f844 Bug 1865672 - Format mach with black r=ahochheiden
To do so we allow straight filenames in the include section and consider
them as automatically-included files.

Differential Revision: https://phabricator.services.mozilla.com/D194093
2023-11-21 08:10:29 +00:00
Geoff Brown 834d394cee Bug 1860671 - Use subprocess instead of mozprocess in mozlint r=hneiva
Reduce reliance on mozprocess ProcessHandler, which is poorly maintained.

Differential Revision: https://phabricator.services.mozilla.com/D191695
2023-10-26 16:09:13 +00:00
Sylvestre Ledru 3608dc8457 Bug 1860157 - Fix typos found by codespell 2.2.6 r=webdriver-reviewers,zeid,search-reviewers,perftest-reviewers,devtools-reviewers,releng-reviewers,gbrown,sparky,jteow
Differential Revision: https://phabricator.services.mozilla.com/D191480
2023-10-19 20:52:10 +00:00
Logan Rosen 45be05a920 Bug 1786490 - reformat the tree using black 23.3.0 r=sylvestre,webdriver-reviewers,taskgraph-reviewers,whimboo,jmaher,ahal,perftest-reviewers,geckoview-reviewers,afinder,m_kato
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D186092
2023-09-06 16:14:30 +00:00
Mark Banner cc8482c3ed Bug 1757373 - Enable linting to run in parallel when '.' is specified as the path. r=linter-reviewers,ahal
Differential Revision: https://phabricator.services.mozilla.com/D177260
2023-05-09 13:11:21 +00:00