Skip to content

Commit

Permalink
sort-comp instantiates regex from eslintrc properly (facebook#69)
Browse files Browse the repository at this point in the history
* sort-comp instantiates regex from eslintrc properly

This fixes the issue where react/sort-comp eslint rules such as `"/^render+.$/"` are incorrectly converted to `/\/^render.+$\//` rather than `/^render.+$/`

* convert actual regex to strings (like how it is in .eslintrc)
  • Loading branch information
jozanza authored and cpojer committed Jul 22, 2016
1 parent 6b618ba commit a88df92
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions transforms/sort-comp.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ const defaultMethodsOrder = [
'componentWillUpdate',
'componentDidUpdate',
'componentWillUnmount',
/^on.+$/,
/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/,
'/^on.+$/',
'/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/',
'everything-else',
/^render.+$/,
'/^render.+$/',
'render',
];

Expand All @@ -146,7 +146,8 @@ function selectorMatches(selector, method) {
const selectorIsRe = regExpRegExp.test(selector);

if (selectorIsRe) {
const selectorRe = new RegExp(selector);
const match = selector.match(regExpRegExp);
const selectorRe = new RegExp(match[1], match[2]);
return selectorRe.test(methodName);
}

Expand Down

0 comments on commit a88df92

Please sign in to comment.