Skip to content

Commit 9a0cd68

Browse files
committed
feature: @putout/plugin-variables: apply-declarations-order: both identifiers
1 parent b449043 commit 9a0cd68

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/plugin-variables/lib/apply-declarations-order/fixture/identifier.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ if (parentPath.isExportDeclaration())
44
return;
55

66
const init = node;
7+
8+
const fn = stub();
9+
const x = stub();

packages/plugin-variables/lib/apply-declarations-order/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@ export const traverse = ({push}) => ({
3434
const prev = path.getAllPrevSiblings();
3535

3636
for (const current of prev.filter(isVariableDeclaration)) {
37-
if (compare(__b, current.node.declarations[0].init))
37+
const {__c, __d} = getTemplateValues(current, 'const __c = __d');
38+
39+
if (isIdentifier(__c))
40+
continue;
41+
42+
if (compare(__b, __d))
3843
push({
3944
current,
4045
path,

0 commit comments

Comments
 (0)