Skip to content

Commit 9397a6e

Browse files
MrHensindresorhus
authored andcommitted
Add some more types to the blacklist in the prefer-node-append rule (#322)
1 parent d62666d commit 9397a6e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

rules/prefer-node-append.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ const getDocsUrl = require('./utils/get-docs-url');
44
const getMethodName = memberExpression => memberExpression.property.name;
55

66
const ignoredParentTypes = [
7+
'ArrayExpression',
78
'IfStatement',
89
'MemberExpression',
10+
'Property',
11+
'ReturnStatement',
912
'VariableDeclarator'
1013
];
1114

test/prefer-node-append.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,26 @@ ruleTester.run('prefer-node-append', rule, {
9898
code: 'if (node.appendChild(child)) {}',
9999
output: 'if (node.appendChild(child)) {}',
100100
errors: [error]
101+
},
102+
{
103+
code: 'const foo = [node.appendChild(child)]',
104+
output: 'const foo = [node.appendChild(child)]',
105+
errors: [error]
106+
},
107+
{
108+
code: 'const foo = { bar: node.appendChild(child) }',
109+
output: 'const foo = { bar: node.appendChild(child) }',
110+
errors: [error]
111+
},
112+
{
113+
code: 'function foo() { return node.appendChild(child); }',
114+
output: 'function foo() { return node.appendChild(child); }',
115+
errors: [error]
116+
},
117+
{
118+
code: 'const foo = () => { return node.appendChild(child); }',
119+
output: 'const foo = () => { return node.appendChild(child); }',
120+
errors: [error]
101121
}
102122
]
103123
});

0 commit comments

Comments
 (0)