Skip to content
Merged
Prev Previous commit
Next Next commit
Rename variables
  • Loading branch information
david-szabo97 committed Feb 9, 2021
commit ae672af9879c278b307b21be3dfbf4951f4851e0
22 changes: 12 additions & 10 deletions packages/eslint-plugin/rules/no-store-string-literals.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ function getReferences( context, specifiers ) {
return references;
}

function collectAllNodesFromHocFunctions( context, node ) {
const hocSpecifiers = node.specifiers.filter(
function collectAllNodesFromCallbackFunctions( context, node ) {
const functionSpecifiers = node.specifiers.filter(
( specifier ) =>
specifier.imported &&
[
Expand All @@ -22,9 +22,9 @@ function collectAllNodesFromHocFunctions( context, node ) {
'withDispatch',
].includes( specifier.imported.name )
);
const hocReferences = getReferences( context, hocSpecifiers );
const functionReferences = getReferences( context, functionSpecifiers );

const hocFunctionVariables = hocReferences.reduce(
const functionArgumentVariables = functionReferences.reduce(
( acc, { identifier: { parent } } ) =>
parent && parent.arguments && parent.arguments.length > 0
? acc.concat(
Expand All @@ -33,11 +33,11 @@ function collectAllNodesFromHocFunctions( context, node ) {
: acc,
[]
);
const hocFunctionReferences = hocFunctionVariables.reduce(
const functionArgumentReferences = functionArgumentVariables.reduce(
( acc, variable ) => acc.concat( variable.references ),
[]
);
const possibleCallExpressionNodes = hocFunctionReferences
const possibleCallExpressionNodes = functionArgumentReferences
.filter( ( reference ) => reference.identifier.parent )
.map( ( reference ) => reference.identifier.parent );

Expand Down Expand Up @@ -100,7 +100,7 @@ module.exports = {
return;
}

const hocFunctionNodes = collectAllNodesFromHocFunctions(
const callbackFunctionNodes = collectAllNodesFromCallbackFunctions(
context,
node
);
Expand All @@ -113,9 +113,11 @@ module.exports = {
node
);

const allNodes = hocFunctionNodes
.concat( directNodes )
.concat( objectPropertyCallNodes );
const allNodes = [
...callbackFunctionNodes,
...directNodes,
...objectPropertyCallNodes,
];
allNodes
.filter(
( callNode ) =>
Expand Down