brandongregoryscott / eslint-plugin-collation

ESLint plugin for making your code easier to read, with autofix and TypeScript support
https://eslint-plugin-collation.brandonscott.me
Apache License 2.0
4 stars 0 forks source link

Update alphabetize-jsx-props to handle inline comments #25

Closed brandongregoryscott closed 2 years ago

brandongregoryscott commented 2 years ago

Ran into an error when attempting to alphabetize jsx props that contained a comment node, i.e.

<IconButton
    {...dragHandleProps}
    // Don't apply className with hover style if another element is being dragged
    className={isOtherElementDragging ? undefined : props.className}
    appearance="default"
    backgroundColor={theme.colors.gray200}
    onClick={onClick}
    size="small"
    visibility={visibility}
/>

will be transformed to:

<IconButton
    {...dragHandleProps}
    appearance="default"
    backgroundColor={theme.colors.gray200}
    // Don't apply className with hover style if another element is being dragged
    className={isOtherElementDragging ? undefined : props.className}
    onClick={onClick}
    size="small"
    visibility={visibility}
/>

Be sure to write a test that accounts for multi-line comments, too.