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

Not support for ES6 constructor method in sort-comp rule #88

Closed
tangrui opened this issue May 29, 2015 · 0 comments
Closed

Not support for ES6 constructor method in sort-comp rule #88

tangrui opened this issue May 29, 2015 · 0 comments

Comments

@tangrui
Copy link

tangrui commented May 29, 2015

The new React 0.13.x introduces ES6 features, which allows to write ES6 classes.

class MyComp extends React.Component {
  constructor() { ... }
  render() { ... }
}

We should always put constructor method at the very beginning of the class, but in this way, eslint will complain: constructor must be placed after render. If I place the "constructor" in the order options to adjust the rule, eslint will throw error:

/Users/tangrui/.nvm/v0.10.36/lib/node_modules/eslint-plugin-react/lib/rules/sort-comp.js:105
      isRegExp = methodsOrder[i].match(regExpRegExp);
                                 ^
TypeError: Object function Object() { [native code] } has no method 'match'
    at getRefPropIndexes (/Users/tangrui/.nvm/v0.10.36/lib/node_modules/eslint-plugin-react/lib/rules/sort-comp.js:105:34)
    at comparePropsOrder (/Users/tangrui/.nvm/v0.10.36/lib/node_modules/eslint-plugin-react/lib/rules/sort-comp.js:258:23)
    at checkPropsOrder (/Users/tangrui/.nvm/v0.10.36/lib/node_modules/eslint-plugin-react/lib/rules/sort-comp.js:322:17)
    at EventEmitter.Program:exit (/Users/tangrui/.nvm/v0.10.36/lib/node_modules/eslint-plugin-react/lib/rules/sort-comp.js:351:9)
    at EventEmitter.emit (events.js:117:20)
    at Controller.controller.traverse.leave (/Users/tangrui/.nvm/v0.10.36/lib/node_modules/eslint/lib/eslint.js:733:25)
    at Controller.__execute (/Users/tangrui/.nvm/v0.10.36/lib/node_modules/eslint/node_modules/estraverse/estraverse.js:393:31)
    at Controller.traverse (/Users/tangrui/.nvm/v0.10.36/lib/node_modules/eslint/node_modules/estraverse/estraverse.js:481:28)
    at EventEmitter.module.exports.api.verify (/Users/tangrui/.nvm/v0.10.36/lib/node_modules/eslint/lib/eslint.js:718:24)
    at processFile (/Users/tangrui/.nvm/v0.10.36/lib/node_modules/eslint/lib/cli-engine.js:197:27)
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