fix(sort-classes): #268: ignored nodes prevent their adjacent node from triggering linting #269
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theunknown
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
This PR will make the following errors appear:
method
:Expected "method" (unknown) to come before "b" (property)
a
:Expected "a" (property) to come before "method" (unknown)
The ideal message should appear only on
a
and sayExpected "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?