-
Notifications
You must be signed in to change notification settings - Fork 94
Rule Blocklist #231
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
Rule Blocklist #231
Conversation
lib/eslint-patch.js
Outdated
@@ -7,6 +7,7 @@ const ConfigFile = require("eslint/lib/config/config-file"); | |||
|
|||
const Config = require("eslint/lib/config"); | |||
const ConfigUpgrader = require("./config_upgrader"); | |||
const RuleBlacklist = require("./rule_blacklist"); |
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.
Could you rename your files and variables to use "blocklist" throughout?
3b513c4
to
41e4720
Compare
41e4720
to
63f2b0e
Compare
lib/rule_blocklist.js
Outdated
let report = []; | ||
|
||
for (const name in blocklistedRules) { | ||
if (Reflect.has(rules, name)) { |
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.
Just curious, what's Reflect
? I don't see it being require
d.
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's a standard built-in object.
lib/config_finder.js
Outdated
"use strict"; | ||
|
||
const | ||
CONFIG_FILES = require("eslint/lib/config/config-file").CONFIG_FILES |
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 sure what project style is, but elsewhere you put the first value on the line with const
.
lib/rule_blocklist.js
Outdated
@@ -0,0 +1,84 @@ | |||
"use strict"; | |||
|
|||
const a = "a" |
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.
What's a
for?
This is looking good! The current rule configured in the blocklist is missing the Instead of
what do you think of outputting a list of ignored rules (if any) after a brief explanation:
|
lib/rule_blocklist.js
Outdated
|
||
const blocklistedRules = { | ||
"no-unresolved": "Code Climate doesn't fetch your project's dependencies so this rule produces high amount of false positives." | ||
}; |
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.
Mentioned in another comment but repeating here inline: I don't think we need to support separate explanations for blocklisted rules just yet. This can be an array of rules and we can provide an explanation after updating the config.
no-resolved
should be import/no-resolved
.
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.
Ignoring the following rules that rely on module resolution: * import/no-unresolved
Right now we have just one reason (we know of) to turn off rules. And we have just one rule (I didn't do extensive research on this yet). It's an appropriate way to format the message for it.
However, it doesn't seem to be the only possible reason. I specifically chosen this approach because there might be others and it will be a bit easier to change it in the future — just add it to this object, no code changes needed.
Here are a few examples of other reasons we may want to disable a rule I can think of:
- A platform-specific rule that is incompatible with Linux
- A rule that relies on an external tool that is not in the container
- A rule that tries to use network
- A rule that is incompatible with Node version we run
I'm not opposing the proposed change. I'm just presenting my reasoning behind the design. I'll make the change if you prefer it.
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.
We should definitely audit all rules currently available via our vendored plugins and add any that rely on module resolution to this blocklist either in this PR or the next one.
Here's one example of another rule that should be in the blocklist:
import/extensions
https://github.com/benmosher/eslint-plugin-import/blob/master/src/rules/extensions.js
Here are a few examples of other reasons we may want to disable a rule I can think of
Until we actually want to ignore rules for another reason, I'd stick with a simpler implementation that doesn't map particular rules to warning messages. I don't think it's worth adding now. If we need it later, we can add it then.
63f2b0e
to
9356897
Compare
@pointlessone Anything I can do to help push this along? |
Another rule that should probably be included in the blocklist: Otherwise, repos see issues like: "Resolve error: unable to load resolver "babel-module"." |
9356897
to
715c202
Compare
@pointlessone Looks like a good portion of the diff is refactoring the config finder. Would you mind splitting that refactor into a separate commit so the rule blocklist additions can stand alone? |
@pointlessone Have you been able to audit the currently vendored plugins for other rules that rely on module resolution? It would be great if we could catch and blocklist any others. |
@dblandin No, I haven't audited other rules. It's a rather time consuming task. I'm not sure if that's an effective use of time. I thought we could push this and add more rules as we hit more false positives. /cc @gordondiggs TBH, I'm not sure about |
I'm fine rolling with this if you think an audit is too time intensive right right now. I was thinking of a simple ack/grep for rules calling out to
|
715c202
to
1d9e86c
Compare
@dblandin Split the commits. Simple grep is a rather naive approach. I imagine it can hit all sorts of unrelated things: comments, any function/var that has this rather generic term in them, etc. Moreover, not every Let's merge this PR as is (or with the changes directly related to it) and expand the list of blocked rules in a separate PR. I'll go through the list you posted and add rules if they primarily deal with external modules. Otherwise, users can mark false-positives. |
Sounds good! |
Add a way to disable rules.
One particular case is #222.