Comparing version 2.2.0 to 2.3.0
@@ -24,2 +24,3 @@ 'use strict'; | ||
isObjectPattern, | ||
isTemplateLiteral, | ||
} = require('@babel/types'); | ||
@@ -47,8 +48,9 @@ | ||
const {node} = path; | ||
const {init} = node; | ||
if (isObjectPattern(node.id)) { | ||
if (isIdentifier(node.init)) | ||
use(path, node.init.name); | ||
if (isIdentifier(init)) | ||
use(path, init.name); | ||
path.traverse({ | ||
path.get('id').traverse({ | ||
ObjectProperty(propPath) { | ||
@@ -69,4 +71,4 @@ if (!isIdentifier(propPath.node.value)) | ||
if (isObjectExpression(node.init)) { | ||
for (const property of node.init.properties) { | ||
if (isObjectExpression(init)) { | ||
for (const property of init.properties) { | ||
if (isSpreadElement(property)) | ||
@@ -77,5 +79,11 @@ use(path, property.argument.name); | ||
} | ||
} else if (isTemplateLiteral(init)) { | ||
path.get('init').traverse({ | ||
Identifier(path) { | ||
use(path, path.node.name); | ||
} | ||
}); | ||
} | ||
declare(path, path.node.id.name); | ||
declare(path, node.id.name); | ||
}, | ||
@@ -145,2 +153,11 @@ | ||
path.traverse({ | ||
TemplateLiteral(path) { | ||
const {node} = path; | ||
const {expressions} = node; | ||
for (const exp of expressions) { | ||
if (isIdentifier(exp)) | ||
use(path, exp.name); | ||
} | ||
}, | ||
Identifier(path) { | ||
@@ -147,0 +164,0 @@ if (node.arguments.includes(path.node)) |
{ | ||
"name": "putout", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)", | ||
@@ -5,0 +5,0 @@ "description": "find and remove unused variables", |
Sorry, the diff of this file is not supported yet
16159
333