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

style-prop-object crashes with empty style tag #834

Closed
Arcanemagus opened this issue Sep 14, 2016 · 0 comments
Closed

style-prop-object crashes with empty style tag #834

Arcanemagus opened this issue Sep 14, 2016 · 0 comments
Labels

Comments

@Arcanemagus
Copy link
Contributor

It seems that the react/style-prop-object rule crashes when the style tag of a <div> is empty with the following error:

CLI:

Cannot read property 'type' of null
TypeError: Cannot read property 'type' of null
    at EventEmitter.JSXAttribute (C:\Temp\github\linter-eslint_GH702\node_modules\eslint-plugin-react\lib\rules\style-prop-object.js:70:21)
    at emitOne (events.js:96:13)
    at EventEmitter.emit (events.js:188:7)
    at NodeEventGenerator.enterNode (C:\Temp\github\linter-eslint_GH702\node_modules\eslint\lib\util\node-event-generator.js:40:22)
    at CodePathAnalyzer.enterNode (C:\Temp\github\linter-eslint_GH702\node_modules\eslint\lib\code-path-analysis\code-path-analyzer.js:608:23)
    at CommentEventGenerator.enterNode (C:\Temp\github\linter-eslint_GH702\node_modules\eslint\lib\util\comment-event-generator.js:97:23)
    at Controller.enter (C:\Temp\github\linter-eslint_GH702\node_modules\eslint\lib\eslint.js:918:36)
    at Controller.__execute (C:\Temp\github\linter-eslint_GH702\node_modules\estraverse\estraverse.js:397:31)
    at Controller.traverse (C:\Temp\github\linter-eslint_GH702\node_modules\estraverse\estraverse.js:501:28)
    at Controller.Traverser.controller.traverse (C:\Temp\github\linter-eslint_GH702\node_modules\eslint\lib\util\traverser.js:36:33)

The trace is similar through the Node.js API.

You can reproduce this error with the following configuration:

.eslintrc.js:

module.exports = {
  rules: {
    'react/style-prop-object': 'error',
  },
  plugins: [
    'react'
  ],
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    ecmaVersion: 2016,
    sourceType: 'module'
  },
  ecmaFeatures: {
    jsx: true
  },
};

package.json:

{
  "private": true,
  "license": "MIT",
  "description": "Test package for linter-eslint #702",
  "scripts": {
    "lint": "eslint foo.jsx"
  },
  "dependencies": {
    "eslint": "3.5.0",
    "eslint-plugin-react": "6.2.1"
  }
}

foo.jsx:

const foo = (
  <div style></div>
);

For convenience here is a ZIP file containing the files use to reproduce this: linter-eslint_GH702.zip

Note: This was originally filed as AtomLinter/linter-eslint#702.

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

No branches or pull requests

2 participants