Currently, I use the sort-keys rule for eslint:
"sort-keys": [
"error",
"asc",
{
"caseSensitive": true,
"natural": false,
"minKeys": 2
}
]
and it properly errors out when I have keys in a JS object that are not alphabetized.
What I am hoping to discover is a way to iterate on this rule to expand it to other things I want sorted. I have case where I use serialized styles for css properties which are embedded inside of other object keys:
const styles = {
container: css`
width: 100%;
border-radius: 0.25rem;
`,
date: css`
margin-bottom: 0.5rem;
width: 100%;
`,
info: css`
flex-wrap: wrap;
display: flex;
font-weight: 400;
`,
}
In the above case, if the style object keys are out of order, sort-keys works as expected. I am curious if there is a rule I can add which errors if the properties are non-alphabetized.