Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Latest commit

 

History

History
41 lines (27 loc) · 1.12 KB

File metadata and controls

41 lines (27 loc) · 1.12 KB

Trim whitespace inside the "className" JSX attribute (trim-class-names)

This rule enforces (and autofixes) that the class names inside the "className" attribute of a JSX element are not preceded or followed by whitespace.

Rule Details

Examples of incorrect code for this rule:

<div className="   foo bar"></div>
<div className="foo bar"></div>
<div className={'    foo bar    '}></div>

Examples of correct code for this rule:

<div className="foo bar"></div>
<div className="foo bar"></div>
<div className={'foo bar'}></div>

Limitations

Note that this only looks at string literals and template literals.

It does not currently check calls to the popular classnames NPM package:

// `classNames()` calls are not checked:
<div className={classNames('   foo   ', '   bar   ')}></div>

Related

Further Reading