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: enhance no-restricted-syntax
to support custom error messages
#8298
Proposal: enhance no-restricted-syntax
to support custom error messages
#8298
Comments
👍 I'd been planning to suggest this as well, and I'm willing to champion it. One bikeshed is that maybe the option should be called |
Who's championing? If @vitorbal counts as a 👍 or champion as a result of creating this issue, we can accept now 😄 |
I would also be willing champion this, but I guess it doesn't matter 😄 |
This is probably a record for the shortest time ever between when an issue was created and accepted. 🎉 @vitorbal Sure, go for it. I'll assign the issue to you as a champion if you're also implementing it. |
It'd be great if this was implemented for all Related #8315 |
@dwelle thanks for your suggestion, I think that's a good idea! Could you open a separate issue with the proposal to add custom messages to the other |
What version are you using?
v3.18.0
What did you do?
What happened?
I got the following error message:
What did you expect to happen?
I would like to be able to provide custom error messages for the syntax patterns I prohibit using
no-restricted-syntax
. For the example above:Would provide the following error message:
Rationale
With the release of the AST selectors feature, the
no-restricted-syntax
rule just got super powerful, which is awesome.However, when a complex selector is used to prohibit a certain syntax pattern, the error message can be quite cryptic for devs that are not familiar with the AST selectors.
This proposal aims to allow the customization of the error messages for each of the syntax patterns configured for
no-restricted-syntax
.This proposal would be backwards compatible, since the rule logic can check if the passed-in option is a string (old format) or an object (new format). For example:
The text was updated successfully, but these errors were encountered: