Skip to content

Commit 212fd97

Browse files
[DO NOT MERGE until #3632] Re-add SCSS stylelint hook via project toolchain (DOCS-81) (#3633)
> [!NOTE] > **Draft, stacked on #3632.** Merge order: **#3632 (unblock) → this**. Until #3632 merges, its removal commit appears in this diff; afterward the diff collapses to this PR's change. Please review the CI-workflow change below — its behavior is proven by this PR's own `pre-commit` run. The proper fix for the broken SCSS lint hook (DOCS-81), following #3632's temporary removal. ## Approach The isolated-node-env hook couldn't resolve `stylelint-config-standard-scss` in CI because stylelint resolves `extends` from the **config file's directory** (repo root), not the hook's environment. This runs the **project's own stylelint** instead: - **`.pre-commit-config.yaml`** — stylelint hook is now `language: system`, `entry: node_modules/.bin/stylelint`. It resolves the shared config from the repo's `node_modules`. - **`.github/workflows/pre-commit.yaml`** — adds a `setup-node` + `npm ci --ignore-scripts` step so `node_modules` exists in CI. `--ignore-scripts` skips the theme's postinstall (for example the Hugo download), which linting doesn't need. Unlike the eslint/markdownlint hooks (pre-commit-managed environments), the SCSS hook needs Node in CI and `npm install` locally. SCSS editors already run `npm install`; a docs-only contributor never triggers the hook (it's scoped to `assets/scss/`). ## Verification (local) - `pre-commit run stylelint` passes on a clean SCSS file and **fails on a file with a finding** (`color-hex-length`), resolving the config correctly. - `actionlint` and `zizmor` pass on the modified workflow (matched the repo's `cache`-less `setup-node` + zizmor ignore convention). - YAML valid. The CI `npm ci` path can only be fully exercised on the runner — this PR's own `pre-commit` check is that proof. ## Sequencing Merge order for the chain: **#3632 → this → then #3631** (the contributor-docs PR, whose docs describe stylelint as an active check). After #3632 merges I'll rebase this onto `main`. Fixes DOCS-81. --- Created in collaboration with Claude Code running Opus 4.8 on 2026-07-23. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5098497 commit 212fd97

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

.github/workflows/pre-commit.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,19 @@ jobs:
5858
restore-keys: |
5959
pre-commit-
6060
61+
# The SCSS stylelint hook runs the project's own stylelint
62+
# (node_modules/.bin/stylelint) so its shared config, stylelint-config-
63+
# standard-scss, resolves from the repo's node_modules. Install just that:
64+
# --ignore-scripts skips the theme's postinstall (for example the Hugo
65+
# download), which the lint hook does not need.
66+
- name: Set up Node.js
67+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
68+
# zizmor: ignore[cache-poisoning] - no cache input is set, so setup-node creates no cache to poison
69+
with:
70+
node-version: 22
71+
- name: Install Node dependencies for the stylelint hook
72+
run: npm ci --ignore-scripts
73+
6174
# DO NOT REMOVE: this makes the PR base sha reachable in the shallow
6275
# clone. Without it the --from-ref/--to-ref range below fails with
6376
# "fatal: Invalid revision range". If you want to drop this step, you must

.pre-commit-config.yaml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,18 @@ repos:
142142
# any local fix would lose on the next sync, so it is not linted here.
143143
exclude: ^content/platform/chainctl/chainctl-docs/
144144

145-
# SCSS/stylelint linting is temporarily not wired here. The previous repo-local
146-
# node hook could not resolve the shared `extends`
147-
# (stylelint-config-standard-scss) in CI: stylelint resolves `extends` from the
148-
# config file's directory (repo root), not from the hook's isolated node
149-
# environment, and the pre-commit CI has no repo-root node_modules. That made
150-
# every PR touching assets/scss fail the required check. It will be re-added to
151-
# run against the project's own toolchain, with a Node/npm step in the
152-
# pre-commit CI job. Tracking: DOCS-81.
145+
# Lint SCSS against .stylelintrc.json using the project's own stylelint
146+
# (node_modules/.bin/stylelint), not a pre-commit-managed environment. stylelint
147+
# resolves its shared `extends` (stylelint-config-standard-scss) from the repo's
148+
# node_modules, so the toolchain must be installed: `npm install` locally and
149+
# `npm ci` in CI (see .github/workflows/pre-commit.yaml). --allow-empty-input
150+
# keeps the hook green when a commit touches only files excluded by
151+
# .stylelintignore.
152+
- repo: local
153+
hooks:
154+
- id: stylelint
155+
name: stylelint (SCSS)
156+
entry: node_modules/.bin/stylelint
157+
language: system
158+
args: ['--allow-empty-input']
159+
files: ^assets/scss/.*\.(css|scss|sass)$

0 commit comments

Comments
 (0)