diff --git a/CHANGELOG.md b/CHANGELOG.md index 394a0db3f2..c85d143d70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,9 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel ### Changed * [Docs] [`jsx-no-bind`]: updates discussion of refs ([#2998][] @dimitropoulos) +* [Refactor] `utils/Components`: correct spelling and delete unused code ([#3026][] @ohhoney1) +[#3026]: https://github.com/yannickcr/eslint-plugin-react/pull/3026 [#3016]: https://github.com/yannickcr/eslint-plugin-react/issues/3016 [#3006]: https://github.com/yannickcr/eslint-plugin-react/pull/3006 [#3001]: https://github.com/yannickcr/eslint-plugin-react/pull/3001 diff --git a/lib/util/Components.js b/lib/util/Components.js index 0ba329dae5..8bf9372678 100644 --- a/lib/util/Components.js +++ b/lib/util/Components.js @@ -36,12 +36,9 @@ function usedPropTypesAreEquivalent(propA, propB) { } function mergeUsedPropTypes(propsList, newPropsList) { - const propsToAdd = []; - newPropsList.forEach((newProp) => { - const newPropisAlreadyInTheList = propsList.some((prop) => usedPropTypesAreEquivalent(prop, newProp)); - if (!newPropisAlreadyInTheList) { - propsToAdd.push(newProp); - } + const propsToAdd = newPropsList.filter((newProp) => { + const newPropIsAlreadyInTheList = propsList.some((prop) => usedPropTypesAreEquivalent(prop, newProp)); + return !newPropIsAlreadyInTheList; }); return propsList.concat(propsToAdd); @@ -412,30 +409,6 @@ function componentRule(rule, context) { return node.type === 'MemberExpression' && node.object.type === 'ThisExpression' && node.property.name === 'state'; }, - getReturnPropertyAndNode(ASTnode) { - let property; - let node = ASTnode; - switch (node.type) { - case 'ReturnStatement': - property = 'argument'; - break; - case 'ArrowFunctionExpression': - property = 'body'; - if (node[property] && node[property].type === 'BlockStatement') { - node = utils.findReturnStatement(node); - property = 'argument'; - } - break; - default: - node = utils.findReturnStatement(node); - property = 'argument'; - } - return { - node, - property - }; - }, - isReturningJSX(ASTNode, strict) { return jsxUtil.isReturningJSX(this.isCreateElement.bind(this), ASTNode, strict, true); }, @@ -552,9 +525,9 @@ function componentRule(rule, context) { }, /** - * Find a return statment in the current node + * Find a return statement in the current node * - * @param {ASTNode} ASTnode The AST node being checked + * @param {ASTNode} node The AST node being checked */ findReturnStatement: astUtil.findReturnStatement, diff --git a/package.json b/package.json index f5fed8f123..72a056d9d8 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "babel-eslint": "^8.2.6", "eslint": "^3 || ^4 || ^5 || ^6 || ^7", "eslint-config-airbnb-base": "^14.2.1", - "eslint-plugin-eslint-plugin": "^3.1.0", + "eslint-plugin-eslint-plugin": "^2.3.0 || ^3.3.1", "eslint-plugin-import": "^2.23.4", "espree": "^3.5.4", "istanbul": "^0.4.5",