Skip to content

@linaria/postcss-linaria: stylelint --fix keeps adding whitespace before a trailing comment #1502

Description

@aki05162525

Environment

  • @linaria/postcss-linaria: 8.1.1
  • Stylelint: 17.14.1
  • PostCSS: 8.5.23
  • Node.js: 24.16.0
  • OS: macOS

Description

stylelint --fix inserts whitespace before a comment that trails a declaration on the same line. The amount added equals the indentation of the tagged template, and it is added again on every run:

color: red; /* c */  →  color: red;   /* c */  →  color: red;     /* c */

This reproduces with zero Stylelint rules configured, so the change happens during the parse/stringify round trip. A template that starts at column 0 is not affected.

Reproduction

.stylelintrc.mjs:

export default {
  customSyntax: '@linaria/postcss-linaria',
  rules: {},
};

sample.style.ts — the template is indented by 2:

import { css } from '@linaria/core';

export const style = {
  a: css`
    color: red; /* c */
  `,
};

Run:

stylelint --config .stylelintrc.mjs --fix sample.style.ts

Expected:

color: red; /* c */

Actual, two spaces added per run:

color: red;   /* c */

Activity

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

    bug report 🦗Issue is probably a bug, but it needs to be checkedneeds: complete repro 🖥️Issue need to have complete repro provided

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions