Description
I was helping someone out in ESLint's help channel who had their import/no-unresolved
rule configured incorrectly.
They were using this configuration:
{
"import/no-unresolved": [2, {"amd": true}, { "ignore": ["external"] }]
}
The complaint was that the "ignore"
option was being ignored.
According to my understanding of the rule (i.e., 30 seconds of reading the documentation), this is incorrect because the options should be combined, like this:
{
"import/no-unresolved": ["error", { "amd": true, "ignore": ["external"] }]
}
I took a look at the code and I think the issue is that the generated schema is interpreted by ESLint as an open-ended array. So in the first example, { "amd": true }
was interpreted as the options object, but { "ignore": ["external"] }
was ignored.
Since this is a utility, it might be a better experience if the function could export a full JSON schema, with an array for severity and for the option object, as well as the array schema having "additionalItems": false
. This would allow the above example to fail schema validation and provide a slightly better user experience.
With all of that said, I understand that (1) this is a corner case, (2) not a lot of people will run into this, and (3) the potential breaking change on the eslint-module-utils package might not be worth the benefit here. If that's the case, feel free to close this. I just wanted to report it in case it's something you want to fix. 😄