@nera-static/stan 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +153 -13
  3. package/canonical/editorconfig +12 -0
  4. package/canonical/github/FUNDING.yml +13 -0
  5. package/canonical/github/dependabot.yml +20 -0
  6. package/canonical/github/workflows/publish.yml +64 -0
  7. package/canonical/github/workflows/test.yml +37 -0
  8. package/canonical/husky/pre-push +1 -0
  9. package/canonical/variants/chokidar-major/github/dependabot.yml +25 -0
  10. package/canonical/variants/desktop-release/github/workflows/publish.yml +104 -0
  11. package/canonical/variants/dist-check/github/workflows/test.yml +43 -0
  12. package/canonical/variants/image-cache/github/workflows/publish.yml +73 -0
  13. package/canonical/variants/image-cache/github/workflows/test.yml +46 -0
  14. package/canonical/variants/validate-templates/github/workflows/publish.yml +64 -0
  15. package/canonical/variants/validate-templates/github/workflows/test.yml +40 -0
  16. package/canonical/variants/windows-smoke/github/workflows/test.yml +57 -0
  17. package/canonical/vitest.config.js +3 -0
  18. package/package.json +24 -12
  19. package/src/bem.js +35 -0
  20. package/src/checks/canonical.js +368 -0
  21. package/src/checks/css.js +131 -0
  22. package/src/checks/docs.js +405 -0
  23. package/src/checks/package.js +352 -0
  24. package/src/checks/pug.js +369 -0
  25. package/src/checks/tree.js +544 -0
  26. package/src/cli.js +49 -39
  27. package/src/eslint/check.js +64 -0
  28. package/src/eslint/config.js +45 -28
  29. package/src/eslint/files.js +37 -0
  30. package/src/markdown.js +60 -0
  31. package/src/repo-files.js +62 -1
  32. package/src/settings.js +136 -0
  33. package/src/stylelint/config.js +122 -0
  34. package/src/stylelint/index.js +15 -0
@@ -0,0 +1,73 @@
1
+ name: 📦 Publish to npm
2
+
3
+ # Publishes when a version tag is pushed:
4
+ # npm version <patch|minor|major> && git push --follow-tags
5
+ #
6
+ # Authentication is npm trusted publishing (OIDC). There is no token
7
+ # stored anywhere — GitHub mints a short-lived, workflow-scoped
8
+ # credential per run. This requires a matching Trusted Publisher entry
9
+ # in the package settings on npmjs.com, pointing at this repository and
10
+ # at this filename (publish.yml).
11
+
12
+ on:
13
+ push:
14
+ tags:
15
+ - 'v*'
16
+
17
+ permissions:
18
+ id-token: write # required for OIDC — without it, publish falls back to a token and fails
19
+ contents: read
20
+
21
+ jobs:
22
+ publish:
23
+ runs-on: ubuntu-latest
24
+
25
+ steps:
26
+ - name: Checkout repository
27
+ uses: actions/checkout@v7
28
+
29
+ # Node 24 ships npm 11.x. Trusted publishing needs npm >= 11.5.1.
30
+ # `registry-url` is deliberately NOT set: it writes an _authToken
31
+ # line into .npmrc which breaks OIDC when no NODE_AUTH_TOKEN is
32
+ # present (actions/setup-node#1551). npm defaults to the public
33
+ # registry regardless.
34
+ - name: Setup Node.js
35
+ uses: actions/setup-node@v7
36
+ with:
37
+ node-version: '24'
38
+
39
+ - name: Pin npm to a version that supports OIDC
40
+ run: npm install -g npm@latest
41
+
42
+ - name: Install dependencies
43
+ run: npm ci
44
+
45
+ # plugin-images' variants of the photographs: minutes
46
+ # cold, about a second warm (the key of test.yml).
47
+ - name: Cache {{any}}
48
+ uses: actions/cache@v6
49
+ with:
50
+ path: {{any}}.nera-cache
51
+ key: nera-cache-${{ hashFiles({{any}}) }}
52
+ restore-keys: nera-cache-
53
+
54
+ - name: Run tests
55
+ run: npx vitest run
56
+
57
+ - name: Lint
58
+ run: npm run lint
59
+
60
+ # Guards against tagging v1.3.0 while package.json still says
61
+ # 1.2.0 — npm would happily publish the wrong version.
62
+ - name: Verify tag matches package.json version
63
+ run: |
64
+ TAG="${GITHUB_REF_NAME#v}"
65
+ PKG="$(node -p "require('./package.json').version")"
66
+ if [ "$TAG" != "$PKG" ]; then
67
+ echo "::error::Tag $GITHUB_REF_NAME does not match package.json version $PKG"
68
+ exit 1
69
+ fi
70
+ echo "Tag and package.json agree on $PKG"
71
+
72
+ - name: Publish
73
+ run: npm publish
@@ -0,0 +1,46 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [main, master]
6
+ pull_request:
7
+ branches: [main, master]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ # Node 20 reached end of life on 2026-04-30, and the dev
17
+ # toolchain (vitest 5) needs Node 22.12 or later, so CI tests
18
+ # 22 and 24. `engines` declares `>=22.12.0` to match.
19
+ node-version: [22, 24]
20
+
21
+ steps:
22
+ - uses: actions/checkout@v7
23
+
24
+ - name: Use Node.js ${{ matrix.node-version }}
25
+ uses: actions/setup-node@v7
26
+ with:
27
+ node-version: ${{ matrix.node-version }}
28
+ cache: 'npm'
29
+
30
+ - name: Install dependencies
31
+ run: npm ci
32
+
33
+ - name: Run linter
34
+ run: npm run lint
35
+
36
+ # plugin-images' variants of the photographs: a minute
37
+ # and a half cold, about a second warm.
38
+ - name: Cache {{any}}
39
+ uses: actions/cache@v6
40
+ with:
41
+ path: {{any}}.nera-cache
42
+ key: nera-cache-${{ hashFiles({{any}}) }}
43
+ restore-keys: nera-cache-
44
+
45
+ - name: Run tests
46
+ run: npx vitest run
@@ -0,0 +1,64 @@
1
+ name: 📦 Publish to npm
2
+
3
+ # Publishes when a version tag is pushed:
4
+ # npm version <patch|minor|major> && git push --follow-tags
5
+ #
6
+ # Authentication is npm trusted publishing (OIDC). There is no token
7
+ # stored anywhere — GitHub mints a short-lived, workflow-scoped
8
+ # credential per run. This requires a matching Trusted Publisher entry
9
+ # in the package settings on npmjs.com, pointing at this repository and
10
+ # at this filename (publish.yml).
11
+
12
+ on:
13
+ push:
14
+ tags:
15
+ - 'v*'
16
+
17
+ permissions:
18
+ id-token: write # required for OIDC — without it, publish falls back to a token and fails
19
+ contents: read
20
+
21
+ jobs:
22
+ publish:
23
+ runs-on: ubuntu-latest
24
+
25
+ steps:
26
+ - name: Checkout repository
27
+ uses: actions/checkout@v7
28
+
29
+ # Node 24 ships npm 11.x. Trusted publishing needs npm >= 11.5.1.
30
+ # `registry-url` is deliberately NOT set: it writes an _authToken
31
+ # line into .npmrc which breaks OIDC when no NODE_AUTH_TOKEN is
32
+ # present (actions/setup-node#1551). npm defaults to the public
33
+ # registry regardless.
34
+ - name: Setup Node.js
35
+ uses: actions/setup-node@v7
36
+ with:
37
+ node-version: '24'
38
+
39
+ - name: Pin npm to a version that supports OIDC
40
+ run: npm install -g npm@latest
41
+
42
+ - name: Install dependencies
43
+ run: npm ci
44
+
45
+ # A theme is declarative — the meaningful gate is that every Pug
46
+ # template still compiles (Pug resolves include/extends at compile
47
+ # time, so a broken partial fails here, not in a consumer's build).
48
+ - name: Validate templates
49
+ run: npm run validate
50
+
51
+ # Guards against tagging v0.2.0 while package.json still says
52
+ # 0.1.0 — npm would happily publish the wrong version.
53
+ - name: Verify tag matches package.json version
54
+ run: |
55
+ TAG="${GITHUB_REF_NAME#v}"
56
+ PKG="$(node -p "require('./package.json').version")"
57
+ if [ "$TAG" != "$PKG" ]; then
58
+ echo "::error::Tag $GITHUB_REF_NAME does not match package.json version $PKG"
59
+ exit 1
60
+ fi
61
+ echo "Tag and package.json agree on $PKG"
62
+
63
+ - name: Publish
64
+ run: npm publish
@@ -0,0 +1,40 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [main, master]
6
+ pull_request:
7
+ branches: [main, master]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ # Node 20 reached end of life on 2026-04-30, and the dev
17
+ # toolchain (vitest 5) needs Node 22.12 or later, so CI tests
18
+ # 22 and 24. `engines` is unchanged: a CI-only change.
19
+ node-version: [22, 24]
20
+
21
+ steps:
22
+ - uses: actions/checkout@v7
23
+
24
+ - name: Use Node.js ${{ matrix.node-version }}
25
+ uses: actions/setup-node@v7
26
+ with:
27
+ node-version: ${{ matrix.node-version }}
28
+ cache: 'npm'
29
+
30
+ - name: Install dependencies
31
+ run: npm ci
32
+
33
+ # A theme is declarative, so there is no unit-test suite here. The
34
+ # equivalent gate is compiling every Pug template: `extends` and
35
+ # `include` resolve at compile time, so a renamed or missing partial
36
+ # fails here rather than in a consumer's build. publish.yml runs the
37
+ # same check, but only on a v* tag — this brings it to every push
38
+ # and pull request, so Dependabot PRs get a real signal too.
39
+ - name: Validate templates
40
+ run: npm run validate
@@ -0,0 +1,57 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [main, master]
6
+ pull_request:
7
+ branches: [main, master]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ # The `engines` floor is >=22.12.0, so CI tests the two
17
+ # supported lines, 22 and 24.
18
+ node-version: [22, 24]
19
+
20
+ steps:
21
+ - uses: actions/checkout@v7
22
+
23
+ - name: Use Node.js ${{ matrix.node-version }}
24
+ uses: actions/setup-node@v7
25
+ with:
26
+ node-version: ${{ matrix.node-version }}
27
+ cache: 'npm'
28
+
29
+ - name: Install dependencies
30
+ run: npm ci
31
+
32
+ - name: Run linter
33
+ run: npm run lint
34
+
35
+ - name: Run tests
36
+ run: npx vitest run
37
+
38
+ # The Claude Desktop extension on Windows: builds the .mcpb, unpacks it and
39
+ # drives its server over stdio on the bundled runtime (create_site with a
40
+ # real npm install through the shims, preview, stop). Needs the network.
41
+ windows:
42
+ runs-on: windows-latest
43
+
44
+ steps:
45
+ - uses: actions/checkout@v7
46
+
47
+ - name: Use Node.js 22
48
+ uses: actions/setup-node@v7
49
+ with:
50
+ node-version: 22
51
+ cache: 'npm'
52
+
53
+ - name: Install dependencies
54
+ run: npm ci
55
+
56
+ - name: Smoke-test the Desktop extension
57
+ run: node scripts/smoke-mcpb.js
@@ -0,0 +1,3 @@
1
+ import { neraConfig } from '@nera-static/test-utils/vitest'
2
+
3
+ export default neraConfig()
package/package.json CHANGED
@@ -1,31 +1,37 @@
1
1
  {
2
2
  "name": "@nera-static/stan",
3
- "version": "1.0.0",
4
- "description": "The handwriting check of a Nera repo: ESLint with the Nera rules, one report format, one exit code.",
3
+ "version": "1.1.0",
4
+ "description": "The handwriting check of a Nera repo: code with the Nera rules, CSS, Pug and structure, one report format, one exit code.",
5
5
  "type": "module",
6
+ "exports": {
7
+ ".": "./src/index.js",
8
+ "./stylelint": "./src/stylelint/index.js"
9
+ },
6
10
  "bin": {
7
11
  "nera-stan": "bin/nera-stan.js"
8
12
  },
9
- "exports": {
10
- ".": "./src/index.js"
13
+ "scripts": {
14
+ "lint": "node bin/nera-stan.js",
15
+ "test": "vitest run",
16
+ "test:watch": "vitest",
17
+ "prepare": "husky"
11
18
  },
12
19
  "files": [
13
20
  "bin",
21
+ "canonical",
14
22
  "src",
15
23
  "CHANGELOG.md"
16
24
  ],
17
- "scripts": {
18
- "lint": "node bin/nera-stan.js",
19
- "test": "vitest",
20
- "prepare": "husky"
21
- },
22
25
  "keywords": [
23
26
  "nera",
24
27
  "eslint",
25
28
  "eslint-config",
26
29
  "eslintplugin",
27
30
  "lint",
28
- "style"
31
+ "pug",
32
+ "style",
33
+ "stylelint",
34
+ "stylelint-config"
29
35
  ],
30
36
  "author": "Michael Becker",
31
37
  "license": "MIT",
@@ -40,21 +46,27 @@
40
46
  "publishConfig": {
41
47
  "access": "public"
42
48
  },
49
+ "sideEffects": false,
43
50
  "engines": {
44
51
  "node": "^22.13.0 || >=24"
45
52
  },
46
- "sideEffects": false,
47
53
  "dependencies": {
48
54
  "@eslint-community/eslint-plugin-eslint-comments": "^4.8.1",
49
55
  "@eslint/js": "^10.0.1",
50
56
  "@nera-static/plugin-utils": "^1.8.0",
51
57
  "@stylistic/eslint-plugin": "^6.0.1",
58
+ "@stylistic/stylelint-plugin": "^5.3.1",
52
59
  "eslint": "^10.16.0",
53
60
  "eslint-plugin-n": "^18.6.0",
54
61
  "espree": "^11.2.0",
55
- "globals": "^17.14.0"
62
+ "globals": "^17.14.0",
63
+ "pug-lexer": "^5.0.1",
64
+ "pug-parser": "^6.0.0",
65
+ "stylelint": "^17.16.0",
66
+ "stylelint-config-standard": "^40.0.0"
56
67
  },
57
68
  "devDependencies": {
69
+ "@nera-static/test-utils": "^1.0.1",
58
70
  "husky": "^9.1.7",
59
71
  "vitest": "^5.1.2"
60
72
  }
package/src/bem.js ADDED
@@ -0,0 +1,35 @@
1
+ /** One lower-case word, as BEM names are written in this fleet. */
2
+ const WORD = '[a-z0-9]+'
3
+ const NAME = `[a-z][a-z0-9]*(?:-${WORD})*`
4
+ const PART = `${WORD}(?:-${WORD})*`
5
+
6
+ /**
7
+ * A BEM class name (D5): `block(-word)*`, then an optional `__element(-word)*`, then an
8
+ * optional `--modifier(-word)*`, all lower case, e.g. `tag-cloud__item--active`. Used by
9
+ * stylelint's `selector-class-pattern` and by `pug/class-pattern`.
10
+ */
11
+ export const BEM_CLASS = new RegExp(`^${NAME}(?:__${PART})?(?:--${PART})?$`)
12
+
13
+ /** How a BEM class is written, for the messages that reject one. */
14
+ export const BEM_HINT = 'block__element--modifier in lower case, words joined by "-" (e.g. "tag-cloud__item--active")'
15
+
16
+ /**
17
+ * Whether `name` is a BEM class name.
18
+ *
19
+ * @param {string} name - A class name without the leading `.`.
20
+ * @returns {boolean}
21
+ */
22
+ export function isBemClass(name) {
23
+ return BEM_CLASS.test(name)
24
+ }
25
+
26
+ /**
27
+ * The classes highlight.js writes into its output: `hljs-<scope>` (with `_` inside, as
28
+ * `hljs-built_in`) and its sub-scope classes, a word followed by `_` (`class_`, `function_`,
29
+ * `inherited__`). They are highlight.js's names, not this fleet's, so CSS that styles
30
+ * highlighted code may use them.
31
+ */
32
+ export const HIGHLIGHT_JS_CLASS = /^(?:hljs-[a-z0-9_-]+|[a-z]+_+)$/
33
+
34
+ /** A class name nera-stan accepts: BEM, or one of highlight.js's. */
35
+ export const CLASS_NAME = new RegExp(`(?:${BEM_CLASS.source})|(?:${HIGHLIGHT_JS_CLASS.source})`)