azat-io / eslint-plugin-perfectionist

🦄 ESLint plugin for sorting various data such as objects, imports, types, enums, JSX props, etc.
https://eslint-plugin-perfectionist.azat.io
MIT License
1.66k stars 30 forks source link

fix: handle more complex expressions in sort-objects #57

Closed stovmascript closed 10 months ago

stovmascript commented 10 months ago

Description

3e987ae7e6fa9fc21caa7e23fb8b17d9ece027f0 fixes references to dependencies/earlier params (#9), but not in some more complex cases. Examples are provided in tests.

Additional context

Do you think this is a good approach? I think we should try to search all of the nested nodes for Identifiers, which would be pushed to the dependencies array. I'm not sure I covered all the possible cases with this approach.

The tests also probably need some more work on the semantics :)


What is the purpose of this pull request?

Before submitting the PR, please make sure you do the following

azat-io commented 10 months ago

Looks good. Thanks!

stovmascript commented 10 months ago

@azat-io Wow, that was fast :) I'll try to follow up with a PR adding the missing test cases and possibly doing something about making this auto fixable.