Environment
@linaria/postcss-linaria: 8.1.1
- Stylelint: 17.14.1
- PostCSS: 8.5.23
- Node.js: 24.16.0
- OS: macOS
Description
Running stylelint --fix with customSyntax: '@linaria/postcss-linaria' doubles
existing backslashes inside Linaria CSS templates.
For example:
- content: '\u2022';
+ content: '\\u2022';
This reproduces with zero Stylelint rules configured, so the corruption occurs during
the @linaria/postcss-linaria parse/stringify round trip rather than in a rule fixer.
The change is also non-idempotent. Each subsequent run doubles the backslashes again:
\u2022 → \\u2022 → \\\\u2022
Reproduction
.stylelintrc.mjs:
export default {
customSyntax: '@linaria/postcss-linaria',
rules: {},
};
sample.style.ts:
import { css } from '@linaria/core';
export const style = css`
.foo {
&:before {
content: '\u2022';
color: red;
}
}
`;
Run:
stylelint --config .stylelintrc.mjs --fix sample.style.ts
Expected:
Actual:
Running the same command again changes it to:
Likely cause
LinariaStringifier unconditionally doubles backslashes for every non-root node:
builder(str.replace(/\\/g, '\\\\').replace(/`/g, '\\`'), node, type);
This also runs on unchanged declaration values, so existing backslashes are escaped
again each time the file is stringified.
Environment
@linaria/postcss-linaria: 8.1.1Description
Running
stylelint --fixwithcustomSyntax: '@linaria/postcss-linaria'doublesexisting backslashes inside Linaria CSS templates.
For example:
This reproduces with zero Stylelint rules configured, so the corruption occurs during
the
@linaria/postcss-linariaparse/stringify round trip rather than in a rule fixer.The change is also non-idempotent. Each subsequent run doubles the backslashes again:
Reproduction
.stylelintrc.mjs:sample.style.ts:Run:
Expected:
Actual:
Running the same command again changes it to:
Likely cause
LinariaStringifierunconditionally doubles backslashes for every non-root node:This also runs on unchanged declaration values, so existing backslashes are escaped
again each time the file is stringified.