Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False negative with :not #48

Open
amannn opened this issue Oct 15, 2018 · 1 comment · May be fixed by #81
Open

False negative with :not #48

amannn opened this issue Oct 15, 2018 · 1 comment · May be fixed by #81
Labels

Comments

@amannn
Copy link
Contributor

amannn commented Oct 15, 2018

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)
@Cellule Cellule linked a pull request Aug 31, 2023 that will close this issue
@yuhsianw
Copy link
Collaborator

yuhsianw commented Sep 14, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants