Skip to content

stylelint --fix drops a trailing interpolation on its own line in a multi-line CSS value #1494

Description

@aki05162525

Environment

  • Linaria version: @linaria/postcss-linaria 6.3.0 (also reproduces on 8.1.1, the latest)
  • Stylelint version: 17.14.1
  • PostCSS version: 8.5.23
  • Bundler (+ version): N/A (reproduces via stylelint CLI directly)
  • Node.js version: 24.16.0
  • OS: macOS

Description

When a CSS value spans multiple lines and the last argument is an interpolated expression (${...}) alone on its own line, stylelint --fix (with customSyntax: '@linaria/postcss-linaria') silently drops it — no error, the line just becomes empty.

This reproduces with zero rules configured, so the corruption occurs during the @linaria/postcss-linaria parse/stringify round trip invoked by --fix, rather than in a specific Stylelint rule fixer.

Likely cause: createPlaceholder classifies an interpolation on an expression-only line as a rule set because isRuleSet finds no colon, opening brace, or comma on that line. It therefore emits a comment placeholder (/* pcss_lin:1 */) instead of a value placeholder (pcss_lin1).

PostCSS omits that comment from Declaration#value, and locationCorrectionWalker stores the resulting comment-free value in raws.linariaValue. By the time the custom stringifier runs, the placeholder is no longer present and the interpolation cannot be restored.

Reproducible Demo

.stylelintrc.mjs:

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

sample.style.ts:

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

const color = 'gray';
const transparentColor = 'transparent';

export const style = css`
    .foo {
        background: linear-gradient(
            0deg,
            ${color} 20%,
            ${transparentColor}
        )
    }
`;
stylelint --config .stylelintrc.mjs --fix sample.style.ts

${transparentColor} is removed, leaving:

background: linear-gradient(
    0deg,
    ${color} 20%,

)

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