eslint crashes on .jsx files if react storybook is installed
See original GitHub issueWith latest eslint and latest react storybook installed, eslint crases in countTrailingLinebreaks while calling match
on undefined.
I’ve run this through a debugger and undefined there is from an end jsx tag token’s .value
.
If I remove react storybook from package.json, wipe node modules and npm install again, then it works. If I then install react storybook afterwords it also works. If I install via npm i --legacy-bundle
it also works. Which makes me think it is something to do with npm’s deduping.
What’s weird is that we have other repos that also use the same version of eslint, same eslintrc, same plugins and same react storybook and there we don’t get any crashes. So it seems to be even more subtle than that.
Tell us about your environment
- ESLint Version: v6.5.1
- Node Version: v10.15.0
- npm Version: v6.9.0
What parser (default, Babel-ESLint, etc.) are you using?
I’m not sure. Default eslint?
Please show your full configuration:
package.json:
{
"name": "lint-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "./node_modules/eslint/bin/eslint.js --ext .js,.jsx ."
},
"author": "",
"license": "ISC",
"devDependencies": {
"@storybook/react": "^5.2.4",
"eslint": "^6.5.1",
"eslint-plugin-react": "^7.16.0",
"eslint-plugin-react-hooks": "^2.1.2"
}
}
.eslintrc:
{
"env": {
"browser": true,
"es6": true
},
"globals": {
"process": true
},
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"plugins": [
"react",
"react-hooks"
],
"rules": {
"indent": [2, 2, { "SwitchCase": 1 }]
}
}
What did you do?
This is the source code I’m trying to lint:
test.jsx:
import React from 'react';
import { render } from 'react-dom';
export default () => {
render(<div></div>, document.querySelector('.react-app'));
};
node_modules/eslint/bin/eslint.js test.jsx
(I get the same with npm run lint
from package.json above and also $ npx eslint test.jsx
)
What did you expect to happen?
I expect it to not crash.
What actually happened?
TypeError: Cannot read property 'match' of undefined
Occurred while linting /Users/leroux/src/lint-test/test.jsx:1
at countTrailingLinebreaks (/Users/leroux/src/lint-test/node_modules/eslint/lib/rules/indent.js:792:47)
at elements.forEach (/Users/leroux/src/lint-test/node_modules/eslint/lib/rules/indent.js:859:65)
at Array.forEach (<anonymous>)
at addElementListIndent (/Users/leroux/src/lint-test/node_modules/eslint/lib/rules/indent.js:834:22)
at Object.addFunctionCallIndent [as listener] (/Users/leroux/src/lint-test/node_modules/eslint/lib/rules/indent.js:927:13)
at Program:exit.listenerCallQueue.filter.forEach.nodeInfo (/Users/leroux/src/lint-test/node_modules/eslint/lib/rules/indent.js:1585:55)
at Array.forEach (<anonymous>)
at Program:exit (/Users/leroux/src/lint-test/node_modules/eslint/lib/rules/indent.js:1585:26)
at listeners.(anonymous function).forEach.listener (/Users/leroux/src/lint-test/node_modules/eslint/lib/linter/safe-emitter.js:45:58)
at Array.forEach (<anonymous>)
Are you willing to submit a pull request to fix this bug?
I’d love to, but for now I’m out of ideas. Any pointers for how to continue to debug this further would be greatly appreciated.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Seems likely to be a dupe of https://github.com/eslint/eslint/issues/11018.
I’m closing this issue as a duplicate.