Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS-code adding spaces between class name which contains hyphens

My VSCode is configured with prettier and ESLint settings to make the development easy.

But I am not sure which rule is affecting my JSX class names. Ideally, the class name should be: test-wrapper

 <i className={style.test-wrapper} />

But its getting changed to below on save and causing lot of issues:

 <i className={style.test - wrapper} />

May i know which rule i should override or modify?

like image 350
Mithun Shreevatsa Avatar asked Jul 16 '26 06:07

Mithun Shreevatsa


1 Answers

Using dot notation to access object property (style.test-wrapper) only works when the name of the property contains plain letters a-z, A-Z, digits 0-9 and special characters $ and _. Also, the name cannot start with a digit.

If you want to use character - in property name, you can use bracket notation:

<i className={style['test-wrapper']} />
like image 66
Vedran Maric Avatar answered Jul 18 '26 20:07

Vedran Maric