Skip to content

Commit 50271f2

Browse files
committed
feature: @putout/plugin-remove-unreferenced-variables: AssignmentExpression: exclude
1 parent c02abb4 commit 50271f2

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

packages/plugin-remove-unreferenced-variables/lib/remove-unreferenced-variables.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ module.exports.traverse = ({push}) => ({
3434
push(path);
3535
},
3636
'__identifier = __a'(path) {
37-
if (path.parentPath.isConditionalExpression())
37+
const {parentPath} = path;
38+
39+
if (parentPath.isMemberExpression())
40+
return;
41+
42+
if (parentPath.isConditionalExpression())
3843
return;
3944

4045
const {name} = path.node.left;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
let files = [];
2+
3+
while (!(files = readDirectory(parentDir)).length) {
4+
const name = getFilename(parentDir);
5+
6+
if (name === '/')
7+
break;
8+
}

packages/plugin-remove-unreferenced-variables/test/remove-unreferenced-variables.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ test('plugin-remove-unreferenced-variables: no transform: ternary', (t) => {
5757
t.end();
5858
});
5959

60+
test('plugin-remove-unreferenced-variables: no report: assignment', (t) => {
61+
t.noReport('assignment');
62+
t.end();
63+
});
64+
6065
test('plugin-remove-unreferenced-variables: transform: merge-variables', (t) => {
6166
t.transform('merge-variables', {
6267
'minify/merge-variables': mergeVariables,

0 commit comments

Comments
 (0)