Add autofixing of lint warnings for specific packages/files #5187
+94
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation
Currently, there are a ton of lint warnings, and it would be good to address them sooner rather than later.
The good thing is that many of these warnings can be autofixed — but only if they are turned into errors first. So, what we could do is open
eslint.config.mjs
, change all of the rules that are configured to produce warnings to produce errors instead ("warn"
->"error"
), then runyarn lint:eslint --fix
and take care of them in one fell swoop.However, if we took this approach, approving such a PR would likely take a while since the changes would touch a bunch of packages in this monorepo and require codeowner approval from a bunch of teams.
Instead, it would be better if we batched lint violation fixes by codeowner. That is, open PRs progressively by addressing all lint violations for packages owned by the Wallet Framework team first, then the Accounts team, then the Confirmations team, etc.
To do this, we would need a way to run ESLint on specific directories. Again, that seems easy on its own, but we'd have to repeat the step that modifies
eslint.config.mjs
to convert warning-producing rules to errors instead each time we wanted to make a new PR.Instead, if would be better if we could ask our ESLint script to not only allow custom file paths to be passed in, but also convert warnings into errors for us at the same time.
That's what this PR achieves. For instance, you should be able to say:
and now ESLint will run just on
network-controller
files, and autofix any warnings automatically.Manual testing steps
As stated above, you should be able to run e.g.:
and see a bunch of changes made to
network-controller
files that fix lint violations. (ESLint may continue to report some errors as unfixable, but that's okay.)References
Changelog
(N/A, developer-only change)
Checklist