Skip to content

Commit

Permalink
feat(no-node-access): report childElementCount prop (#650)
Browse files Browse the repository at this point in the history
feat: add childElementCount prop

Co-authored-by: Breno Cota <brenogcota@gmail.com>
  • Loading branch information
brenocota-hotmart and Breno Cota committed Sep 23, 2022
1 parent fc6ccf8 commit 3463a2c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/utils/index.ts
Expand Up @@ -83,6 +83,7 @@ const TESTING_FRAMEWORK_SETUP_HOOKS = ['beforeEach', 'beforeAll'];
const PROPERTIES_RETURNING_NODES = [
'activeElement',
'children',
'childElementCount',
'firstChild',
'firstElementChild',
'fullscreenElement',
Expand Down
17 changes: 17 additions & 0 deletions tests/lib/rules/no-node-access.test.ts
Expand Up @@ -324,5 +324,22 @@ ruleTester.run(RULE_NAME, rule, {
},
],
},
{
code: `
import { render } from '${testingFramework}';
const { container } = render(<ul><li>item</li><li>item</li></ul>)
expect(container.childElementCount).toBe(2)
`,
errors: [
{
// error points to `childElementCount`
line: 6,
column: 26,
messageId: 'noNodeAccess',
},
],
},
]),
});

0 comments on commit 3463a2c

Please sign in to comment.