sort-comp wrong order with RegExp rules and static methods
See original GitHub issueI believe this issues comes from #1795
The Airbnb rules for react include sort-comp
with regex matching. source here
If 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 for method.static
will not happen because of the new conditional on empty indexes
.
This should be valid according to the Airbnb Rules.
class Row extends React.Component {
static getDelta(data) {
...
}
static onTimeout() {
...
}
static renderCell(data) {
...
}
constructor(props) {
...
}
render() {
...
}
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:11 (11 by maintainers)
Top Results From Across the Web
sort-comp wrong order with RegExp rules and static methods
I believe this issues comes from #1795 The Airbnb rules for react include sort-comp with regex matching. source here If you have a...
Read more >Regular Expression (Regex) Tutorial
A regex (regular expression) consists of a sequence of sub-expressions. In this example ... Regex to be matched // Step 1: Compile a...
Read more >Regular expression syntax cheatsheet - JavaScript | MDN
This page provides an overall cheat sheet of all the capabilities of RegExp syntax by aggregating the content of the articles in the...
Read more >Best Practices for Regular Expressions in .NET - Microsoft Learn
Text that matches the regular expression pattern. ... Static regular expression methods are recommended as an alternative to repeatedly ...
Read more >A Practical Guide to Regular Expressions (RegEx) In JavaScript
In order to fully understand the regex world you first need to learn the basics concepts, ... There are mainly two methods for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m creating a PR. The fix is a bit more involved than a revert or added RegExp check.
I have no doubt that having
gDDFP
in lifecycle is a valid view. I’m willing to bet others think having it with statics is preferable. The precedence set with RegExps when this rule was first created is that things can appear in any matching group.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.)