Open jl-compileit opened 1 month ago
"perfectionist/sort-objects": [
"error",
{
"ignore-pattern": ["data"]
}
]
Does ignore-pattern
solve your problem?
Does
ignore-pattern
solve your problem?
Unfortunately not; as I said we have many objects in many different places with many different names/no names that we don't want sorted.
Okay, I know. How about ignore-pattern
supports Function
to customize?
Okay, I know. How about
ignore-pattern
supportsFunction
to customize?
Sure, as long as the function receives enough information to differentiate between "regular" objects and destructuring, regardless of what names they may have or the files they're in. A tiny example of things we want to ignore: https://github.com/statelyai/xstate/blob/main/examples/fetch/src/fetchMachine.ts
Okay, I know. How about
ignore-pattern
supportsFunction
to customize?
@azat-io What do you think of this solution?
What rule do you want to change?
sort-objects
Describe the problem
We have too many objects that we don't want sorted (e.g. XState machines where properties are grouped logically) to make sort-objects with ignore-pattern and/or ESLint overrides feasible. It would be nice to still have object destructuring available, particularly for React components where currently the props' type get sorted but the prop destructuring does not.
Code example
Input:
Expected output:
Additional comments
Not sure if it should be an option to sort-objects or a new/split rule. https://github.com/mskelton/eslint-plugin-sort has separate rules for destructuring-properties and object-properties.
Validations