eslint-plugin-unicorn icon indicating copy to clipboard operation
eslint-plugin-unicorn copied to clipboard

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

Open universemaster opened this issue 3 years ago • 3 comments

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

universemaster avatar May 30 '22 11:05 universemaster

It should apply to the other classList methods too.

sindresorhus avatar May 30 '22 12:05 sindresorhus

Accepted

sindresorhus avatar Jun 05 '22 09:06 sindresorhus

Please suggest a rule name.

sindresorhus avatar Jun 05 '22 09:06 sindresorhus