question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

eslint crashes on .jsx files if react storybook is installed

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
kaicataldocommented, Oct 18, 2019

Seems likely to be a dupe of https://github.com/eslint/eslint/issues/11018.

0reactions
mysticateacommented, Oct 26, 2019

I’m closing this issue as a duplicate.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Storybook fails on eslint errors in react - Stack Overflow
In my case I just wanted to disabled eslint errors during development so. DISABLE_ESLINT_PLUGIN=true start-storybook -p 6006 -s public.
Read more >
How to use Storybook with ESLint - JS.ORG
You'll first need to install ESLint if you don't have already: ... This linter will only run against files following the *.stories.
Read more >
@storybook/react-native-server | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
missing class properties transform storybook - You.com
On start up I'm getting a bunch of Syntax Error: Missing class properties transform errors. However, it looks like @babel/plugin-proposal-class-properties is ...
Read more >
Create React v18 TypeScript Project with webpack and Babel
It solves dependencies and bundle files into one file. Because webpack provide convenient package called webpack dev server and webpack-cli, let's install them ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found