@putout/plugin-remove-unused-variables
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -12,2 +12,3 @@ 'use strict'; | ||
isFunctionDeclaration, | ||
isArrayExpression, | ||
} = require('@babel/types'); | ||
@@ -29,2 +30,3 @@ | ||
const traverseTmpl = traverseTemplateLiteral(use); | ||
const traverseArray = traverseArrayExpression(use); | ||
@@ -35,2 +37,3 @@ return { | ||
const {init} = node; | ||
const idPath = path.get('id'); | ||
@@ -40,3 +43,3 @@ if (isIdentifier(node.id)) { | ||
} else if (isObjectPattern(node.id)) { | ||
path.get('id').traverse({ | ||
idPath.traverse({ | ||
ObjectProperty(propPath) { | ||
@@ -54,3 +57,3 @@ if (!isIdentifier(propPath.node.value)) | ||
} else if (isArrayPattern(node.id)) { | ||
path.get('id').traverse({ | ||
idPath.traverse({ | ||
Identifier(elPath) { | ||
@@ -79,2 +82,4 @@ const {elements} = node.id; | ||
traverseTmpl(path, init.expressions); | ||
else if (isArrayExpression(init)) | ||
traverseArray(initPath.get('elements')); | ||
}, | ||
@@ -428,2 +433,15 @@ | ||
const traverseArrayExpression = (use) => { | ||
const traverseObjExpression = traverseObjectExpression(use); | ||
return (elementsPaths) => { | ||
for (const elementPath of elementsPaths) { | ||
const {node} = elementPath; | ||
if (isObjectExpression(node)) | ||
traverseObjExpression(elementPath.get('properties')); | ||
} | ||
}; | ||
}; | ||
const traverseAssignmentExpression = (use) => { | ||
@@ -433,2 +451,3 @@ const traverseObjPattern = traverseObjectPattern(use); | ||
const traverseTmpl = traverseTemplateLiteral(use); | ||
const traverseArray = traverseArrayExpression(use); | ||
@@ -453,2 +472,4 @@ return (path) => { | ||
traverseTmpl(path, right.expressions); | ||
else if (isArrayExpression(right)) | ||
traverseArray(path.get('right.elements')); | ||
}; | ||
@@ -455,0 +476,0 @@ }; |
{ | ||
"name": "@putout/plugin-remove-unused-variables", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)", | ||
@@ -5,0 +5,0 @@ "description": "putout plugin adds ability to find and remove unused variables", |
23108
579