@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
package/CHANGELOG.md CHANGED
@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.1.0] - 2026-11-28
9
+
10
+ ### Added
11
+
12
+ - A CSS check: stylelint with one shipped configuration (`stylelint-config-standard`, `@stylistic` with indent 4 and single quotes, a BEM `selector-class-pattern` that also allows highlight.js's classes, and a `custom-property-pattern` for `--theme-*`, a plugin's `--nera-<name>-*` and a theme's own prefix). Eight rules of taste or of doubtful results are switched off. Rule ids carry the `css/` prefix, plus `css/parse-error`, `css/needless-disable` and `css/descriptionless-disable`. `--fix` applies stylelint's fixes.
13
+ - A Pug check: `pug/syntax` (every template lexes and parses, without following includes), `pug/indent`, `pug/no-tabs`, `pug/quotes` and `pug/class-pattern`. `--fix` re-indents a template indented by 2 spaces per level to 4, moving text blocks, filters, comments and code blocks as a whole so the whitespace inside them stays; a file with tabs, another indentation width, or a result that would not parse to the same tree is left alone.
14
+ - Structure checks per repo kind: `structure/package-key-order` (with `private` right after `version`), `structure/engines`, `structure/plugin-utils-range`, `structure/changelog-in-files`, `structure/npm-pkg-fix`, `structure/plugin-tree`, `structure/theme-tree`, `structure/starter-tree`, `structure/readme-badges`, `structure/readme-outline`, `structure/changelog-format`, `structure/license`, `structure/canonical-file`, `structure/test-scripts` and `structure/test-layout`. `--fix` reorders `package.json`, adds `CHANGELOG.md` to `files`, writes the `npm pkg fix` forms, the test scripts and a missing or differing canonical file, and never writes through a symlink out of the repo. A theme README may carry the business themes' `## Business facts: \`app.business\`` section after Page types.
15
+ - The canonical files ship in the package under `canonical/`: `.editorconfig`, `vitest.config.js`, `.husky/pre-push`, `test.yml`, `publish.yml`, `dependabot.yml` and `FUNDING.yml`, plus the variants `image-cache`, `windows-smoke`, `dist-check`, `validate-templates`, `desktop-release` and `chokidar-major`, whose open parts are written `{{any}}`.
16
+ - The exception keys `nera-stan.variants` (canonical file → variant name) and `nera-stan.skip` (rule id → reason) next to `nera-stan.ignores`. An unknown key, file, variant or rule id, or a skip without a reason, is exit code 2.
17
+ - The stylelint config for editors: `export { default } from '@nera-static/stan/stylelint'`.
18
+
19
+ ### Changed
20
+
21
+ - The checks run one after the other and their findings merge into the one report, sorted by file, line and column. A new rule fails a repo that already runs nera-stan; this ships as a minor because no repo but nera-stan itself depends on it yet.
22
+ - The README documents every rule family, the `nera-stan` keys with their allowed values, the canonical files and their variants.
23
+
24
+ ## [1.0.1] - 2026-11-27
25
+
26
+ ### Changed
27
+
28
+ - README: a section on moving an existing repo to nera-stan (the editor export replaces `eslint.config.js`, one `--fix` sweep followed by a second run, exceptions, the sweep as a commit of its own). First release through CI with npm trusted publishing.
29
+
8
30
  ## [1.0.0] - 2026-11-27
9
31
 
10
32
  ### Added
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Test](https://github.com/seebaermichi/nera-stan/actions/workflows/test.yml/badge.svg)](https://github.com/seebaermichi/nera-stan/actions/workflows/test.yml)
4
4
  [![npm version](https://img.shields.io/npm/v/@nera-static/stan)](https://www.npmjs.com/package/@nera-static/stan)
5
5
 
6
- The handwriting check of a [Nera](https://github.com/seebaermichi/nera) repo. `nera-stan` lints a plugin, theme, starter, the core, a tool or a site with one shipped ESLint configuration and the Nera rules. It reports every finding in one line format and ends with one exit code, so `npm run lint` fails in CI and in the `pre-push` hook on anything that breaks the fleet's style.
6
+ The handwriting check of a [Nera](https://github.com/seebaermichi/nera) repo. `nera-stan` checks a plugin, theme, starter, the core, a tool or a site: its code with one shipped ESLint configuration and the Nera rules, its CSS with one shipped stylelint configuration, its Pug templates, and its structure for the repo's kind. It reports every finding in one line format and ends with one exit code, so `npm run lint` fails in CI and in the `pre-push` hook on anything that breaks the fleet's style.
7
7
 
8
8
  📖 **Documentation:** [nera.js.org](https://nera.js.org), with the style guide at [nera.js.org/docs/style-guide/](https://nera.js.org/docs/style-guide/)
9
9
 
@@ -11,13 +11,14 @@ The handwriting check of a [Nera](https://github.com/seebaermichi/nera) repo. `n
11
11
 
12
12
  - One ESLint flat config for every Nera repo: `@eslint/js` recommended, the `globals` presets and the fleet's formatting through `@stylistic`
13
13
  - Eight Nera rules: no local copies of `@nera-static/plugin-utils` or `@nera-static/test-utils` helpers, the shared logger in plugin runtime code, the canonical hook shape, no "copied from" notes and no roadmap references in published files, and four test rules
14
+ - CSS through stylelint: `stylelint-config-standard`, the fleet's formatting through `@stylistic`, BEM class names and prefixed custom properties
15
+ - Pug: every template parses, 4-space indentation without tabs, single-quoted attributes and BEM class literals
16
+ - Structure per repo kind: the plugin, theme and starter trees, `package.json`, README, CHANGELOG and LICENSE, and the canonical files every repo shares (`test.yml`, `publish.yml`, `dependabot.yml`, `FUNDING.yml`, `.editorconfig`, the husky `pre-push` hook, `vitest.config.js`)
14
17
  - Detects the repo kind from `package.json`, and each rule applies only to the kinds and files it is meant for
15
18
  - One report line per finding, `<file>:<line> <rule> <message>`, where each message names what is wrong and what to do
16
19
  - `--fix` applies only the fixes that have one obviously correct result, and only inside the checked repo
17
- - Ships ESLint and every plugin it uses as its own dependencies, so a repo installs one package
18
- - Needs nothing but the checked repo: no network, no workspace and no sibling folder
19
-
20
- CSS, Pug and structure checks per repo kind are planned for a later release.
20
+ - Ships ESLint, stylelint, the Pug parser and every plugin they use as its own dependencies, so a repo installs one package
21
+ - Needs nothing but the checked repo: no network, no workspace and no sibling folder. The canonical files ship inside the package
21
22
 
22
23
  ## 🚀 Installation
23
24
 
@@ -37,6 +38,14 @@ Then point the repo's `lint` script at it:
37
38
 
38
39
  `npm run lint` now checks the whole repo. The fleet's husky hooks run it before every commit (`pre-commit`: `npm run lint`) and the tests before every push (`pre-push`: `npx vitest run`). `test.yml` and `publish.yml` run `npm run lint`, so CI refuses what fails.
39
40
 
41
+ ### Moving an existing repo to nera-stan
42
+
43
+ 1. Install it and point `lint` at it, as above.
44
+ 2. Replace the repo's `eslint.config.js` (and a `stylelint.config.js`, if it has one) with the editor exports (see [Editor integration](#editor-integration)) and remove the ESLint and stylelint packages from its own `devDependencies`: nera-stan brings them.
45
+ 3. Run `npx nera-stan --fix` once, then run `npx nera-stan` again. A fix can create a new finding: re-indenting a block can push a line past `max-len`.
46
+ 4. Fix what is left by hand. Generated or vendored files that are not Nera code go into `nera-stan.ignores`, a canonical file the repo deliberately differs in gets its variant under `nera-stan.variants`, and a rule the repo cannot follow goes under `nera-stan.skip` with its reason (see [Exceptions](#exceptions-the-nera-stan-key)); a single deliberate line gets an `eslint-disable-next-line <rule> -- <reason>` comment.
47
+ 5. Run the tests, then commit the sweep on its own, so the formatting changes stay apart from real ones.
48
+
40
49
  ## 🧩 Usage
41
50
 
42
51
  ```bash
@@ -63,7 +72,18 @@ index.js:12 nera/hook-shape `getAppData(data)` must destructure its argument wit
63
72
  test/build.test.js:4 nera/test-no-chdir `process.chdir` in a test moves the cwd of every test in the worker: …
64
73
  ```
65
74
 
66
- The file is relative to the checked repo, with `/` separators. The rule is an ESLint rule id (`nera/hook-shape`, `@stylistic/indent`, `no-var`, …), `parse-error` for a file ESLint cannot parse, or `eslint-directive` for an unused `eslint-disable` comment.
75
+ The file is relative to the checked repo, with `/` separators. The rule id tells which check reported it:
76
+
77
+ | Rule id | Check |
78
+ |---|---|
79
+ | `nera/*`, `@stylistic/*`, `no-var`, … | ESLint: the Nera rules and the base config, with ESLint's own ids |
80
+ | `parse-error`, `eslint-directive` | ESLint: a file it cannot parse, an unused `eslint-disable` comment |
81
+ | `css/<stylelint rule>` | stylelint, e.g. `css/selector-class-pattern` or `css/@stylistic/indentation` |
82
+ | `css/parse-error`, `css/needless-disable`, `css/descriptionless-disable` | stylelint: a file it cannot parse, a `stylelint-disable` comment that disables nothing or gives no reason |
83
+ | `pug/*` | the Pug check |
84
+ | `structure/*` | the structure checks |
85
+
86
+ The family prefix keeps stylelint's `@stylistic/indentation` apart from ESLint's `@stylistic/indent`.
67
87
 
68
88
  stderr carries one summary line:
69
89
 
@@ -112,21 +132,31 @@ The repo's own `eslint.config.js` is **not** read: nera-stan builds its configur
112
132
 
113
133
  ### Ignored paths
114
134
 
115
- nera-stan never checks `node_modules/` and `.nera-cache/` at any depth, `public/`, `dist/` and `coverage/` at the repo root, and any `test/site/public/`. It also skips everything the repo's `.gitignore` ignores.
135
+ nera-stan never checks `node_modules/` and `.nera-cache/` at any depth, `public/`, `dist/` and `coverage/` at the repo root, and any `test/site/public/`. It also skips everything the repo's `.gitignore` ignores, and never walks into an ignored folder. This holds for every check: code, CSS, Pug and the test layout.
136
+
137
+ ## Exceptions: the `nera-stan` key
116
138
 
117
- The only exception key is `nera-stan.ignores` in `package.json`, a list of globs relative to the repo root:
139
+ A repo's exceptions live in one object under the `nera-stan` key of its `package.json`, with at most these three keys:
118
140
 
119
141
  ```json
120
142
  {
121
143
  "nera-stan": {
122
- "ignores": ["test/markup/", "demo/demo.js"]
144
+ "ignores": ["test/markup/", "demo/demo.js"],
145
+ "variants": { ".github/workflows/test.yml": "image-cache" },
146
+ "skip": { "structure/test-scripts": "a theme without tests: it compiles its templates instead" }
123
147
  }
124
148
  }
125
149
  ```
126
150
 
127
- Use it for generated or third-party files that live in the repo, such as built bundles or test fixtures copied from upstream. Anything other than an object with a list of non-empty strings under `ignores` is exit code 2. A single deliberate exception in code stays possible with an inline `// eslint-disable-next-line <rule> -- <reason>`.
151
+ | Key | Value | Meaning |
152
+ |---|---|---|
153
+ | `ignores` | a list of non-empty globs relative to the repo root | No check reads these files. For generated or third-party files that live in the repo, such as built bundles, test fixtures copied from upstream, or the repo templates a scaffolding script copies. |
154
+ | `variants` | canonical file → variant name | The repo's copy of that canonical file is compared with the named variant instead of the canonical copy. Only the files and names in [Variants](#variants) are allowed. |
155
+ | `skip` | rule id → reason | The rule neither reports nor fixes in this repo. The id is written exactly as a report line prints it (`css/color-hex-length`, `structure/plugin-tree`, …); the reason is a non-empty string, so the exception explains itself. |
128
156
 
129
- ## Rules
157
+ Exit code 2 ends the run for any other key, a value of the wrong type, an empty glob, a file without variants, an unknown variant name, a `skip` entry without a reason, and a `skip` rule id that no check reports. A single deliberate exception in code stays possible with an inline `// eslint-disable-next-line <rule> -- <reason>`, and in CSS with `/* stylelint-disable-next-line <rule> -- <reason> */`.
158
+
159
+ ## Code rules
130
160
 
131
161
  | Rule | Kinds | Files | `--fix` |
132
162
  |---|---|---|---|
@@ -257,6 +287,108 @@ function makeSite(files) { /* … */ }
257
287
  import { makeSite } from '@nera-static/test-utils'
258
288
  ```
259
289
 
290
+ ## CSS rules
291
+
292
+ Every `*.css` file is checked with stylelint and one shipped configuration:
293
+
294
+ - `stylelint-config-standard`
295
+ - `@stylistic/stylelint-plugin`: `@stylistic/indentation` 4, `@stylistic/string-quotes` single, `@stylistic/no-eol-whitespace` and `@stylistic/no-missing-end-of-source-newline`
296
+ - `selector-class-pattern`: every class is BEM, `block__element--modifier` in lower case with words joined by `-` (`tag-cloud__item--active`). The classes highlight.js writes (`hljs-<scope>`, and sub-scopes such as `class_`) are allowed too, so CSS that styles highlighted code may use them. The same pattern checks the class literals in Pug.
297
+ - `custom-property-pattern`, in plugins and themes only: a plugin's custom properties start with `--theme-` or its own `--nera-<name>-` (`@nera-static/plugin-consent` → `--nera-consent-*`). A theme's start with `--theme-`, its own name (`@nera-static/theme-stack` → `--stack-*`) or any plugin's `--nera-`, since a theme styles plugin output through them. Other kinds have no prefix rule.
298
+ - Switched off as matters of taste, or because their results cannot be trusted: `alpha-value-notation`, `color-function-alias-notation`, `color-function-notation`, `declaration-block-single-line-max-declarations`, `media-feature-range-notation`, `no-descending-specificity` (false positives on component CSS), `number-max-precision` and `property-no-vendor-prefix` (its fix drops `-webkit-` prefixes Safari still needs)
299
+ - `reportNeedlessDisables` and `reportDescriptionlessDisables`: a `stylelint-disable` comment that disables nothing is `css/needless-disable`, one without a reason after ` -- ` is `css/descriptionless-disable`
300
+
301
+ Every finding's rule id is the stylelint rule with the `css/` prefix. A repo's own stylelint config and `.stylelintignore` are not read. `--fix` applies stylelint's own fixes.
302
+
303
+ ## Pug rules
304
+
305
+ Every `*.pug` file is lexed and parsed. Includes and extends are not followed, since a site's theme and vendor layers resolve them only at build time. `--fix` fixes `pug/indent` in one case only, see [Re-indenting a 2-space template](#re-indenting-a-2-space-template); every other Pug finding is fixed by hand.
306
+
307
+ | Rule | Reports |
308
+ |---|---|
309
+ | `pug/syntax` | a template Pug cannot parse, with Pug's message. The file gets no other finding. |
310
+ | `pug/indent` | indentation that is not a multiple of 4 spaces |
311
+ | `pug/no-tabs` | indentation with a tab |
312
+ | `pug/quotes` | an attribute value that is one double-quoted string, `meta(charset="utf-8")`. Double quotes stay allowed around a value that contains a single quote. |
313
+ | `pug/class-pattern` | a class literal, `.Tag-Cloud` or `class='tagCloud'`, that is not BEM (see [CSS rules](#css-rules)) |
314
+
315
+ Text blocks (`p.`, `script.`, `style.`, comments), pipe text, dynamic attributes (`class=cls`) and `&attributes` are not read.
316
+
317
+ ### Re-indenting a 2-space template
318
+
319
+ `--fix` re-indents a template whose every line of Pug structure is indented with spaces, each nested level exactly 2 spaces deeper than its parent. Such a file gets 4 spaces per level:
320
+
321
+ - a line of Pug structure, pipe text included, doubles its indentation
322
+ - a continuation line of a multi-line attribute list moves with the line its tag starts on
323
+ - the lines of a text block (`pre.`, `script.`, `style.`, a filter such as `:markdown`, a `//` comment, a `-` code block) move by the block's own indentation, so the block starts one 4-space level deeper than its parent and the whitespace inside it stays as it was
324
+
325
+ A file with a tab in its indentation, with a level that is not 2 spaces deeper than its parent (` p`, or 4 spaces and then 2), or that would no longer parse to the same tree after re-indenting (a template literal spanning lines in an attribute) is reported and left alone. Its `pug/indent` findings do not count as fixable. With `pug/indent` under `nera-stan.skip`, nothing is re-indented.
326
+
327
+ ## Structure rules
328
+
329
+ | Rule | Kinds | Checks | `--fix` |
330
+ |---|---|---|---|
331
+ | `structure/package-key-order` | all | the top-level keys of `package.json` in the order `name`, `version`, `private`, `description`, `main`, `type`, `exports`, `bin`, `scripts`, `files`, `keywords`, `author`, `license`, `repository`, `bugs`, `homepage`, `publishConfig`, `sideEffects`, `engines`, `nera`, `peerDependencies`, `dependencies`, `optionalDependencies`, `devDependencies`, then any other key in its own order | reorders, keeping the file's indent and line endings; never writes a `package.json` that is a symlink out of the repo |
332
+ | `structure/engines` | all | `engines.node` is `>=22.12.0`, or `^22.13.0 \|\| >=24` where a dependency needs Node 22.13 | no |
333
+ | `structure/plugin-utils-range` | all | a `@nera-static/plugin-utils` range, in any dependency field, is a caret range of the current major no lower than the one nera-stan depends on | no |
334
+ | `structure/changelog-in-files` | published | `files` ships `CHANGELOG.md` | adds it |
335
+ | `structure/npm-pkg-fix` | published | `bin` paths without a leading `./` and `repository.url` with the `git+` prefix, the forms `npm pkg fix` writes | writes those forms |
336
+ | `structure/plugin-tree` | `plugin` | the entry exports hooks only; `src/` exists; `config/<name>.yaml` exists and is in `files`; `bin/publish-template.js` exists exactly when `views/` does, and is the only bin, named `nera-<name>` | no |
337
+ | `structure/theme-tree` | `theme` | `views/layouts/layout.pug`; the seams `head-extra`, `scripts-extra`, `footer-extra` and `nav-main` under `views/partials/`; a `nera.generator` range; every `@font-face` url a file under `assets/fonts/<theme>/`, with a licence file there | no |
338
+ | `structure/starter-tree` | `starter` | `nera.starter.label` and `description`; `files` lists only what `nera new` copies (`pages`, `config`, `theme`, `assets`, `plugins`, `.neraignore`), `CHANGELOG.md` and `!…` exclusions inside them; the README's last H2 is `## First steps`; no file is a byte copy of an installed plugin's `views/` file | no |
339
+ | `structure/readme-badges` | published, not `site` | the Test badge and the npm badge, one per line, directly under the `# title` | no |
340
+ | `structure/readme-outline` | `plugin`, `theme`, `starter` | the README's H2 sections in the kind's order, spelled as listed (emoji included), each once | no |
341
+ | `structure/changelog-format` | all but `site` | Keep a Changelog: `# Changelog`, version headings `## [x.y.z] - YYYY-MM-DD` or `## [Unreleased]`, the groups Added, Changed, Deprecated, Removed, Fixed, Security and `### Migration from vX.x`, list items written `- ` (dash plus three spaces). A missing CHANGELOG counts only in a published package. | no |
342
+ | `structure/license` | published, not `site` | `LICENSE` holds the MIT licence, `MIT License` on line 1 and `Copyright (c) <year> Michael Becker` without placeholders | no |
343
+ | `structure/canonical-file` | all | the [canonical files](#canonical-files) | writes a missing or differing file, see below |
344
+ | `structure/test-scripts` | all but `site` | the scripts `"test": "vitest run"` and `"test:watch": "vitest"` | sets a missing script, and one that only ran vitest |
345
+ | `structure/test-layout` | all but `site` | every test lies under `test/` and is named `<module>.test.js`: no `.unit.`, `.integration.` or `.template.` infix, not `.spec.`, not `.mjs` or `.cjs` | no |
346
+
347
+ **Published** means a `package.json` without `"private": true`. The README, CHANGELOG and LICENSE rules never apply to a `site`.
348
+
349
+ The README outlines per kind:
350
+
351
+ - **plugin:** ✨ Features, 🚀 Installation, 🧩 Usage, ⚙️ Configuration, then any feature sections (plain headings without emoji), 🛠️ Template Publishing and 🎨 Styling (exactly when the plugin ships `views/`), 📊 Generated Output, the optional ⚠️ Warnings and Known limitations, 🧩 Compatibility, 🧪 Development, 🤝 Contributing, 📦 License
352
+ - **theme:** Installation, Page types, the optional Business facts: `app.business` (the contract of the business themes), Seams: where plugin output goes, the optional What a post may contain, External links in a new tab and Search, Configuration: `config/theme.yaml`, Translations, Overriding the theme, What your site must do, the optional Switching between the blog themes, Accessibility and privacy, Versioning, Development, License
353
+ - **starter:** Usage, What you get, then any other sections, Requirements, License, and last First steps
354
+
355
+ ### Canonical files
356
+
357
+ Every repo carries these files exactly as nera-stan ships them under `canonical/` in the package (`node_modules/@nera-static/stan/canonical/`, without the leading dots):
358
+
359
+ | File | Repos |
360
+ |---|---|
361
+ | `.editorconfig` | all |
362
+ | `vitest.config.js` | all but `site` |
363
+ | `.husky/pre-push` | all but `site` |
364
+ | `.github/workflows/test.yml` | all but `site` |
365
+ | `.github/workflows/publish.yml` | published |
366
+ | `.github/dependabot.yml` | all |
367
+ | `.github/FUNDING.yml` | all |
368
+
369
+ The files are compared line by line after dropping full-line `#` comments and trailing blank lines, so a comment that explains the repo's own choice is no difference. The finding names the first line that differs, what nera-stan expected there and what it found.
370
+
371
+ `vitest.config.js` is compared by its structure, not byte by byte: it imports `neraConfig` from `@nera-static/test-utils/vitest` and ends in `export default neraConfig()`, with at most one object of the repo's own options, each with a comment why. `@nera-static/test-utils` itself imports the preset from the file its `./vitest` export names, since a package cannot install itself.
372
+
373
+ `--fix` writes a missing or differing canonical file, and a missing `vitest.config.js`. It never rewrites a `vitest.config.js` that exists, and never a variant with an open part.
374
+
375
+ ### Variants
376
+
377
+ A few repos differ from a canonical file for a reason. Each such difference is a named variant, chosen under `nera-stan.variants`:
378
+
379
+ | File | Variant | For |
380
+ |---|---|---|
381
+ | `.github/workflows/test.yml` | `image-cache` | an `actions/cache` step for `@nera-static/plugin-images`' `.nera-cache` (theme-ansitz, theme-umwege and their starters) |
382
+ | `.github/workflows/test.yml` | `windows-smoke` | `@nera-static/mcp`'s Windows job |
383
+ | `.github/workflows/test.yml` | `dist-check` | `@nera-static/highlightjs-pug`'s check that the committed `dist/` is current |
384
+ | `.github/workflows/test.yml` | `validate-templates` | `@nera-static/theme-example`, which compiles its templates instead of linting and testing |
385
+ | `.github/workflows/publish.yml` | `image-cache` | as above |
386
+ | `.github/workflows/publish.yml` | `desktop-release` | `@nera-static/mcp`'s desktop extension release job |
387
+ | `.github/workflows/publish.yml` | `validate-templates` | as above |
388
+ | `.github/dependabot.yml` | `chokidar-major` | `@nera-static/nera`'s Dependabot ignore of chokidar majors |
389
+
390
+ The variant copies ship under `canonical/variants/<variant>/`. A line of a variant may hold an **open part**, written `{{any}}`, that matches any text in its place, such as the cache step's name, its `path:` before `.nera-cache` and the files its `key:` hashes. `--fix` does not write a variant with open parts: copy it from `node_modules/@nera-static/stan/canonical/variants/<variant>/` and fill them in by hand.
391
+
260
392
  ## Editor integration
261
393
 
262
394
  Editors read `eslint.config.js`, so a repo's config is a single line that re-exports nera-stan's:
@@ -275,13 +407,21 @@ import { createConfig } from '@nera-static/stan'
275
407
  export default createConfig({ root: '/path/to/repo' })
276
408
  ```
277
409
 
410
+ Editors that run stylelint read `stylelint.config.js`; it re-exports nera-stan's stylelint config the same way:
411
+
412
+ ```js
413
+ export { default } from '@nera-static/stan/stylelint'
414
+ ```
415
+
416
+ That default export is the config for the repo in the current directory, with its `nera-stan.skip` entries for `css/*` rules applied. `@nera-static/stan/stylelint` also exports `createStylelintConfig({ pkg, settings })` to build it for another manifest, `customPropertyPrefixes(pkg)`, `TASTE_RULES` and `CSS_PREFIX` (`'css/'`). The `nera-stan` bin reads neither `eslint.config.js` nor `stylelint.config.js`.
417
+
278
418
  The package also exports `detectKind(root)`, `kindOf(pkg)`, `KINDS`, `ALWAYS_IGNORED` and `CONFIG_KEY` (`'nera-stan'`).
279
419
 
280
420
  ## 🧩 Compatibility
281
421
 
282
- Node.js `^22.13.0 || >=24`, the range ESLint 10 and its plugins declare. ESLint, `@eslint/js`, `globals`, `@stylistic/eslint-plugin`, `eslint-plugin-n` and `espree` come with the package, and `@nera-static/plugin-utils` is a dependency for the helper names.
422
+ Node.js `^22.13.0 || >=24`, the range ESLint 10, stylelint 17 and their plugins declare. ESLint, `@eslint/js`, `globals`, `@stylistic/eslint-plugin`, `eslint-plugin-n`, `@eslint-community/eslint-plugin-eslint-comments` and `espree`, stylelint, `stylelint-config-standard` and `@stylistic/stylelint-plugin`, and `pug-lexer` and `pug-parser` come with the package. `@nera-static/plugin-utils` is a dependency for the helper names and the range `structure/plugin-utils-range` asks for.
283
423
 
284
- The rule ids, the report format, the exit codes, the flags, the repo kinds, the `nera-stan.ignores` key and the exported config are the public contract. A new rule or a stricter option fails consumers' CI, so it ships as a minor only when the whole fleet is already green under it, otherwise as a major.
424
+ The rule ids, the report format, the exit codes, the flags, the repo kinds, the `nera-stan` keys with their allowed values, the canonical files and their variants, and the exported ESLint and stylelint configs are the public contract. A new rule or a stricter option fails consumers' CI, so it ships as a minor only when the whole fleet is already green under it, otherwise as a major.
285
425
 
286
426
  ## 🧪 Development
287
427
 
@@ -0,0 +1,12 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ end_of_line = lf
6
+ indent_size = 4
7
+ indent_style = space
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.md]
12
+ trim_trailing_whitespace = false
@@ -0,0 +1,13 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: [seebaermichi]
4
+ # patreon: # Replace with a single Patreon username
5
+ # open_collective: # Replace with a single Open Collective username
6
+ ko_fi: softwarembecker
7
+ # tidelift: # Replace with a single Tidelift package-name e.g., npm/babel
8
+ # community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ # liberapay: # Replace with a single Liberapay username
10
+ # issuehunt: # Replace with a single IssueHunt username
11
+ # otechie: # Replace with a single Otechie username
12
+ # lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13
+ custom: ["https://www.paypal.com/paypalme/softwarembecker"]
@@ -0,0 +1,20 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: npm
4
+ directory: /
5
+ schedule:
6
+ interval: weekly
7
+ groups:
8
+ npm-dependencies:
9
+ patterns:
10
+ - '*'
11
+ open-pull-requests-limit: 5
12
+ - package-ecosystem: github-actions
13
+ directory: /
14
+ schedule:
15
+ interval: weekly
16
+ groups:
17
+ github-actions:
18
+ patterns:
19
+ - '*'
20
+ open-pull-requests-limit: 5
@@ -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
+ - name: Run tests
46
+ run: npx vitest run
47
+
48
+ - name: Lint
49
+ run: npm run lint
50
+
51
+ # Guards against tagging v1.3.0 while package.json still says
52
+ # 1.2.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,37 @@
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
+ - name: Run tests
37
+ run: npx vitest run
@@ -0,0 +1 @@
1
+ npx vitest run
@@ -0,0 +1,25 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: npm
4
+ directory: /
5
+ schedule:
6
+ interval: weekly
7
+ groups:
8
+ npm-dependencies:
9
+ patterns:
10
+ - '*'
11
+ ignore:
12
+ # chokidar 6 needs Node >= 22.22, above our `engines` floor
13
+ # (>=22.12.0). Lift this together with the floor.
14
+ - dependency-name: chokidar
15
+ update-types: ['version-update:semver-major']
16
+ open-pull-requests-limit: 5
17
+ - package-ecosystem: github-actions
18
+ directory: /
19
+ schedule:
20
+ interval: weekly
21
+ groups:
22
+ github-actions:
23
+ patterns:
24
+ - '*'
25
+ open-pull-requests-limit: 5
@@ -0,0 +1,104 @@
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
+ contents: read
19
+
20
+ # Each job gets only what it needs: `publish` the OIDC token for npm, `release`
21
+ # the `contents: write` that creates the GitHub Release.
22
+
23
+ jobs:
24
+ publish:
25
+ runs-on: ubuntu-latest
26
+
27
+ permissions:
28
+ id-token: write # required for OIDC — without it, publish falls back to a token and fails
29
+ contents: read
30
+
31
+ steps:
32
+ - name: Checkout repository
33
+ uses: actions/checkout@v7
34
+
35
+ # Node 24 ships npm 11.x. Trusted publishing needs npm >= 11.5.1.
36
+ # `registry-url` is deliberately NOT set: it writes an _authToken
37
+ # line into .npmrc which breaks OIDC when no NODE_AUTH_TOKEN is
38
+ # present (actions/setup-node#1551). npm defaults to the public
39
+ # registry regardless.
40
+ - name: Setup Node.js
41
+ uses: actions/setup-node@v7
42
+ with:
43
+ node-version: '24'
44
+
45
+ - name: Pin npm to a version that supports OIDC
46
+ run: npm install -g npm@latest
47
+
48
+ - name: Install dependencies
49
+ run: npm ci
50
+
51
+ - name: Run tests
52
+ run: npx vitest run
53
+
54
+ - name: Lint
55
+ run: npm run lint
56
+
57
+ # Guards against tagging v1.3.0 while package.json still says
58
+ # 1.2.0 — npm would happily publish the wrong version.
59
+ - name: Verify tag matches package.json version
60
+ run: |
61
+ TAG="${GITHUB_REF_NAME#v}"
62
+ PKG="$(node -p "require('./package.json').version")"
63
+ if [ "$TAG" != "$PKG" ]; then
64
+ echo "::error::Tag $GITHUB_REF_NAME does not match package.json version $PKG"
65
+ exit 1
66
+ fi
67
+ echo "Tag and package.json agree on $PKG"
68
+
69
+ - name: Publish
70
+ run: npm publish
71
+
72
+ # The Claude Desktop extension, attached to the tag's GitHub Release once
73
+ # the package is on npm (a failed bundle never holds back the package).
74
+ release:
75
+ needs: publish
76
+ runs-on: ubuntu-latest
77
+
78
+ permissions:
79
+ contents: write
80
+
81
+ steps:
82
+ # no token left in .git/config for the install scripts to find
83
+ - name: Checkout repository
84
+ uses: actions/checkout@v7
85
+ with:
86
+ persist-credentials: false
87
+
88
+ - name: Setup Node.js
89
+ uses: actions/setup-node@v7
90
+ with:
91
+ node-version: '24'
92
+
93
+ - name: Install dependencies
94
+ run: npm ci
95
+
96
+ # downloads the docs, installs the production dependencies for
97
+ # every Desktop platform plus npm itself, packs nera-mcp-<version>.mcpb
98
+ - name: Build the Claude Desktop extension
99
+ run: npm run mcpb
100
+
101
+ - name: Attach the extension to the GitHub Release
102
+ env:
103
+ GH_TOKEN: ${{ github.token }}
104
+ run: gh release create "$GITHUB_REF_NAME" "nera-mcp-${GITHUB_REF_NAME#v}.mcpb" --title "$GITHUB_REF_NAME" --generate-notes --verify-tag
@@ -0,0 +1,43 @@
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
+ - name: Run linter
34
+ run: npm run lint
35
+
36
+ - name: Run tests
37
+ run: npx vitest run
38
+
39
+ # dist/ (highlight.js's 3rd-party layout) and the demo's bundle
40
+ # are committed; fail when they were not rebuilt after a change
41
+ # to src/.
42
+ - name: Check that dist/ and demo/ are up to date
43
+ run: npm run build && git diff --exit-code -- dist demo