Skip to content
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

fix(sort-classes): #268: ignored nodes prevent their adjacent node from triggering linting #269

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

hugop95
Copy link
Contributor

@hugop95 hugop95 commented Sep 13, 2024

Description

Fixes #268.

When implementing the notion of ignored unknown group, ignored nodes were set to avoid creating linting errors: it's a bit counter-intuitive to tell the user that an ignored node should be before or after another node if it's supposed to be ignored.

Because linting errors are based on adjacent nodes comparison, classes that only have errors between ignored nodes and their adjacent nodes will not raise any error, and thus not trigger linting.

In practice, this likely shouldn't happen often and is fixed as soon as another error is detected in the class, as it will trigger linting and correctly sort it, so I don't believe this is a big issue (I detected it by accident while trying something else).

Custom groups with the unsorted sort type are unrelated to this issue. Only cases where a node has the unknown group may trigger this behavior.

This PR removes the checks that prevented errors from being raised between an ignored node and its adjacent nodes.

Because those ignored nodes now create ESLint error messages, a test had to be updated as it would now display more errors than before.

Possible improvements for another PR

class Class {
    b

    method() {
    }

    a
}

This PR will make the following errors appear:

  • on method: Expected "method" (unknown) to come before "b" (property)
  • on a: Expected "a" (property) to come before "method" (unknown)

The ideal message should appear only on a and say Expected "a" to come before "b".
The reasoning behind is that if we compute that a node N1 needs to be placed before an adjacent ignored node NI, then there is at least one other node N2 before NI that should be placed after N1.

What is the purpose of this pull request?

  • Bug fix

@hugop95 hugop95 changed the title fix(268): sort-classes: ignored nodes prevent their adjacent node from trigg… fix(268): sort-classes: ignored nodes prevent their adjacent node from triggering linting Sep 14, 2024
@hugop95 hugop95 changed the title fix(268): sort-classes: ignored nodes prevent their adjacent node from triggering linting fix(sort-classes): #268: ignored nodes prevent their adjacent node from triggering linting Sep 14, 2024
@azat-io
Copy link
Owner

azat-io commented Sep 19, 2024

Could you fix merge conflicts?

@hugop95
Copy link
Contributor Author

hugop95 commented Sep 19, 2024

@azat-io Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: sort-classes: Ignored nodes prevent their adjacent node from triggering linting
2 participants