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 when using the object spread operator and React.createClass #624

Closed
mandx opened this issue Jun 6, 2016 · 2 comments
Closed

Comments

@mandx
Copy link

mandx commented Jun 6, 2016

Test file

import React from 'react';

const proto = {};

const Test = React.createClass({
    ...proto,

    render: function () {
        return <span></span>;
    }
});

export default Test;

Output:

Cannot read property 'name' of undefined
TypeError: Cannot read property 'name' of undefined
    at getPropertyName (/home/mandx/Work/test-project/node_modules/eslint-plugin-react/lib/rules/sort-comp.js:157:20)
    at /home/mandx/Work/test-project/node_modules/eslint-plugin-react/lib/rules/sort-comp.js:324:15
    at Array.map (native)
    at checkPropsOrder (/home/mandx/Work/test-project/node_modules/eslint-plugin-react/lib/rules/sort-comp.js:322:38)
    at EventEmitter.Program:exit (/home/mandx/Work/test-project/node_modules/eslint-plugin-react/lib/rules/sort-comp.js:374:9)
    at emitOne (events.js:95:20)
    at EventEmitter.emit (events.js:182:7)
    at NodeEventGenerator.leaveNode (/home/mandx/Work/test-project/node_modules/eslint/lib/util/node-event-generator.js:49:22)
    at CodePathAnalyzer.leaveNode (/home/mandx/Work/test-project/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:627:23)
    at CommentEventGenerator.leaveNode (/home/mandx/Work/test-project/node_modules/eslint/lib/util/comment-event-generator.js:110:23) 

Eslint command line (called by SublimeLinter-eslint):

node_modules/.bin/eslint --format compact --stdin --stdin-filename @

.eslintrc file:

{
  "extends": [
    "eslint:recommended",
    "plugin:import/errors",
    "plugin:import/warnings"
  ],
  "plugins": [
    "react",
    "import"
  ],
  "settings": {
    "import/extensions": [".js", ".jsx", ".scss", ".css"],
    "import/resolver": {
      "webpack": {
        "config": "webpack.config.js"
      }
    }
  },
  "parser": "babel-eslint",
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true,
      "experimentalObjectRestSpread": true
    }
  },
  "env": {
    "es6": true,
    "browser": true,
    "node": true,
    "jquery": true,
    "mocha": true
  },
  "rules": {
    "quotes": 0,
    "no-console": 1,
    "no-debugger": 1,
    "no-var": 1,
    "semi": [2, "always"],
    "no-trailing-spaces": 0,
    "eol-last": 0,
    "no-unused-vars": 0,
    "no-underscore-dangle": 0,
    "no-alert": 0,
    "no-lone-blocks": 0,
    "jsx-quotes": 1,
    "comma-dangle": [0, "always"],
    "react/display-name": [ 1, {"ignoreTranspilerName": false }],
    "react/forbid-prop-types": [1, {"forbid": ["any"]}],
    "react/jsx-boolean-value": 1,
    "react/jsx-closing-bracket-location": 0,
    "react/jsx-curly-spacing": 1,
    "react/jsx-indent-props": 0,
    "react/jsx-key": 1,
    "react/jsx-max-props-per-line": 0,
    "react/jsx-no-bind": 1,
    "react/jsx-no-duplicate-props": 1,
    "react/jsx-no-literals": 0,
    "react/jsx-no-undef": 1,
    "react/jsx-pascal-case": 1,
    "react/jsx-sort-prop-types": 0,
    "react/jsx-sort-props": 0,
    "react/jsx-uses-react": 1,
    "react/jsx-uses-vars": 1,
    "react/no-danger": 1,
    "react/no-did-mount-set-state": 1,
    "react/no-did-update-set-state": 1,
    "react/no-direct-mutation-state": 1,
    "react/no-multi-comp": 1,
    "react/no-set-state": 0,
    "react/no-unknown-property": 1,
    "react/prefer-es6-class": 1,
    "react/prop-types": 1,
    "react/react-in-jsx-scope": 1,
    "react/require-extension": 1,
    "react/self-closing-comp": 1,
    "react/sort-comp": 1,
    "react/wrap-multilines": 0,
    "import/no-amd": [1, "always"],
    "import/no-commonjs": [1, "always"],
    "import/no-unresolved": 2
  }
}

.babelrc file:

{
    "presets": ["es2015", "stage-2", "react"],
    "plugins": [
        "transform-class-properties",
        "transform-runtime"
    ]
}
@mandx mandx changed the title Esling crashes when using the object spread operator and React.createClass Eslint crashes when using the object spread operator and React.createClass Jun 6, 2016
@ljharb
Copy link
Member

ljharb commented Jun 6, 2016

What version of eslint and eslint-plugin-react are you using?

@mandx
Copy link
Author

mandx commented Jun 6, 2016

Oh yes, I'm sorry I forgot about that. Here it is:

$ npm ls | grep eslint
├─┬ babel-eslint@6.0.4
├─┬ eslint@2.11.1
├─┬ eslint-import-resolver-webpack@0.3.0
├─┬ eslint-plugin-import@1.8.1
│ ├── eslint-import-resolver-node@0.2.0
├── eslint-plugin-react@5.1.1

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

No branches or pull requests

2 participants