Skip to content

Commit 3463a2c

Browse files
brenocota-hotmartBreno Cota
and
Breno Cota
authored
feat(no-node-access): report childElementCount prop (#650)
feat: add childElementCount prop Co-authored-by: Breno Cota <[email protected]>
1 parent fc6ccf8 commit 3463a2c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/utils/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ const TESTING_FRAMEWORK_SETUP_HOOKS = ['beforeEach', 'beforeAll'];
8383
const PROPERTIES_RETURNING_NODES = [
8484
'activeElement',
8585
'children',
86+
'childElementCount',
8687
'firstChild',
8788
'firstElementChild',
8889
'fullscreenElement',

tests/lib/rules/no-node-access.test.ts

+17
Original file line numberDiff line numberDiff line change
@@ -324,5 +324,22 @@ ruleTester.run(RULE_NAME, rule, {
324324
},
325325
],
326326
},
327+
{
328+
code: `
329+
import { render } from '${testingFramework}';
330+
331+
const { container } = render(<ul><li>item</li><li>item</li></ul>)
332+
333+
expect(container.childElementCount).toBe(2)
334+
`,
335+
errors: [
336+
{
337+
// error points to `childElementCount`
338+
line: 6,
339+
column: 26,
340+
messageId: 'noNodeAccess',
341+
},
342+
],
343+
},
327344
]),
328345
});

0 commit comments

Comments
 (0)