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: space-unary-ops uses astUtils.canTokensBeAdjacent (fixes #9907) #9906

merged 2 commits into from Feb 1, 2018


Copy link

@platinumazure platinumazure commented Jan 28, 2018

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

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

Tell us about your environment

  • ESLint Version: 4.16.x / master
  • Node Version: 8.9.3
  • npm Version: 4.1.1

What parser (default, Babel-ESLint, etc.) are you using?


Please show your full configuration:

(See demo link below)

What did you do? Please include the actual source code causing the issue.

See demo.

What did you expect to happen?

Every UnaryExpression, NewExpression, YieldExpression, and AwaitExpression should be flagged as invalid. It is possible to remove the spaces between the unary word operator and the next token.

What actually happened? Please include the actual, raw output from ESLint.

No linting errors.

What changes did you make? (Give an overview)

Changed special-case ObjectExpression check (which seemed to be used as a check for whether the next token was {) to instead use astUtils.canTokensBeAdjacent, which generalizes the logic and allows the rule to work correctly with ( and [ tokens.

Is there anything you'd like reviewers to focus on?

Not really.

@platinumazure platinumazure changed the title Update: Use astUtils.canTokensBeAdjacent in space-unary-ops Update: Use astUtils.canTokensBeAdjacent in space-unary-ops (fixes #9907) Jan 29, 2018
@platinumazure platinumazure force-pushed the space-unary-ops-fix branch from 1ea47cc to 8fd2841 Jan 29, 2018
@platinumazure platinumazure changed the title Update: Use astUtils.canTokensBeAdjacent in space-unary-ops (fixes #9907) Update: space-unary-ops uses astUtils.canTokensBeAdjacent (fixes #9907) Jan 29, 2018
Copy link
Member Author

@platinumazure platinumazure commented Jan 29, 2018

@gyandeeps @not-an-aardvark Ended up throwing in some doc changes to avoid doing another force-push (as part of fixing the PR merge message). Hopefully nothing controversial but feel free to review again if you like. Thanks!

@platinumazure platinumazure merged commit dc80487 into master Feb 1, 2018
5 checks passed
@not-an-aardvark not-an-aardvark deleted the space-unary-ops-fix branch Feb 1, 2018
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Aug 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants