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

[postcss-linaria] Allow for alias of css in config #1423

Open
clintandrewhall opened this issue Sep 13, 2024 · 2 comments
Open

[postcss-linaria] Allow for alias of css in config #1423

clintandrewhall opened this issue Sep 13, 2024 · 2 comments
Labels
cat: modules aliasing 🔗 Issue related to modules aliasing enhancement: proposal 💬 Improvement of current behaviour that needs to be discussed needs: triage 🏷 Issue needs to be checked and prioritized

Comments

@clintandrewhall
Copy link

Describe the enhancement

Supply the ability to declare aliases for css and styled when running stylelint analysis for projects that export those methods from linaria with a different name.

Motivation

I'm using atomic styles in a personal project. I recently added stylelint with property-disallowed-list to flag uses of margin and padding, (to prompt using margin-left instead, etc) and it wasn't working... at all.

After a day of digging, it turned out the reason was I had abstracted the use of linaria out to a local import. And since I was needing to apply global styles for a component library, to differentiate css from core and atomic, I had done the following:

// lib/css
export { css as csa, styled } from '@linaria/atomic';
export { css } from '@linaria/core';

and

// some/component.styles.ts

import { csa } from '@lib/css';
...
csa`{
  margin-left: 10px;
}`

Because postcss-linaria looks specifically for css and styled the string literals weren't being flagged.

Possible implementations

Allow the ability to configure the syntax with aliases to each named method:

alias: {
  css: 'csa',
  styled: 'linariaStyled',
}

Related Issues

None I could find.

@clintandrewhall clintandrewhall added the enhancement: proposal 💬 Improvement of current behaviour that needs to be discussed label Sep 13, 2024
@github-actions github-actions bot added cat: modules aliasing 🔗 Issue related to modules aliasing needs: triage 🏷 Issue needs to be checked and prioritized labels Sep 13, 2024
@DaveSauce
Copy link

Is there any reason this syntax won't work for you?

export { css as csa } from '@linaria/core';

@clintandrewhall
Copy link
Author

@DaveSauce That's literally what I did, and what surfaced the issue.

Because postcss-linaria looks specifically for css and styled the string literals weren't being flagged.

If the function is renamed, postcss-linaria doesn't see it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat: modules aliasing 🔗 Issue related to modules aliasing enhancement: proposal 💬 Improvement of current behaviour that needs to be discussed needs: triage 🏷 Issue needs to be checked and prioritized
Projects
None yet
Development

No branches or pull requests

2 participants