Skip to content

Eslint crashes when using the object spread operator and React.createClass #624

Closed
@mandx

Description

@mandx

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"
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions