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
Proposal: support custom message for all no-restricted-* rules and possibly others #8400
Comments
Thanks for the proposal. This seems like a good idea to me. 👍 |
@eslint/eslint-team This issue has three 👍s -- it just needs a champion to be accepted. |
Should #8315 be closed in favor of this once it gets accepted? |
Yes, I think that sounds reasonable. |
I'll champion. Marking as accepted. I think I like a |
Okay, finally coming back around to this. Current status:
It's not immediately clear how we should add custom message support for patterns. @ljharb Any ideas on that? PRs would be very welcome! |
What do you mean by "patterns"? |
@platinumazure the OP seems to have that answered for patterns; can you elaborate on the confusion? |
Not sure if I can elaborate on the patterns. Is this a question for implem or API? |
I'm having trouble with it conceptually since patterns allow for negation which represent patterns that should specifically not be flagged by the rule. Take this example: Seems the first two patterns are related and should have one message between them, ideally (the second pattern is sort of a modification of the first, really). The last gets its own message. Or, if we really want to do one message per pattern, the second one doesn't need a message because it's not actually forbidding anything. So when implementing a Similar questions arise for |
That's a good point. I'd say grouping patterns with a message in an object, and allowing multiple objects, makes sense. |
So, for it to not be a breaking change, we need to allow mixed objects and strings in the top-level |
@dwelle Thanks, I agree. I think I'll support a top-level |
Following the precedent set by no-restricted-globals, anywhere you can pass a path string, you can also pass an object with a "name" and "message" key. This custom message will be appended to any error message triggered by an import of the "name" value. Custom messages are not supported with patterns.
Support for custom messages in |
I'm going to close this and create a new issue for whether we need to support custom messages for |
The basic idea is to allow custom message for rules which may not be self-evident and may demand a description of why they exist.
Semi-duplicate of #8315, but I'm opening a new issue to suggest this for (IMO) all the rules that really need this, and to discuss what other rules we could implement this for.
I think all
no-restricted*
rules need this.no-restricted-syntax
andno-restricted-properties
rules already have this, but these don't:no-restricted-modules
no-restricted-globals
no-restricted-imports
Syntax is comparative to the rules where it's already implemented, but the naming of the keys is up for bikeshed. Proposals:
no-restricted-globals
- either aname
,variable
oridentifier
for the main key:no-restricted-modules
&&no-restricted-imports
It may be a good idea to implement custom messages for other rules, as well. Thoughts?
The text was updated successfully, but these errors were encountered: