Codespell incorrectly changes package.json
Categories
(Developer Infrastructure :: Lint and Formatting, task, P2)
Tracking
(firefox95 fixed)
Tracking | Status | |
---|---|---|
firefox95 | --- | fixed |
People
(Reporter: standard8, Assigned: ahal)
Details
Attachments
(2 files)
I just caught this on a patch that someone had posted.
Running ./mach lint -l codespell --fix
causes a change to tools/lint/eslint/eslint-plugin-mozilla/package-lock.json
as per below. These files should never be automatically changed by linters.
diff --git a/tools/lint/eslint/eslint-plugin-mozilla/package-lock.json b/tools/lint/eslint/eslint-plugin-mozilla/package-lock.json
index 36be00fdd1967..2d8bc6aeaf069 100644
--- a/tools/lint/eslint/eslint-plugin-mozilla/package-lock.json
+++ b/tools/lint/eslint/eslint-plugin-mozilla/package-lock.json
@@ -1499,7 +1499,7 @@
"require-from-string": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
- "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
+ "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/view==",
"dev": true
},
"resolve-from": {
Reporter | ||
Comment 1•2 years ago
|
||
I can't figure out how to stop this happening, I've added various variants of package-lock.json (with **
and with full paths) to the exclude list in tools/lint/codespell.yml
and it doesn't prevent the change.
Any ideas Andrew?
Assignee | ||
Comment 2•2 years ago
|
||
Adding "**/package-lock.json"
seems to do it for me. Note it needs to be in quotes though since *
is a special character in yaml.
Assignee | ||
Comment 3•2 years ago
|
||
We have a check in the 'CodespellProcess' class to ignore errors that are
fixing single letter camelCase errors (since these tend to be used frequently.
Unfortunately, when using '--fix', these errors are fixed regardless as the
fixing happens with the codespell process. Since we increment the 'fix'
variable after the check happens, we don't even report that anything was
'fixed'.
Ideally we would find a way to prevent these types of errors from being fixed,
but for now this at will at least ensure that the user is notified that
something was modified.
Assignee | ||
Comment 4•2 years ago
|
||
Depends on D128885
Assignee | ||
Comment 5•2 years ago
|
||
Note there's still a bug in the codespell linter though. Basically this check is useless with --fix
:
https://searchfox.org/mozilla-central/rev/36aa22c7ea92bd3cf7910774004fff7e63341cf5/tools/lint/spell/__init__.py#58
This check prevents the aforementioned package-lock.json
issue from being reported without --fix
.
Reporter | ||
Comment 6•2 years ago
|
||
(In reply to Andrew Halberstadt [:ahal] from comment #2)
Adding
"**/package-lock.json"
seems to do it for me. Note it needs to be in quotes though since*
is a special character in yaml.
Hmm, I wonder if I maybe changed the file in the wrong repo... oops.
(In reply to Andrew Halberstadt [:ahal] from comment #5)
Note there's still a bug in the codespell linter though. Basically this check is useless with
--fix
:
https://searchfox.org/mozilla-central/rev/36aa22c7ea92bd3cf7910774004fff7e63341cf5/tools/lint/spell/__init__.py#58This check prevents the aforementioned
package-lock.json
issue from being reported without--fix
.
We could use bug 1736560 to fix that maybe.
Pushed by ahalberstadt@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f42752e51c9c [lint] Fix codespell silently fixing files, r=linter-reviewers,sylvestre https://hg.mozilla.org/integration/autoland/rev/bd985949aa5c [lint] Ignore all 'package-lock.json' files in codespell linter, r=linter-reviewers,sylvestre
Comment 8•2 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/f42752e51c9c
https://hg.mozilla.org/mozilla-central/rev/bd985949aa5c
Updated•8 months ago
|
Description
•