Skip to content

[added] The rule to check propTypes declarations sorting. #72

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

Merged
merged 4 commits into from
Apr 21, 2015

Conversation

AlexKVal
Copy link
Contributor

Tests and Docs are included.

The jsx-sort-prop-types rule recognizes all supported patterns by this plugin
including those with ES6 classes syntax and static propTypes.

var Component = React.createClass({
  propTypes: {
    a: React.PropTypes.number,
    b: React.PropTypes.any
  }
...
class Component extends React.Component {
  ...
}
Component.propTypes = {
  a: React.PropTypes.any,
  b: React.PropTypes.string
};
class Component extends React.Component {
  static propTypes = {
    a: React.PropTypes.any,
    b: React.PropTypes.any,
    c: React.PropTypes.any
  }
  render() {
    return <div />;
  }
}

By default it is disabled.
Also it allows case ignoring.

Closes #38.

In the case this PR is merged it needs DRY refactoring.
(isPropTypesDeclaration() is the one to extract and isDisplayNameDeclaration() has similar code)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.21%) to 94.13% when pulling aebbcc4 on AlexKVal:38_sort_propTypes into 8624343 on yannickcr:master.

@yannickcr
Copy link
Member

Great work!

Can you add the new rule in the Readme? Then I think we can definitely merge it.

@AlexKVal AlexKVal force-pushed the 38_sort_propTypes branch from aebbcc4 to 4c1a524 Compare April 21, 2015 07:07
@coveralls
Copy link

Coverage Status

Coverage increased (+0.21%) to 94.13% when pulling 4c1a524 on AlexKVal:38_sort_propTypes into 76d5cd4 on yannickcr:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.21%) to 94.13% when pulling 4c1a524 on AlexKVal:38_sort_propTypes into 76d5cd4 on yannickcr:master.

@AlexKVal
Copy link
Contributor Author

I've forgot it. My bad :)
I've added it as fixup into docs commit AlexKVal@d2676bc

yannickcr added a commit that referenced this pull request Apr 21, 2015
Add jsx-sort-prop-types rule (fixes #38)
@yannickcr yannickcr merged commit a8737b5 into jsx-eslint:master Apr 21, 2015
@yannickcr
Copy link
Member

Perfect, thanks!

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

Successfully merging this pull request may close these issues.

Rule proposal: sorted propTypes
3 participants