Skip to content

Commit 0205374

Browse files
author
Mateus Felix
committed
refactor(no-container): add conditional
for containerIndex | clean up method declaration
1 parent 5d02426 commit 0205374

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

lib/rules/no-container.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,17 @@ export default ESLintUtils.RuleCreator(getDocsUrl)({
4242
isIdentifier(property.key) &&
4343
property.key.name === 'container'
4444
);
45-
const nodeValue = node.id.properties[containerIndex].value;
46-
destructuredContainerName =
47-
containerIndex !== -1 &&
48-
isIdentifier(nodeValue) &&
49-
nodeValue.name;
45+
if (containerIndex !== -1) {
46+
const nodeValue = node.id.properties[containerIndex].value;
47+
destructuredContainerName =
48+
isIdentifier(nodeValue) &&
49+
nodeValue.name;
50+
}
5051
}
5152
}
5253
},
5354

54-
[`CallExpression`](node: TSESTree.CallExpression) {
55+
CallExpression(node: TSESTree.CallExpression) {
5556
if (
5657
isMemberExpression(node.callee) &&
5758
isIdentifier(node.callee.object) &&

tests/lib/rules/no-container.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ruleTester.run(RULE_NAME, rule, {
3131
invalid: [
3232
{
3333
code: `
34-
const {container} = render(<Example />)
34+
const { container } = render(<Example />)
3535
const button = container.querySelector('.btn-primary')
3636
`,
3737
errors: [

0 commit comments

Comments
 (0)