-
-
Notifications
You must be signed in to change notification settings - Fork 131
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
Add rule to order definitions #267
Comments
Hi! This was marked as ready to be worked on! Note that while this is ready to be worked on, nothing is said about priority: it may take a while for this to be solved. Is this something you can and want to work on? Team: please use the |
I like this idea!
I think definitions should be sorted within each group. Requiring a list of definitions to be moved to the end could be a separate rule.
I’d say a definition is sorted wrongly if it should appear above it’s sibling. [remark]: https://remark.js.org
[unifiedjs]: https://unifiedjs.com
[rehype]: https://rehype.js.org
^^^^^^-- message: “rehype” link reference should be sorted before “unifiedjs” Auto fixing may be nice as well. See vfile/vfile-message#13 (comment) |
So the rule would first create “groups” (nodes with the same parent that do not have non-definitions between them). 👍 But what about:
3 warnings for b, c, and d? Or one for z? (Not sure if you already took this example into account, which I sort of alluded to in the prose) |
In that case only b would be reported. If this is corrected, the file looks like this: [a]: #
[b]: #
[z]: #
[c]: #
[d]: # Now c will be reported. Something is always reported if an item is out of order, so the user will have to repeat this process until everything is sorted as expected. It would also be possible to report b, c, and d. That would mean that for each definition in the group would need to be checked against all of its preceding siblings until a violation is found. In the end this has the same result: The user has to sort the definitions until no more messages appear. It may be a bit more daunting if 3 violations are reported. I don’t think It’s necessarily more or less correct to do so. If the checks would happen from end to start, then only z would be reported with either strategy. |
I've taken a stab at this, though as a remark transformer rather than a remark-lint rule: remark-sort-definitions. |
Subject of the feature
It’s hard to sort definitions manually, and vague how to do it.
Problem
My list of definitions, at the end of readmes, is messy
Expected behavior
Options to sort a) alphabetically, b) first-use?
Alternatives
?
Questions
The text was updated successfully, but these errors were encountered: