Skip to content

Commit

Permalink
[Refactor] utils/Components: correct spelling and delete unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
ohhoney1 authored and ljharb committed Jul 27, 2021
1 parent d0b5196 commit e8da096
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 33 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down
37 changes: 5 additions & 32 deletions lib/util/Components.js
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
},
Expand Down Expand Up @@ -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,

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down

0 comments on commit e8da096

Please sign in to comment.