-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Improve usage of eslint-disable directives #16941
Conversation
Verified by running `npm run lint-js -- --report-unused-disable-directives` before and after making these changes.
I see you had some issues with the lock file. I added docs with what worked for me when I did some extensive testing this week: https://github.com/WordPress/gutenberg/tree/master/packages#managing-dependencies @dsifford suggests manual updates of |
Looking good to me, will compliment #16795 nicely 👌🏼 |
@@ -21,6 +21,7 @@ module.exports = { | |||
extends: [ | |||
'plugin:@wordpress/eslint-plugin/recommended', | |||
'plugin:jest/recommended', | |||
'plugin:eslint-comments/recommended', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does order of those configs matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I am aware of. Can't find anything in the docs that would indicate this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not certain here but I want to say that order does matter. Because what if 2 plugins set configuration for a single rule in different ways?
Edit: It appears to derive the final configuration in order from first to last, as described here: (https://eslint.org/docs/user-guide/configuring#extending-configuration-files). It doesn't explicitly state this though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran a quick test eslint --print-config .eslintrc.js
https://gist.github.com/ntwb/d04000c8a29bd441c05b20650c027ed8/revisions
The order of the rules is changed, but, I agree that there is a chance of conflicting rules having some unknown behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we are good here with the current order. It's a bit surprising though that rules are applied this way. I assumed the opposite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, this should help us keep the codebase cleaner 💯
@@ -21,6 +21,7 @@ module.exports = { | |||
extends: [ | |||
'plugin:@wordpress/eslint-plugin/recommended', | |||
'plugin:jest/recommended', | |||
'plugin:eslint-comments/recommended', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we are good here with the current order. It's a bit surprising though that rules are applied this way. I assumed the opposite.
* Remove unused `eslint-disable` directives * Leverage `eslint-plugin-eslint-comments` and fix reported errors
* Remove unused `eslint-disable` directives * Leverage `eslint-plugin-eslint-comments` and fix reported errors
Description
This PR attempts to improve the way
eslint-disable
is being used throughout the project.In a first run
npm run lint-js -- --report-unused-disable-directives
has been used to identify and removeeslint-disable
directives that were unused and thus unnecessary.In a second run,
eslint-plugin-eslint-comments
has been installed and configured that does the same thing, and much more. For example, it points out ESLint rules that have been disabled but not re-enabled again, or rules that have been enabled but were not actually disabled in the first place.How has this been tested?
ESLint passes just fine after these changes.
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: