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 incorrectly treats string properties #1976

Closed
metreniuk opened this issue Sep 10, 2018 · 1 comment
Closed

sort-prop-types incorrectly treats string properties #1976

metreniuk opened this issue Sep 10, 2018 · 1 comment

Comments

@metreniuk
Copy link
Contributor

I have a prop that is declared using string literal. I expect that it should be sorted by its name and not by the single or double quote.
The way the props are compared doesn't take into account the quotes.
I expect that 'data-t': PropTypes.string.isRequired should be after
children: PropTypes.node.isRequired.

class Button extends Component {
  render() {
    const {children, ...restProps} = this.props;

    return (
      <button {...restProps}>
        {children}
      </button>
    );
  }
}

Button.propTypes = {
  children: PropTypes.node.isRequired,
  'data-t': PropTypes.string.isRequired,  // ESLint warning: Prop types declarations should be sorted alphabetically
  className: PropTypes.string,
};
@metreniuk
Copy link
Contributor Author

@ljharb I've made a fix and added tests in #1977 .

@metreniuk metreniuk changed the title sort-prop-types incorrectly treats escaped properties sort-prop-types incorrectly treats string properties Sep 10, 2018
ljharb pushed a commit to metreniuk/eslint-plugin-react that referenced this issue Sep 11, 2018
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