Skip to content
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

Update: add new schema to no-restricted-syntax (fixes #8298) #8357

Merged
merged 2 commits into from Mar 31, 2017

Conversation

vitorbal
Copy link
Member

What is the purpose of this pull request? (put an "X" next to item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[x] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)
This PR updates the no-restricted-syntax rule to support custom messages, like discussed in #8298.
This is a non-breaking enhancement to the rule.

Is there anything you'd like reviewers to focus on?
Any suggestions to make the docs clearer are welcome!

@vitorbal vitorbal added accepted There is consensus among the team that this change meets the criteria for inclusion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules labels Mar 29, 2017
@mention-bot
Copy link

@vitorbal, thanks for your PR! By analyzing the history of the files in this pull request, we identified @not-an-aardvark, @BYK and @scriptdaemon to be potential reviewers.

@eslintbot
Copy link

LGTM

Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Just one docs question: Should we have an example (or some prose) which indicates that strings and objects can be freely mixed in config?

@vitorbal
Copy link
Member Author

vitorbal commented Mar 29, 2017 via email

Copy link
Member

@not-an-aardvark not-an-aardvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just have a few minor nitpicks.

context.report({
node,
message: hasCustomMessage ? selectorOrObject.message : "Using '{{selector}}' is not allowed.",
data: { selector }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a custom message contains the substring {{selector}}, this will cause it to get replaced with the current selector. I doubt this will be a common problem in practice, but do you think it's worth documenting this or updating the logic to avoid it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very true! I updated the logic to take this into account and added a test for it. Thanks!

@@ -12,7 +12,7 @@ This rule disallows specified (that is, user-defined) syntax.

## Options

This rule takes a list of strings:
This rule takes a list of strings, where each string is a node type or AST selector:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Technically, any node type is also an AST selector, so this sentence is redundant. However, I'm fine with keeping it if you think it makes things clearer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I changed it to say only "where each string is an AST selector".

@eslintbot
Copy link

LGTM

@vitorbal vitorbal force-pushed the enhance-no-restricted-syntax branch from d137f14 to ab745a4 Compare March 30, 2017 20:54
@eslintbot
Copy link

LGTM

@vitorbal vitorbal force-pushed the enhance-no-restricted-syntax branch from ab745a4 to 5c38842 Compare March 31, 2017 16:36
@eslintbot
Copy link

LGTM

@not-an-aardvark not-an-aardvark merged commit 91baed4 into master Mar 31, 2017
@ilyavolodin ilyavolodin deleted the enhance-no-restricted-syntax branch March 31, 2017 22:30
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants