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

"sort-prop-types" rule fails when using spread operator and ignoreCase is enabled #478

Closed
dimkaufo opened this issue Mar 2, 2016 · 2 comments

Comments

@dimkaufo
Copy link

dimkaufo commented Mar 2, 2016

If we define rule this way:

"rules": {
    "react/sort-prop-types": [2, {"ignoreCase": true}]
}

and if we have class with the following piece of code:

import {Component} from 'react';

const spread = {
    a: PropTypes.string,
    b: PropTypes.object,
}

export default class ClassWithSpreadInPropTypes extends Component {
   static propTypes = {
       ...spread,
       c: PropTypes.string
   }
}

then we have the following error: TypeError: Cannot read property 'toLowerCase' of undefined

eslint-plugin-react version 4.1.0

@yannickcr
Copy link
Member

I was not able to reproduce the crash.

What versions of eslint and babel-eslint are you using?

@dimkaufo
Copy link
Author

dimkaufo commented Mar 7, 2016

Sorry, it seems that spread operator is not the only reason of this crash (my previous example is not valid). That is valid:

a.js

import {Component, PropTypes} from 'react';

export default class BaseClass extends Component {
   static propTypes = {
       a: PropTypes.string,
       b: PropTypes.object
   }
}

b.js

import {PropTypes} from 'react';
import BaseClass from 'a';

export default class ClassWithSpreadInPropTypes extends BaseClass {
   static propTypes = {
       ...BaseClass.propTypes,
       c: PropTypes.string
   }
}

versions:

"babel-eslint": "5.0.0",
"eslint": "1.10.3",
"eslint-plugin-react": "4.1.0"

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

No branches or pull requests

2 participants