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

Lexicographical sorting of object keys #585

Open
LinusU opened this issue Nov 23, 2023 · 0 comments
Open

Lexicographical sorting of object keys #585

LinusU opened this issue Nov 23, 2023 · 0 comments

Comments

@LinusU
Copy link

LinusU commented Nov 23, 2023

A bit similar to #561, but this is for every object literal.

There is an ESLint rule for this:
https://eslint.org/docs/latest/rules/sort-keys

Since ESLint are removing formatting rules, they have not accepted pull requests to implement auto-fixing of that rule, it instead lives in a separate repo:
https://github.com/leo-buneev/eslint-plugin-sort-keys-fix

This is very useful in larger codebases where multiple people commit to, in order to reduce merge conflicts if everyone is always appending new keys to the end of objects.

Example:

- let obj1 = {a: 1, c: 3, b: 2}
+ let obj1 = {a: 1, b: 2, c: 3}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant