-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Running infinitely: ${f({ a:
${1} })}
; '' ? ${2}
: <em />
#1523
Comments
Maybe this piece of code is easier to understand to reproduce the issue: const s = `${'' + { a: `${1}` }}`;
const t = '' ? `${2}` : <em />; The problem happens when following is involved:
The problem does not happen if:
|
Thanks for the update; the first example was just two throwaway statements :-) This seems like a (totally obscure, strange, edge, but valid) bug. Thanks for the report and the repro repo! |
After a quick investigation, it looks to be an issue with using |
Interesting - it'd be useful to figure out if it's a bug in babel-eslint (which is possible), or a bug in this plugin when using babel-eslint (which is also possible). |
Some investigation later… The infinite loop comes from here: It seems that in some cases, let prevPrevToken = null;
do {
prevToken = sourceCode.getTokenBefore(prevToken);
if (prevToken === prevPrevToken) {
throw new Error('Woops, entering into an infinite loop!');
}
prevPrevToken = prevToken;
} while (prevToken.type === 'Punctuator'); I added some console.log(sourceCode.ast.tokens.map(t => t.value).join('·')); This is the result for non working code (entering infinite loop) (line return added for clarity): const·s·=·`${·''·+·{·a·:·`·template·${·1·}·template·`·}·}·template·`·;
const·t·=·''·?·`·template·${·2·}·template·`·:·<·em·/·>·; And the result for working code (not entering infinite loop, I just inverted the first and second operand of the ternary expression: const·s·=·`${·''·+·{·a·:·`·template·${·1·}·template·`·}·}·template·`·;
const·t·=·`·template·${·2·}·template·`·?·''·:·<·em·/·>·; As you can see there doesn’t seem to be a lot of differences, and the tokens seem okay (I don't know what So maybe the issue is in the |
If it’s only with babel-eslint, then i think you’d need to file an issue there. |
thanks! |
On a big file I have, ESLint is going into an infinite loop while linting. It doesn't throw any error, just never terminates. I reproduced the problem in a very short example.
You can reproduce the problem with this minimalistic repo I created.
Here is the file I want to run ESLint on:
I know it looks pretty weird, but the syntax is totally correct (with ES2015 and JSX). I simplified it as much as possible; if I change something (replace a template string with a plain string for instance) the problem doesn't reproduce.
Here is the package.json:
And the .eslintrc.js:
And finally what happens when I run ESLint:
The text was updated successfully, but these errors were encountered: