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
astUtils.canTokensBeAdjacent hardcoded espree.tokenize #12291
Comments
Interesting. I definitely think we should change this. Ideally, we'd be able to use a custom configured parser for this, but it also forces custom parsers to implement a Maybe it could check if the configured parser has a |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
Reopening because I think this is an important discussion to have. @eslint/eslint-team Any other thoughts on this? |
Not sure I have any bright ideas. Passing through |
I think we should always call |
I agree that we should eventually require |
That sounds like a good plan to me. |
I'm not sure it's a good idea to require all parsers to have |
I would be okay with this as well. |
Wouldn't that break every time espree tried to tokenize some new syntax? |
We could use a try-catch and return a safe default value if espree fails.
|
Sounds good to me. I do think we can make it optional for parsers. Since most parsers most likely already have a tokenizer included somewhere in the code, it would be a minor enhancement for them to expose it. But having fallback to espree with try-catch is fine, I think. |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
@mdjermanovic Would you like to assign this to yourself to avoid this being auto-closed again? |
Now, after merging #12879,
Based on this comment by @not-an-aardvark and votes on it, it looks like we can close this issue? |
Agreed. |
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
What did you expect to happen?
What actually happened? Please include the actual, raw output from ESLint.
SyntaxError: Identifier directly after number
atEspree.raise ... canTokensBeAdjacent
.Problem
astUtils.canTokensBeAdjacent
can accept astring
value, which is useful when fixer adds some new code. But, it's using hardcodedespree.tokenize
withecmaVersion: 2015
.The same problem occurs with the following code when
babel-eslint
is used:Are you willing to submit a pull request to fix this bug?
Yes, but I'm not sure what would be the best approach. Whether to use the configured parser and configured options, or to somehow avoid this feature e.g., pass a token-like object instead of a string (that would require a change in 4-5 rules though).
The text was updated successfully, but these errors were encountered: