Do we need to support custom messages for patterns in no-restricted-imports and no-restricted-modules?
See original GitHub issueFollow-up issue to #8400.
Proposal would be to add support for custom error messages when users use patterns in no-restricted-imports
or no-restricted-modules
. Proposal is basically the same for both rules, so I’m going to save myself some time and only draw it out for no-restricted-modules
.
What rule do you want to change?
no-restricted-modules (and no-restricted-imports, analogously)
Does this change cause the rule to produce more or fewer warnings?
Same number of warnings
How will the change be implemented? (New option, new default behavior, etc.)?
New option to create custom messages for pattern-based configurations
Please provide some example code that this change will affect:
Config strawman:
{
"no-restricted-modules": ["error",
{ "patterns": ["import1/private/*"], "message": "Do not use any modules in import1/private" },
{ "patterns": ["import2/*", "!import2/good"], "message": "Do not use any modules in import2 except import2/good" }
]
}
Code:
const badImport1 = require("import1/private/foo");
const badImport2 = require("import2/bad");
What does the rule currently do for this code?
Report an error on each line using the generic message for this rule.
What will the rule do after it’s changed?
Report an error on each line using the generic message for this rule plus the message supplied in the configuration file.
I’m submitting this as a separate issue to see if this is something we definitely need to support in ESLint (either by strong community voice or by the team coming to consensus independently). I’m not championing this at the moment.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top GitHub Comments
Closing due to lack of interest.
This would be really helpful to me as I’m looking to deprecate an entire directory worth of components in favor of a new set elsewhere. I could take a stab at this if you’d be interested!