Skip to content

sort-prop-types incorrectly treats string properties #1976

Closed
@metreniuk

Description

@metreniuk

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,
};

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