MCPcopy Index your code
hub / github.com/reactjs/react-codemod / findUnusedVariables

Function findUnusedVariables

transforms/class.js:1057–1074  ·  view source on GitHub ↗
(path, varName)

Source from the content-addressed store, hash-verified

1055 };
1056
1057 const findUnusedVariables = (path, varName) => j(path)
1058 .closestScope()
1059 .find(j.Identifier, {name: varName})
1060 // Ignore require vars
1061 .filter(identifierPath => identifierPath.value !== path.value.id)
1062 // Ignore import bindings
1063 .filter(identifierPath => !(
1064 path.value.type === 'ImportDeclaration' &&
1065 path.value.specifiers.some(specifier => specifier.local === identifierPath.value)
1066 ))
1067 // Ignore properties in MemberExpressions
1068 .filter(identifierPath => {
1069 const parent = identifierPath.parent.value;
1070 return !(
1071 j.MemberExpression.check(parent) &&
1072 parent.property === identifierPath.value
1073 );
1074 });
1075
1076 const updateToClass = (classPath) => {
1077 const specPath = ReactUtils.directlyGetCreateClassSpec(classPath);

Callers 1

class.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected