Skip to content

Make local classnames global - #97

Closed
mxstbr wants to merge 1 commit into
masterfrom
local-classnames
Closed

Make local classnames global#97
mxstbr wants to merge 1 commit into
masterfrom
local-classnames

Conversation

@mxstbr

Copy link
Copy Markdown
Contributor

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:

importstylesfrom'./styles.css';<divclassName={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

@ghostghost added the CLA Signed label Jul 22, 2016
@mxstbrmxstbr mentioned this pull request Jul 22, 2016
@vjeux

Copy link
Copy Markdown
Contributor

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
Copy Markdown
ContributorAuthor

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

gaearon commented Jul 22, 2016

Copy link
Copy Markdown
Contributor

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.

importstylesfrom'./styles.css';// should trigger our lint ruleimport'./styles.css';// should be fine

@mxstbr

mxstbr commented Jul 22, 2016

Copy link
Copy Markdown
ContributorAuthor

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

@ghostghost added the CLA Signed label Jul 22, 2016
@gaearon

Copy link
Copy Markdown
Contributor

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

@gaearongaearon closed this Jul 22, 2016
@gaearon
gaearon deleted the local-classnames branch July 22, 2016 20:13
@mxstbr

Copy link
Copy Markdown
ContributorAuthor

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. Closesreact#106 and react#97.
@locklockBot locked and limited conversation to collaborators Jan 22, 2019
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@mxstbr@vjeux@gaearon