Skip to content

Commit a778dcc

Browse files
committed
Add Stylelint
And fix up CSS where it caught problems. CSS is still a mess, though
1 parent e7b7206 commit a778dcc

8 files changed

Lines changed: 753 additions & 1 deletion

File tree

.stylelintrc.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"extends": ["stylelint-config-standard"],
3+
"plugins": ["stylelint-value-no-unknown-custom-properties"],
4+
"customSyntax": "postcss-html",
5+
"rules": {
6+
"csstools/value-no-unknown-custom-properties": [
7+
true,
8+
{
9+
"importFrom": ["src/app.css"]
10+
}
11+
],
12+
"custom-property-pattern": "^(color|spacing|font)-.+",
13+
"declaration-block-no-duplicate-custom-properties": true,
14+
"selector-class-pattern": null,
15+
"no-descending-specificity": null,
16+
"color-hex-length": null,
17+
"color-function-notation": null,
18+
"alpha-value-notation": null,
19+
"value-keyword-case": null,
20+
"property-no-vendor-prefix": null,
21+
"selector-pseudo-element-colon-notation": null,
22+
"font-family-no-duplicate-names": null,
23+
"declaration-property-value-keyword-no-deprecated": null,
24+
"declaration-block-no-redundant-longhand-properties": null,
25+
"comment-empty-line-before": null,
26+
"color-function-alias-notation": null,
27+
"keyframes-name-pattern": null,
28+
"rule-empty-line-before": null,
29+
"comment-whitespace-inside": null,
30+
"selector-pseudo-class-no-unknown": [
31+
true,
32+
{
33+
"ignorePseudoClasses": ["global"]
34+
}
35+
],
36+
"shorthand-property-no-redundant-values": null
37+
},
38+
"ignoreFiles": ["dist/**", "build/**", ".svelte-kit/**", "node_modules/**", "src-tauri/target/**"]
39+
}

AGENTS.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ Can use also `./scripts/check.sh --rust`, `./scripts/check.sh --svelte`, `./scri
6464
or `./scripts/check.sh --help` to see all options.
6565

6666
Can also use `cargo fmt`, `cargo clippy`, `cargo audit`, `cargo deny check`, `cargo nextest run`, `pnpm format`,
67-
`pnpm lint --fix`, `pnpm test`, `pnpm test:e2e` as needed.
67+
`pnpm lint --fix`, `pnpm stylelint:fix`, `pnpm test`, `pnpm test:e2e` as needed.
68+
69+
**CSS health checks**: When writing CSS, ALWAYS use variables defined in `src/app.css`. Stylelint catches
70+
undefined/hallucinated CSS variables.
6871

6972
GitHub Actions workflow in `.github/workflows/ci.yml`:
7073

docs/tooling/css-health-checks.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# CSS health checks with Stylelint
2+
3+
We use Stylelint to validate CSS and catch common issues.
4+
5+
Checks for:
6+
7+
- Unused/hallucinated CSS variables
8+
- Variables to follow the pattern `--color-*`, `--spacing-*`, or `--font-*`.
9+
- CSS syntax errors
10+
- General CSS best practices
11+
12+
Run it by `pnpm stylelint:fix` or via `./scripts/check.sh`
13+
14+
## Config
15+
16+
Stylelint is configured in `.stylelintrc.json` with:
17+
18+
1. **`postcss-html` syntax** - Allows parsing `<style>` blocks in `.svelte` files
19+
2. **`stylelint-value-no-unknown-custom-properties` plugin** - The key plugin that validates CSS variables
20+
3. **`importFrom: ["src/app.css"]`** - Tells Stylelint which variables are actually defined

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"tauri": "node scripts/tauri-wrapper.js",
1313
"lint": "eslint .",
1414
"lint:fix": "eslint . --fix",
15+
"stylelint": "stylelint \"src/**/*.{css,svelte}\"",
16+
"stylelint:fix": "stylelint \"src/**/*.{css,svelte}\" --fix",
1517
"format": "prettier --write .",
1618
"format:check": "prettier --check .",
1719
"test": "vitest run",
@@ -45,8 +47,12 @@
4547
"globals": "^16.5.0",
4648
"jsdom": "^27.3.0",
4749
"knip": "^5.77.1",
50+
"postcss-html": "^1.8.0",
4851
"prettier": "^3.7.4",
4952
"prettier-plugin-svelte": "^3.4.1",
53+
"stylelint": "^16.26.1",
54+
"stylelint-config-standard": "^39.0.1",
55+
"stylelint-value-no-unknown-custom-properties": "^6.1.0",
5056
"svelte": "^5.46.1",
5157
"svelte-check": "^4.3.5",
5258
"svelte-eslint-parser": "^1.4.1",

0 commit comments

Comments
 (0)