Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix]: utils/Components correct spelling and delete unused code #3026

Merged
merged 1 commit into from Aug 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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