eslint-plugin-css-modules icon indicating copy to clipboard operation
eslint-plugin-css-modules copied to clipboard

False negative with :not

Open amannn opened this issue 7 years ago • 1 comments

SCSS:

.root {
  &:not(.selected) {
    opacity: 0.5;
  }
}

JS:

<div className={cx(styles.root, styles.selected)} />

Result:

Class 'selected' not found (css-modules/no-undef-class)

amannn avatar Oct 15 '18 10:10 amannn

This is not a bug. In the example above, there're no selectors that target .selected in the SCSS file. :not(.selected) targets anything other then .selected so the error is semantically correct - .selected is undefined.

You should be able to avoid this error by using string literals for classes that aren't defined in the CSS module:

<div className={cx(styles.root, 'selected')} />

*syntax unchecked

yuhsianw avatar Sep 14 '23 04:09 yuhsianw