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

Make local classnames global #97

Closed
wants to merge 1 commit into from
Closed

Make local classnames global #97

wants to merge 1 commit into from

Conversation

mxstbr
Copy link
Contributor

@mxstbr mxstbr commented Jul 22, 2016

This is the only way I've found to "disable" the :local(.class) notation.

It disables it in the sense that the generated classname will just be "class" – it doesn't keep users from doing the webpack-specific thing though:

import styles from './styles.css';

<div className={styles.class} />

That means it'll still break users builds if they for some reason rely on the above and we change to a different bundler.

Closes #90

@ghost ghost added the CLA Signed label Jul 22, 2016
@vjeux
Copy link
Contributor

vjeux commented Jul 22, 2016

Can you add a comment above explaining why you need this incantation, otherwise it'll be confusing when looking at this line in a few months

@mxstbr
Copy link
Contributor Author

mxstbr commented Jul 22, 2016

Wait @vjeux, following the discussion in #90 I'm not 100% sure we want to merge this. I'll add the comment for now though.

@gaearon
Copy link
Contributor

gaearon commented Jul 22, 2016

Man, I know what we should do!

import styles from './styles.css';

Write a custom lint rule against importing anything from .css file. This defeats the purpose of using CSS modules and protects us.

import styles from './styles.css'; // should trigger our lint rule
import './styles.css'; // should be fine

@mxstbr
Copy link
Contributor Author

mxstbr commented Jul 22, 2016

That actually sounds very reasonable! (also, that "Aha!" moment 👍)

@ghost ghost added the CLA Signed label Jul 22, 2016
@gaearon
Copy link
Contributor

gaearon commented Jul 22, 2016

Let’s close this then. Would you like to write that rule?

@gaearon gaearon closed this Jul 22, 2016
@gaearon gaearon deleted the local-classnames branch July 22, 2016 20:13
@mxstbr
Copy link
Contributor Author

mxstbr commented Jul 22, 2016

I've never written a rule and don't have the time to dig into that at the moment, so I'd rather somebody from the community does that!

grengojbo pushed a commit to grengojbo/es6-react-scripts that referenced this pull request Jun 6, 2018
Fix Jest snapshot CSS Module class names, add CSS Module class name template as a configuration option. Closes facebook#106 and facebook#97.
@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants