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

Fix: Alphabetize jsx props with comments #36

Closed brandongregoryscott closed 2 years ago

brandongregoryscott commented 2 years ago

Resolves #25

Handles associating single-line and multi-line comments with props, for standard and spread attributes.

The code in alphabetizeJsxPropsWithSpread is really messy and I don't even quite understand it myself, but it is working - I'm going to add a refactor task. Since there's good test coverage there already, I think it should be pretty low-risk.

Additionally, the implementation here basically dwarfs the 'forgotten node' fix in https://github.com/brandongregoryscott/collation/commit/3e1df555c582a18ce8b39aad30ce7f821fa7e0e8. The ordering in alphabetize-jsx-props is important and I think we're going to keep hitting forgotten node errors in the future. I'm thinking that the p-retry library and retrying a rule (i.e. rerunning it on the same file until the errors are sorted out) should prevent a bunch of hacky re-try or one-off handling for forgotten nodes.

Finally, I slightly tweaked the logic in the fuzzy file finder so that it doesn't suggest an empty array. That doesn't help 🤦