Skip to content

Commit 7c1d98b

Browse files
improved unused variable feature #24
1 parent 7bac4f0 commit 7c1d98b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

changelog/0.16.0.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ v0.16.0
1919
- Improved extract method feature
2020
- Improved completions detection from default_autocomplete.json
2121
- Added flow warnings
22+
- Improved unused variable feature
2223

2324
## Misc
2425
- Changed gutter color (using other available sublime scopes) for errors and unused variable features.

src/listeners/show_unused_variables.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def on_modified_async_with_thread(self, recheck=True):
124124

125125
repetitions[variable_name] = [variable_region]
126126

127-
items = util.nested_lookup("type", ["VariableDeclarator", "MemberExpression", "CallExpression", "BinaryExpression", "ExpressionStatement", "Property", "ArrayExpression", "ObjectPattern", "AssignmentExpression", "IfStatement", "ForStatement", "WhileStatement", "ForInStatement", "ForOfStatement", "LogicalExpression", "UpdateExpression", "ArrowFunctionExpression", "ConditionalExpression", "JSXIdentifier", "ExportDefaultDeclaration", "JSXExpressionContainer", "NewExpression", "ReturnStatement", "SpreadProperty", "TemplateLiteral", "ObjectPattern"], body)
127+
items = util.nested_lookup("type", ["VariableDeclarator", "MemberExpression", "CallExpression", "BinaryExpression", "ExpressionStatement", "Property", "ArrayExpression", "ObjectPattern", "AssignmentExpression", "IfStatement", "ForStatement", "WhileStatement", "ForInStatement", "ForOfStatement", "LogicalExpression", "UpdateExpression", "ArrowFunctionExpression", "ConditionalExpression", "JSXIdentifier", "ExportDefaultDeclaration", "JSXExpressionContainer", "NewExpression", "ReturnStatement", "SpreadProperty", "TemplateLiteral", "ObjectPattern", "ObjectExpression"], body)
128128
for item in items:
129129

130130
if "exportKind" in item and "declaration" in item and isinstance(item["declaration"],dict) and "name" in item["declaration"] and item["declaration"]["type"] == "Identifier":
@@ -182,6 +182,9 @@ def on_modified_async_with_thread(self, recheck=True):
182182
elif "expression" in item and isinstance(item["expression"],dict) and "name" in item["expression"] and item["expression"]["type"] == "Identifier":
183183
item = item["expression"]
184184

185+
elif "expression" in item and isinstance(item["expression"],dict) and item["expression"]["type"] == "TaggedTemplateExpression" and "tag" in item["expression"]:
186+
item = item["expression"]["tag"]
187+
185188
elif "argument" in item and isinstance(item["argument"],dict) and "name" in item["argument"] and item["argument"]["type"] == "Identifier":
186189
item = item["argument"]
187190

0 commit comments

Comments
 (0)