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%,
)
Environment
@linaria/postcss-linaria6.3.0 (also reproduces on 8.1.1, the latest)stylelintCLI directly)Description
When a CSS value spans multiple lines and the last argument is an interpolated expression (
${...}) alone on its own line,stylelint --fix(withcustomSyntax: '@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-linariaparse/stringify round trip invoked by--fix, rather than in a specific Stylelint rule fixer.Likely cause:
createPlaceholderclassifies an interpolation on an expression-only line as a rule set becauseisRuleSetfinds 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, andlocationCorrectionWalkerstores the resulting comment-free value inraws.linariaValue. By the time the custom stringifier runs, the placeholder is no longer present and the interpolation cannot be restored.Reproducible Demo
.stylelintrc.mjs:sample.style.ts:${transparentColor}is removed, leaving: