Add a rule option to only detect/fix top-level keys
Opened this issue · 0 comments
longzheng commented
It would be great if we can specify an option so that only the top-level keys are sorted, while nested keys are ignored/left alone.
For example using the default options
/* eslint sort-keys/sort-keys-fix: "error" */
export const test = {
b: 'b',
a: {
b: 'b',
a: 'a',
},
};
will be sorted to
export const test = {
a: {
a: 'a',
b: 'b',
},
b: 'b',
};
It would be great if I can specify an option like nested: true
/* eslint sort-keys/sort-keys-fix: ["error", "asc", {nested: false}] */
export const test = {
b: 'b',
a: {
b: 'b',
a: 'a',
},
};
so it becomes
export const test = {
a: {
b: 'b',
a: 'a',
},
b: 'b',
};