Repository navigation
Expand file tree
/
Copy pathstylelint.config.mjs
More file actions
54 lines (53 loc) · 2.45 KB
/
Copy pathstylelint.config.mjs
File metadata and controls
54 lines (53 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// =============================================================================
// stylelint.config.mjs — the consumer-facing contract
// =============================================================================
//
// Exported as `@stylescape/stylescape-devcontainer/stylelint` so a consumer
// can extend it and have the one rule that matters enforced in its own
// stylesheets: brand colour belongs in THIS package, referenced through
// `var(--ss-*)` or `var(--devcontainer-*)`. A hex in a consumer's SCSS is a
// value that will not follow a `data-theme="dark"` band, and on a dark band
// that means text that disappears.
//
// // stylelint.config.mjs
// import theme from "@stylescape/stylescape-devcontainer/stylelint";
// export default { ...theme, ignoreFiles: [...] };
//
// This package does NOT lint itself with this config, and cannot: its token
// files are made of the literals the rule forbids, which is exactly what a
// token file is for. `npm run lint` here is ESLint over the JavaScript.
// =============================================================================
export default {
rules: {
"color-no-hex": [
true,
{
message:
"Use a --ss-* or --devcontainer-* token instead of a " +
"literal colour (stylescape-devcontainer).",
},
],
"declaration-property-value-disallowed-list": {
// A fallback inside a `var()` is fine; a bare literal is not.
"/^(color|background-color|border-color)$/": [
"/^(rgb|hsl|oklch)\\(/",
"/^(red|blue|green|black|white)$/",
],
},
// Custom properties in consumer code namespace under the consumer's
// own prefix rather than colonise the design system's. This has to
// be `property-disallowed-list`, which checks DECLARATIONS only: the
// obvious `custom-property-pattern` also flags `var(--ss-*)`
// references (stylelint >= 17), and referencing the tokens is
// exactly what a consumer is supposed to do.
"property-disallowed-list": [
["/^--ss-/", "/^--devcontainer-/"],
{
message:
"--ss-* and --devcontainer-* are owned by " +
"stylescape-devcontainer; declare your own tokens under " +
"your own prefix (referencing them with var() is fine).",
},
],
},
};