Files
discourse/stylelint.config.mjs
T
David Taylor 439efc7419 DEV: Introduce system for renaming CSS variables (#42733)
From time-to-time, variables may need to be renamed in core. To avoid
breaking existing themes and plugins, this commit introduces a system to
automatically rewrite old variable names to new ones. A list of renames
is maintained in `stylesheets/variable-renames.json`, and is applied
when CSS is compiled. This list also powers a stylelint rule which will
automatically rewrite old names to new names in source code.

Transformations apply to all core/theme/plugin code. For now, the
stylelint rule/autofix applies to core only, but this will be extracted
to `@discourse/lint-configs` in the near future.

When a transformation is applied, it adds a trailing `/* automatically
renamed --old to --new */` comment so that the behavior is
understandable from the browser developer tools.
2026-09-01 11:34:46 +01:00

41 lines
1.1 KiB
JavaScript

import noCoreVariables from "./stylelint-rules/no-core-variables.mjs";
import noRenamedVariables from "./stylelint-rules/no-renamed-variables.mjs";
import requireDesignTokens from "./stylelint-rules/require-design-tokens.mjs";
import ucClassesInWhere from "./stylelint-rules/uc-classes-in-where.mjs";
export default {
extends: ["@discourse/lint-configs/stylelint"],
plugins: [
noCoreVariables,
noRenamedVariables,
requireDesignTokens,
ucClassesInWhere,
],
rules: {
"media-feature-range-notation": "context",
"discourse/no-renamed-variables": true,
"discourse/uc-classes-in-where": true,
},
overrides: [
{
files: [
"**/sidebar.scss",
"**/sidebar-*.scss",
"**/*-sidebar.scss",
"**/*-sidebar-*.scss",
],
rules: {
"discourse/no-core-color-variables": true,
"discourse/require-design-tokens": true,
},
},
{
files: ["themes/horizon/scss/**"],
rules: {
"discourse/no-core-color-variables": null,
"discourse/require-design-tokens": null,
},
},
],
};