-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
sort-comp wrong order with RegExp rules and static methods #1821
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
Comments
Is the issue that #1795 needs to be reverted, or that the regex checking needs to be done in a second place? |
I think we should check for getDerivedStateFromProps more explicitly rather than use |
that makes sense. Can someone put up a PR? |
I'm creating a PR. The fix is a bit more involved than a revert or added RegExp check. |
The documentation isn't clear on expected behaviour. Does |
If |
There's a contradiction when method is static and matches regexp:
I think the problem is more deeper than it seems. |
The way that I'm implementing it at the moment is group order based. It's not a massive change to make statics the priority, but as you say, the API isn't flexible enough to cover all potential desired behaviours. |
Possible change of plan. I just hit the test that says that if a method matches two RegExps then it can be placed in either location. Should this be the case for everything? That would mean that The example in the issue description could have the methods with the statics, or with the RegExps. This is the most flexible option, but there will be people who do not like that flexibility. |
I think by default we should place For example, in this case lifecycle group doesn't include |
I have no doubt that having Making it more strict would require going back to your original PR commit and having explicit exceptions to rules. It may be the case that my PR will be a partial revert of your PR in your eyes, since it's less strict. Allowing static methods/properties to be in multiple places fixes two additional issues. #1838 and #1808 I'll push the PR and see what the feedback is. It should be done shortly after adding a test for an undiscovered bug that my changes fix. (While hopefully not breaking things we don't have tests for.) |
I believe this issues comes from #1795
The Airbnb rules for react include
sort-comp
with regex matching. source hereIf you have a static method that matches any of the 3 RegExp values (e.g.
renderCell
) then this will push to indexes, and the following check formethod.static
will not happen because of the new conditional on emptyindexes
.This should be valid according to the Airbnb Rules.
The text was updated successfully, but these errors were encountered: