Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import ``,ESLint: Cannot read property 'range' of null Occurred while linting

Tags:

eslint

The error is because of this line of code

item.component = () => import(`@/views/${_component}`)

If I modify .eslintrc.js, it works

'indent' : "off",
'template-curly-spacing' : "off",

But this way, eslint won't help me format the code

when I run the following code, He can't work, but eslint has no errors:

item.component = () => import(`@/views/` + _component)
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.0.1",
"eslint": "5.15.3",

node -v: v12.9.1

eslint -v: v6.8.0

vscode

like image 770
ebyte Avatar asked Jan 22 '20 02:01

ebyte


1 Answers

Try setting your eslint indent rule to contain: ignoredNodes for template literals. My eslintrc.js has the following:

rules: {
  indent: [2, "tab", { 
    ignoredNodes: ["TemplateLiteral"] 
  }],
  ... etc ...
}

That will ignore extended template literals.

If the above doesn't work, try deleting package-lock.json and node_modules then re-install with npm i or yarn. This will restore your packages and reset downline versions.

like image 149
JREAM Avatar answered Nov 09 '22 01:11

JREAM