Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint:fix package script #5204

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Fix lint:fix package script #5204

wants to merge 3 commits into from

Conversation

mcmire
Copy link
Contributor

@mcmire mcmire commented Jan 27, 2025

Explanation

Some developers run yarn lint:fix before pushing. After the ESLint 9 upgrade, however, this package script has been broken because it fixes all lint warnings in addition to errors. Since there are many, many warnings, this ends up making all kind of changes. In addition, the fixing step was happening twice, meaning that the package script was very, very slow.

This commit gets this script in working order again.

References

Changelog

(N/A, developer-only change)

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Some developers run `yarn lint:fix` before pushing. After the ESLint 9
upgrade, however, this package script has been broken because it fixes
all lint warnings in addition to errors. Since there are many, many
warnings, this ends up making all kind of changes. In addition, the
fixing step was happening twice, meaning that the package script was
very, very slow.

This commit gets this script in working order again.
@@ -25,7 +25,7 @@
"lint:dependencies": "depcheck && yarn dedupe --check",
"lint:dependencies:fix": "depcheck && yarn dedupe",
"lint:eslint": "yarn build:only-clean && yarn ts-node ./scripts/run-eslint.ts --cache",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write && yarn constraints --fix && yarn lint:dependencies:fix",
"lint:fix": "yarn lint:eslint --quiet --fix && yarn lint:misc --write && yarn constraints --fix && yarn lint:dependencies:fix",
Copy link
Contributor Author

@mcmire mcmire Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--quiet hides warnings, and the combination of --quiet and --fix will only autofix errors and not warnings.

@@ -44,7 +44,7 @@ main().catch((error) => {
async function main() {
const { cache, fix, quiet } = parseCommandLineArguments();

const eslint = new ESLint({ cache, fix });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix option instructs lintFiles to autofix errors as it finds them. We manually call outputFixes in runESLint further down which does the same thing.

@mcmire mcmire marked this pull request as ready for review January 27, 2025 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant