Skip to content

Commit e8da096

Browse files
ohhoney1ljharb
authored andcommitted
[Refactor] utils/Components: correct spelling and delete unused code
1 parent d0b5196 commit e8da096

File tree

3 files changed

+8
-33
lines changed

3 files changed

+8
-33
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
1515

1616
### Changed
1717
* [Docs] [`jsx-no-bind`]: updates discussion of refs ([#2998][] @dimitropoulos)
18+
* [Refactor] `utils/Components`: correct spelling and delete unused code ([#3026][] @ohhoney1)
1819

20+
[#3026]: https://github.com/yannickcr/eslint-plugin-react/pull/3026
1921
[#3016]: https://github.com/yannickcr/eslint-plugin-react/issues/3016
2022
[#3006]: https://github.com/yannickcr/eslint-plugin-react/pull/3006
2123
[#3001]: https://github.com/yannickcr/eslint-plugin-react/pull/3001

lib/util/Components.js

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,9 @@ function usedPropTypesAreEquivalent(propA, propB) {
3636
}
3737

3838
function mergeUsedPropTypes(propsList, newPropsList) {
39-
const propsToAdd = [];
40-
newPropsList.forEach((newProp) => {
41-
const newPropisAlreadyInTheList = propsList.some((prop) => usedPropTypesAreEquivalent(prop, newProp));
42-
if (!newPropisAlreadyInTheList) {
43-
propsToAdd.push(newProp);
44-
}
39+
const propsToAdd = newPropsList.filter((newProp) => {
40+
const newPropIsAlreadyInTheList = propsList.some((prop) => usedPropTypesAreEquivalent(prop, newProp));
41+
return !newPropIsAlreadyInTheList;
4542
});
4643

4744
return propsList.concat(propsToAdd);
@@ -412,30 +409,6 @@ function componentRule(rule, context) {
412409
return node.type === 'MemberExpression' && node.object.type === 'ThisExpression' && node.property.name === 'state';
413410
},
414411

415-
getReturnPropertyAndNode(ASTnode) {
416-
let property;
417-
let node = ASTnode;
418-
switch (node.type) {
419-
case 'ReturnStatement':
420-
property = 'argument';
421-
break;
422-
case 'ArrowFunctionExpression':
423-
property = 'body';
424-
if (node[property] && node[property].type === 'BlockStatement') {
425-
node = utils.findReturnStatement(node);
426-
property = 'argument';
427-
}
428-
break;
429-
default:
430-
node = utils.findReturnStatement(node);
431-
property = 'argument';
432-
}
433-
return {
434-
node,
435-
property
436-
};
437-
},
438-
439412
isReturningJSX(ASTNode, strict) {
440413
return jsxUtil.isReturningJSX(this.isCreateElement.bind(this), ASTNode, strict, true);
441414
},
@@ -552,9 +525,9 @@ function componentRule(rule, context) {
552525
},
553526

554527
/**
555-
* Find a return statment in the current node
528+
* Find a return statement in the current node
556529
*
557-
* @param {ASTNode} ASTnode The AST node being checked
530+
* @param {ASTNode} node The AST node being checked
558531
*/
559532
findReturnStatement: astUtil.findReturnStatement,
560533

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"babel-eslint": "^8.2.6",
5252
"eslint": "^3 || ^4 || ^5 || ^6 || ^7",
5353
"eslint-config-airbnb-base": "^14.2.1",
54-
"eslint-plugin-eslint-plugin": "^3.1.0",
54+
"eslint-plugin-eslint-plugin": "^2.3.0 || ^3.3.1",
5555
"eslint-plugin-import": "^2.23.4",
5656
"espree": "^3.5.4",
5757
"istanbul": "^0.4.5",

0 commit comments

Comments
 (0)