Skip to content

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

Open

Description

@clintandrewhall

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.

Activity

  1. DaveSauce commented on Sep 19, 2024

    @DaveSauce

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

    export { css as csa } from '@linaria/core';
  2. clintandrewhall commented on Sep 20, 2024

    @clintandrewhall
    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.

  3. espretto commented on Mar 26, 2025

    @espretto

    This is a possible duplicate of #1430. Have you tried the tagResolver option documented here?

  4. espretto commented on Nov 19, 2025

    @espretto

    This is a possible duplicate of #1430. Have you tried the tagResolver option documented here?

    Did this solve your issue? @clintandrewhall

  5. clintandrewhall commented on Nov 19, 2025

    @clintandrewhall
    Author

    @espretto Thanks for the ping! I'm doing this already, but that doesn't appear to have any effect on the postcss-linaria plugin...?

  6. clintandrewhall commented on Nov 19, 2025

    @clintandrewhall
    Author

    This is a possible duplicate of #1430.

    Unfortunately, it is not. I don't have a problem re-exporting it. I'm having a problem with how the style is being checked/validated with postcss-linaria: it's hardcoded to look for css and styled.

    I readily admit this is an edge case. And due to another bug in the stylelint impl, regarding corruption of styles with autofix, I recently removed stylelint entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions