sindresorhus/eslint-plugin-unicorn

Rule proposal: Error when adding a class that begins with a dot`classList.add('.`

Closed

#1,837 opened on May 30, 2022

 (4 comments) (8 reactions) (0 assignees)JavaScript (468 forks)user submission
help wantednew rule

Repository metrics

Stars
 (5,022 stars)
PR merge metrics
 (Avg merge 1d 16h) (399 merged PRs in 30d)

Description

Description

Sometimes, we incorrectly try to add a class that begins with a dot, but linters and indeed browsers do not indicate that this is an error.

The error occurs because we use a dot in selectors for classname, but the dot is not part of the actual class name.

Fail

node.classList.add('.table-of-contents');

Pass

node.classList.add('table-of-contents')

Additional Info

No response

Contributor guide