sindresorhus/eslint-plugin-unicorn

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

Chiusa

#1837 aperta il 30 mag 2022

 (4 commenti) (8 reazioni) (0 assegnatari)JavaScript (468 fork)user submission
help wantednew rule

Metriche repository

Star
 (5022 stelle)
Metriche merge PR
 (Merge medio 4h 30m) (26 PR mergiate in 30 g)

Descrizione

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

Guida contributor