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

jsx-curly-spacing rule breaks with comments #584

Merged
merged 1 commit into from
May 8, 2016

Conversation

jkimbo
Copy link
Contributor

@jkimbo jkimbo commented May 3, 2016

When the jsx-curly-spacing rule is set to never the rule reports an error when there is a comment in the expression. I've added a failing test to illustrate this but I'm not sure how to go about fixing it. Any pointers?

Using https://astexplorer.net/#/Y9uxLiaZ7W it looks like it should be possible to use the trailingComments and leadingComments attributes on the node to take comments into account when comparing ranges though I'm not sure how to access them in the isSpaced function (https://github.com/jkimbo/eslint-plugin-react/blob/2b5a612755723862ec51790b7a6037d3ed68e594/lib/rules/jsx-curly-spacing.js#L37-L45)

@yannickcr yannickcr merged commit e882a18 into jsx-eslint:master May 8, 2016
@yannickcr
Copy link
Member

Thanks for the failing test case, it really helps to figure out the problem.

For the fix, I think I will replace isSpaced by the new ESLint isSpaceBetweenTokens function that already ignore comments.

@jkimbo
Copy link
Contributor Author

jkimbo commented May 8, 2016

Sounds like a good solution. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants