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

Possibly wrong parsing with the ESLint "template-curly-spacing" rule #69

Closed
tmcdos opened this issue May 4, 2020 · 1 comment
Closed

Comments

@tmcdos
Copy link

tmcdos commented May 4, 2020

I have this simple Vue.js project
test.zip
When I run npm run build I get a crash:

Z:\1>npm run build

> composite@1.0.6 build Z:\1
> node --preserve-symlinks --preserve-symlinks-main ./node_modules/@vue/cli-serv
ice/bin/vue-cli-service.js build

-  Building for production...

 ERROR  Failed to compile with 1 errors                                 17:11:23

 error  in ./src/App.vue

Module build failed (from ./node_modules/eslint-loader/index.js):
TypeError: Cannot read property 'range' of null
Occurred while linting Z:\1\src\App.vue:11
    at SourceCode.getTokenBefore (Z:\1\node_modules\eslint\lib\source-code\token
-store\index.js:298:18)
    at checkSpacingBefore (Z:\1\node_modules\eslint\lib\rules\template-curly-spa
cing.js:60:42)
    at TemplateElement (Z:\1\node_modules\eslint\lib\rules\template-curly-spacin
g.js:119:17)
    at Z:\1\node_modules\eslint\lib\linter\safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (Z:\1\node_modules\eslint\lib\linter\safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (Z:\1\node_modules\eslint\lib\linter\nod
e-event-generator.js:254:26)
    at NodeEventGenerator.applySelectors (Z:\1\node_modules\eslint\lib\linter\no
de-event-generator.js:283:22)
    at NodeEventGenerator.enterNode (Z:\1\node_modules\eslint\lib\linter\node-ev
ent-generator.js:297:14)
    at CodePathAnalyzer.enterNode (Z:\1\node_modules\eslint\lib\linter\code-path
-analysis\code-path-analyzer.js:634:23)
    at Z:\1\node_modules\eslint\lib\linter\linter.js:936:32
    at Array.forEach (<anonymous>)
    at runRules (Z:\1\node_modules\eslint\lib\linter\linter.js:931:15)
    at Linter._verifyWithoutProcessors (Z:\1\node_modules\eslint\lib\linter\lint
er.js:1157:31)
    at Z:\1\node_modules\eslint\lib\linter\linter.js:1281:29
    at Array.map (<anonymous>)

 @ ./src/main.js 5:0-28 7:17-20
 @ multi ./src/main.js

 ERROR  Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! composite@1.0.6 build: `node --preserve-symlinks --preserve-symlinks-ma
in ./node_modules/@vue/cli-service/bin/vue-cli-service.js build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the composite@1.0.6 build script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     z:\temp\npm\_logs\2020-05-02T14_11_23_489Z-debug.log

Z:\1>

80866569-198fe600-8c98-11ea-81d4-69d20fd014c4

The issue occurs with the ESLint rule template-curly-spacing - only when there are no interpolations in a JavaScript string template (those contained in backticks). The token variable on line 117 in file eslint/lib/rules/template-curly-spacing.js is undefined in such cases.

I reported the issue to ESLint (eslint/eslint#13248) but they claim that the problem lies in Vue-ESLint-parser because getFirstToken(node) should never return undefined for a TemplateElement.

Any ideas ?

@ota-meshi
Copy link
Member

I have checked your files. It's a babel-eslint problem. The same problem occurs with js file that have the same code.
You can either stop using babel-eslint or contact the babel-eslint repository.

However, the babel-eslint repository is archived. You need to find out your new contact.
https://github.com/babel/babel-eslint

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

No branches or pull requests

2 participants