eslint-config-hardcore
eslint-config-hardcore copied to clipboard
Enforce alphabetical sorting of things
Or not?
I've never been a fan of alphabetical sorting, but I'm willing to give it a go.
Note: CSS has a better alternative (implemented in stylelint-config-recess-order and included in @twinscom/stylelint-config).
- [ ] If yes, should sorting be case-insensitive? I'm leaning towards case-insensitive, it should make it easier to scan code.
- [ ] Set
"ignoreCase": true
forreact/sort-prop-types
- [ ] Set
"ignoreCase": true
forreact/jsx-sort-default-props
- [ ] Set
"ignoreCase": true
forreact/jsx-sort-props
- [ ] Set
- [ ] eslint-plugin-sort-keys-fix
- [ ] eslint-plugin-sort-destructure-keys
- [ ] eslint-plugin-sort?
- [ ] imports (
alphabetize
option) - [ ] exports
- [ ] class members (
"sort": "alphabetical"
option) - [ ] ~variables?~
sort-vars
won't have any effect because it doesn't sort separate statements
Related: https://github.com/EvgenyOrekhov/eslint-config-hardcore/issues/453
-
I like to sort my imports by type (https://github.com/import-js/eslint-plugin-import/blob/HEAD/docs/rules/order.md). Unless you are talking about https://eslint.org/docs/rules/sort-imports; that seems fine to me!
-
https://eslint.org/docs/rules/sort-vars has problems when variables depend on another defined in the same block:
const b = 5, a = b + 10;
sort-vars
wants me to reverse the order of a
and b
, but that'll throw an error due to b
not being defined.
@RedGuy12 import/order
will remain by type:
https://github.com/EvgenyOrekhov/eslint-config-hardcore/blob/755a05129b0f4801aba74819fb6d83525c86ff13/base.json#L465-L479
but inside each group items will also be sorted alphabetically, see the alphabetize
option.
Regarding sort-vars
, "one-var": ["error", "never"]
will enforce this style which doesn't have the problem you described:
const b = 5;
const a = b + 10;
Oh, I see that sort-vars
doesn't sort separate statements, so it doesn't make sense to enable it.