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

eslint crashes on .jsx files if react storybook is installed #12457

Closed
lerouxb opened this issue Oct 18, 2019 · 5 comments
Closed

eslint crashes on .jsx files if react storybook is installed #12457

lerouxb opened this issue Oct 18, 2019 · 5 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion

Comments

@lerouxb
Copy link

lerouxb commented Oct 18, 2019

With 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.

@lerouxb lerouxb added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Oct 18, 2019
@kaicataldo
Copy link
Member

Seems likely to be a dupe of #11018.

@kaicataldo kaicataldo added evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Oct 18, 2019
@iantocristian
Copy link

Pinning espree to 4.0.0 seems to solve the problem alright.

@lerouxb
Copy link
Author

lerouxb commented Oct 21, 2019

Pinning espree to any version works around the problem, so I pinned to ^6.0.0 which is what eslint is currently using.

@mysticatea
Copy link
Member

> npm ls acorn-jsx acorn
sandbox@0.0.0 C:\Users\t-nagashima.AD\dev\sandbox
+-- @storybook/react@5.2.4
| `-- webpack@4.41.2
|   `-- acorn@6.3.0
`-- eslint@6.5.1
  `-- espree@6.1.2
    +-- acorn@7.1.0
    `-- acorn-jsx@5.1.0

Yes, this is a duplicate of the long-standing issue #11018.

Would you confirm that this problem has been fixed by clean-install? In fact, I have released a new espree (6.1.2) that should fix this problem 10 hours ago.

@mysticatea mysticatea added evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Oct 21, 2019
@mysticatea
Copy link
Member

I'm closing this issue as a duplicate.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Apr 25, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion
Projects
None yet
Development

No branches or pull requests

4 participants