-
Notifications
You must be signed in to change notification settings - Fork 44
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
feat(sort-objects): Adds ignore rule for objects passed as arguments to function calls #420
feat(sort-objects): Adds ignore rule for objects passed as arguments to function calls #420
Conversation
eddaeb4
to
4eb6c9c
Compare
* Rules with `useConfigurationIf` will be able to use the `unsorted` type.
- `let options = { ...completeOptions, type }` is necessary for compilation: this allows the compiler to know that `options.type` can not be `unsorted`. I wish it would detect it without having to do that, but it doesn't. If you have a cleaner way, feel free to suggest.
- Same comment as the previous commit.
- It will return the list of matching context options instead of the first matched context options. - This will allow us to add additional custom filters for `sort-objects` in next commit.
- Returned parents will have their types correctly inferred.
- I feel it's more explicit this way.
4eb6c9c
to
8eb9a79
Compare
8eb9a79
to
630e8c2
Compare
@@ -129,6 +129,7 @@ Specifies the sorting method. | |||
- `'natural'` — Sort items in a [natural](https://github.com/yobacca/natural-orderby) order (e.g., “item2” < “item10”). | |||
- `'line-length'` — Sort items by the length of the code line (shorter lines first). | |||
- `'custom'` — Sort items using the alphabet entered in the [`alphabet`](#alphabet) option. | |||
- `'unsorted'` — Do not sort items. To be used with the [`useConfigurationIf`](#useConfigurationIf) option. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of the name 'no-sort'
or 'preserve-order'
? Or do you prefer 'unsorted'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I prefer
unsorted
andno-sort
overpreserve-order
(I feel the first two are more explicit). unsorted
is already used incustomGroups
.
eslint-plugin-perfectionist/rules/sort-classes.types.ts
Lines 205 to 216 in 7fdadd7
type CustomGroup = ( | { order?: SortClassesOptions[0]['order'] type?: SortClassesOptions[0]['type'] } | { type?: 'unsorted' } ) & (SingleCustomGroup | AnyOfCustomGroup) & { groupName: string }
I think it's better for consistency to keep the same name, so I would personally pick unsorted
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, thank you 👍
Do I understand correctly that we should remove the |
Sorry, I'm not sure to understand! What do you mean? |
@hugop95 You added scope in commit message |
@azat-io you can remove it you want, the PR does affects other rules as well (by adding the |
Resolves #413
Changes
useConfigurationIf.callingFunctionNamePattern
option tosort-objects
. Object that are not parameters of a function will not be matched by configurations using this option.unsorted
astype
.Example configuration:
What is the purpose of this pull request?