@vwala/tooling-config 1.6.0 → 1.7.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.
- package/.vwala/docs/react-19.md +2 -2
- package/.vwala/docs/react-compiler.md +1 -1
- package/README.md +8 -4
- package/package.json +2 -2
- package/src/biome/_scripts/check-naming.mjs +5 -4
- package/src/biome/biome.config.json +1 -0
- package/src/biome/plugins/_scripts/check-test-layout.mjs +14 -10
- package/src/context/_scripts/check-module-context.mjs +50 -17
- package/src/monorepo/_scripts/check-exports.mjs +1 -1
- package/src/react-compiler/policy/scoped-source.mjs +1 -0
package/.vwala/docs/react-19.md
CHANGED
|
@@ -26,7 +26,7 @@ Install `@vwala/tooling-config` at the repository root beside `biome.json` or `b
|
|
|
26
26
|
"!**/generated/**",
|
|
27
27
|
"!**/__generated__/**",
|
|
28
28
|
"!**/__tests__/**",
|
|
29
|
-
"!**/
|
|
29
|
+
"!**/__test-support__/**",
|
|
30
30
|
"!**/fixtures/**",
|
|
31
31
|
"!**/__fixtures__/**",
|
|
32
32
|
"!**/vendor/**",
|
|
@@ -54,7 +54,7 @@ Install `@vwala/tooling-config` at the repository root beside `biome.json` or `b
|
|
|
54
54
|
"!**/generated/**",
|
|
55
55
|
"!**/__generated__/**",
|
|
56
56
|
"!**/__tests__/**",
|
|
57
|
-
"!**/
|
|
57
|
+
"!**/__test-support__/**",
|
|
58
58
|
"!**/fixtures/**",
|
|
59
59
|
"!**/__fixtures__/**",
|
|
60
60
|
"!**/vendor/**",
|
|
@@ -51,7 +51,7 @@ Append these exclusions to both `includes` arrays above so editor diagnostics ha
|
|
|
51
51
|
"!**/node_modules/**", "!**/.git/**", "!**/dist/**", "!**/build/**",
|
|
52
52
|
"!**/.next/**", "!**/.expo/**", "!**/coverage/**",
|
|
53
53
|
"!**/generated/**", "!**/__generated__/**", "!**/__tests__/**",
|
|
54
|
-
"!**/
|
|
54
|
+
"!**/__test-support__/**", "!**/fixtures/**", "!**/__fixtures__/**",
|
|
55
55
|
"!**/vendor/**", "!**/vendored/**", "!**/*.test.*", "!**/*.spec.*",
|
|
56
56
|
"!**/*.d.ts", "!**/*.d.mts", "!**/*.d.cts"
|
|
57
57
|
]
|
package/README.md
CHANGED
|
@@ -116,7 +116,7 @@ They are warnings because the convention applies to new code and asks that exist
|
|
|
116
116
|
|
|
117
117
|
`check-naming` (see [Convention checks](#convention-checks)) supplies the two halves the rules cannot express — folder names, which Biome never sees, and an error for files **added since the base ref**, which no static severity can express. Existing offenders are printed as warnings and leave the exit code at 0; a new file or a new folder that breaks the convention exits 1. The base ref defaults to `origin/main` — set `NAMING_BASE_REF` for a differently named default branch, and note that a shallow CI clone that cannot resolve it degrades the check to warnings only, so fetch enough history for `git merge-base` to work.
|
|
118
118
|
|
|
119
|
-
`__tests__`, `__mocks__`, `_scripts`, hidden folders, and the `[slug]` / `(group)` / `@slot` segments Next.js and Expo give meaning to are exempt from the folder check.
|
|
119
|
+
`__tests__`, `__test-support__`, `__mocks__`, `_scripts`, hidden folders, and the `[slug]` / `(group)` / `@slot` segments Next.js and Expo give meaning to are exempt from the folder check.
|
|
120
120
|
|
|
121
121
|
Filenames that carry a routing marker — a leading `_` (`_layout.tsx`), or a `+` or `[` anywhere (`+not-found.tsx`, `hello+api.ts`, `[id].tsx`, `[...slug].tsx`) — are exempt from both `useFilenamingConvention` and `check-naming`, because Expo Router and Next.js own those names. Only the filename counts: `payment_service.ts` still fails, and so does `fooBar.ts` inside `_scripts/`.
|
|
122
122
|
|
|
@@ -144,6 +144,8 @@ All three are errors, which is a departure from the [naming](#naming) rules and
|
|
|
144
144
|
|
|
145
145
|
`use-tests-folder-location` can only check syntax — a GritQL plugin cannot see its own file path. The path-level halves of that convention — no `tests/` folder, no non-test files in `__tests__/`, no production code importing test code — are the second of the [convention checks](#convention-checks).
|
|
146
146
|
|
|
147
|
+
Test utilities live in `__test-support__/`, named like `__tests__/` so both read as test-only. The legacy `test-support/` name is still treated as test code by every check and shipped glob — test layout, module context, package exports, `no-uuid-type-assertion`, and the React Compiler scope — so a repository can upgrade this package before it renames its folders. Names that are not folders keep `test-support`: a `test-support.ts` barrel and the `"./test-support"` export it backs.
|
|
148
|
+
|
|
147
149
|
---
|
|
148
150
|
|
|
149
151
|
## Convention checks
|
|
@@ -168,7 +170,7 @@ Some conventions are about paths and manifests rather than syntax, and Biome rea
|
|
|
168
170
|
| `package exports` | Every `packages/**` manifest declares an `exports` map of explicit subpaths, with no legacy `main`/`module`/`types` and no dangling targets — see [package exports](#package-exports). |
|
|
169
171
|
| `agent skills` | [`.agents/skills/` is the only copy](#agent-skills); other agent directories mirror it with symlinks. |
|
|
170
172
|
| `agent docs` | [`CLAUDE.md` is a symlink to `AGENTS.md`](#agent-briefs), never a second copy. |
|
|
171
|
-
| `module context` | [Every module under `packages/modules/` declares its domain language](#module-glossaries) in `CONTEXT.md
|
|
173
|
+
| `module context` | [Every module under `packages/modules/` declares its domain language](#module-glossaries) in `GLOSSARY.md`; a legacy `CONTEXT.md` still passes with a warning while repositories migrate. |
|
|
172
174
|
|
|
173
175
|
Wire that single script into your own preflight and new checks arrive with an upgrade, rather than as another `&&` you have to add by hand. It runs every check even after one fails — a bad filename and a misplaced test are independent problems, and seeing both in one run beats fixing one to discover the other. Each check is still a standalone script under `src/**/_scripts/` if you want to run one on its own.
|
|
174
176
|
|
|
@@ -221,14 +223,16 @@ Both files are optional. A repository with neither passes, and so does one with
|
|
|
221
223
|
|
|
222
224
|
### Module glossaries
|
|
223
225
|
|
|
224
|
-
Every package under `packages/modules/` owns a bounded area of the business, so every one of them declares its domain language in `
|
|
226
|
+
Every package under `packages/modules/` owns a bounded area of the business, so every one of them declares its domain language in `GLOSSARY.md`.
|
|
225
227
|
|
|
226
228
|
Without it each module invents its own words for the same thing — one calls it an order, the next a purchase, the third a transaction — and the cost only shows up later, when the three have to talk to each other and nobody can say whether they mean the same thing. `packages/platform/` and `packages/tooling/` are excluded on purpose: they hold code with no domain knowledge, so they have no domain language to declare.
|
|
227
229
|
|
|
228
|
-
A module is identified by its `package.json`, at any depth. Modules nest (`packages/modules/act/enrich/`) and may be scoped (`packages/modules/@acme/invoicing/`), so every manifest counts — including one at a grouping level that has modules beneath it, because a directory carrying a manifest is a package and a package here is a module. Manifests below `node_modules/`, `src/`, `dist/`, `build/`, `__tests__/`, `test-support/` or `fixtures/` are skipped; a workspace package never has one of those as an ancestor, so excluding by folder rather than by depth is what keeps a fixture's manifest from registering as a module of its own.
|
|
230
|
+
A module is identified by its `package.json`, at any depth. Modules nest (`packages/modules/act/enrich/`) and may be scoped (`packages/modules/@acme/invoicing/`), so every manifest counts — including one at a grouping level that has modules beneath it, because a directory carrying a manifest is a package and a package here is a module. Manifests below `node_modules/`, `src/`, `dist/`, `build/`, `__tests__/`, `__test-support__/`, `test-support/` or `fixtures/` are skipped; a workspace package never has one of those as an ancestor, so excluding by folder rather than by depth is what keeps a fixture's manifest from registering as a module of its own.
|
|
229
231
|
|
|
230
232
|
Existence and non-emptiness are all that is checked. The convention asks for a glossary written as terms crystallise, and a checker that demanded headings and a minimum term count would only teach people to satisfy it with a heading and a fake term.
|
|
231
233
|
|
|
234
|
+
The file used to be called `CONTEXT.md`, and repositories are migrating to the new name. Until they have, a module whose only glossary is a legacy `CONTEXT.md` still passes, with a warning that names the file and asks for the rename; the empty and symlink rules apply to it as they would to `GLOSSARY.md`. A module with both files fails instead — two glossaries for one module drift apart, so merge `CONTEXT.md` into `GLOSSARY.md` and delete it. Legacy support will be removed in a later release.
|
|
235
|
+
|
|
232
236
|
---
|
|
233
237
|
|
|
234
238
|
## Package manager
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vwala/tooling-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shared tooling configuration for Vwala repositories",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"src",
|
|
16
16
|
".vwala/docs",
|
|
17
17
|
"!src/**/__tests__",
|
|
18
|
-
"!src/**/
|
|
18
|
+
"!src/**/__test-support__"
|
|
19
19
|
],
|
|
20
20
|
"bin": {
|
|
21
21
|
"compile-react-library": "./src/react-compiler/build/compile-react-library.mjs",
|
|
@@ -33,10 +33,11 @@ const IGNORED_PREFIXES = [".agents/", ".claude/", ".husky/"];
|
|
|
33
33
|
const SOURCE_FILE = /\.[cm]?[jt]sx?$/;
|
|
34
34
|
const KEBAB_CASE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
35
35
|
// Folder names that are a convention in their own right rather than a name:
|
|
36
|
-
// the test and story folders, the `_scripts` prefix this package
|
|
37
|
-
// runnable helpers, anything hidden, and the bracket/paren/@ segments
|
|
38
|
-
// Next.js and Expo routing give meaning to.
|
|
39
|
-
const RESERVED_FOLDER =
|
|
36
|
+
// the test, test-support and story folders, the `_scripts` prefix this package
|
|
37
|
+
// uses for runnable helpers, anything hidden, and the bracket/paren/@ segments
|
|
38
|
+
// that Next.js and Expo routing give meaning to.
|
|
39
|
+
const RESERVED_FOLDER =
|
|
40
|
+
/^(__[a-z]+(-[a-z]+)*__|_[a-z-]+|\..+|\[.+\]|\(.+\)|@.+|\+.+)$/;
|
|
40
41
|
// Filenames that carry a router's marker — Expo's `_layout` and `+not-found`,
|
|
41
42
|
// its `+api` suffix, a `[param]` / `[...slug]` segment — follow whatever that
|
|
42
43
|
// framework enforces, which is not ours to second-guess.
|
|
@@ -9,18 +9,21 @@
|
|
|
9
9
|
* tracked files.
|
|
10
10
|
*
|
|
11
11
|
* 1. No folder named `tests` or `test` — test files live in `__tests__/`, test
|
|
12
|
-
* utilities in `
|
|
13
|
-
* 2. No non-test file inside `__tests__/` — utilities belong in
|
|
14
|
-
* This is the check that catches helpers drifting back
|
|
15
|
-
*
|
|
12
|
+
* utilities in `__test-support__/`.
|
|
13
|
+
* 2. No non-test file inside `__tests__/` — utilities belong in
|
|
14
|
+
* `__test-support__/`. This is the check that catches helpers drifting back
|
|
15
|
+
* in.
|
|
16
|
+
* 3. Production code must not import from `__test-support__/` or `__tests__/`.
|
|
17
|
+
* The legacy `test-support/` folder name is still recognized on both sides,
|
|
18
|
+
* so a repository can upgrade before its folders are renamed.
|
|
16
19
|
* Two things are deliberately exempt, because in both the import is the
|
|
17
20
|
* point rather than a leak:
|
|
18
21
|
* - Storybook apps, whose whole job is rendering real fixtures, and whose
|
|
19
22
|
* story helpers are not always named `*.stories.tsx`;
|
|
20
23
|
* - `test-support.ts` barrels, which re-export a package's own
|
|
21
|
-
* `
|
|
22
|
-
* camelCase spelling is still accepted, because the kebab-case
|
|
23
|
-
* rule only reaches code written since it shipped.
|
|
24
|
+
* `__test-support__/` through a published `"./test-support"` export.
|
|
25
|
+
* The camelCase spelling is still accepted, because the kebab-case
|
|
26
|
+
* filename rule only reaches code written since it shipped.
|
|
24
27
|
*
|
|
25
28
|
* See: .agents/skills/vwala-conventions/references/test-style.md
|
|
26
29
|
*/
|
|
@@ -32,6 +35,7 @@ const TEST_FILE = /\.test\.[cm]?[jt]sx?$/;
|
|
|
32
35
|
const STORY_FILE =
|
|
33
36
|
/(\.stories\.[jt]sx?$|\/__stories__\/|^apps\/[^/]*storybook[^/]*\/)/;
|
|
34
37
|
const TEST_SUPPORT_BARREL = /(^|\/)(test-support|testSupport)\.[cm]?ts$/;
|
|
38
|
+
const TEST_FOLDER = /(^|\/)(__tests__|__test-support__|test-support)\//;
|
|
35
39
|
|
|
36
40
|
const files = execFileSync("git", ["ls-files"], {
|
|
37
41
|
encoding: "utf8",
|
|
@@ -48,7 +52,7 @@ const violations = [];
|
|
|
48
52
|
for (const file of files) {
|
|
49
53
|
if (/(^|\/)tests?\//.test(file)) {
|
|
50
54
|
violations.push(
|
|
51
|
-
`${file}\n Folder named "tests"/"test". Test files go in __tests__/, utilities in
|
|
55
|
+
`${file}\n Folder named "tests"/"test". Test files go in __tests__/, utilities in __test-support__/.`,
|
|
52
56
|
);
|
|
53
57
|
}
|
|
54
58
|
|
|
@@ -58,7 +62,7 @@ for (const file of files) {
|
|
|
58
62
|
!file.endsWith(".md")
|
|
59
63
|
) {
|
|
60
64
|
violations.push(
|
|
61
|
-
`${file}\n Non-test file inside __tests__/. Test utilities belong in
|
|
65
|
+
`${file}\n Non-test file inside __tests__/. Test utilities belong in __test-support__/.`,
|
|
62
66
|
);
|
|
63
67
|
}
|
|
64
68
|
}
|
|
@@ -69,7 +73,7 @@ const productionSources = files.filter(
|
|
|
69
73
|
!TEST_FILE.test(file) &&
|
|
70
74
|
!STORY_FILE.test(file) &&
|
|
71
75
|
!TEST_SUPPORT_BARREL.test(file) &&
|
|
72
|
-
|
|
76
|
+
!TEST_FOLDER.test(file) &&
|
|
73
77
|
!/\.config\.[cm]?[jt]s$/.test(file),
|
|
74
78
|
);
|
|
75
79
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* Every package under `packages/modules/` owns a bounded area of the business,
|
|
4
|
-
* so every one of them declares its domain language in `
|
|
4
|
+
* so every one of them declares its domain language in `GLOSSARY.md`.
|
|
5
5
|
*
|
|
6
6
|
* Without it each module invents its own words for the same thing — one calls
|
|
7
7
|
* it an order, the next a purchase, the third a transaction — and the cost only
|
|
@@ -15,9 +15,15 @@
|
|
|
15
15
|
* and a minimum term count would only teach people to satisfy it with a heading
|
|
16
16
|
* and a fake term.
|
|
17
17
|
*
|
|
18
|
+
* The file used to be called `CONTEXT.md`. While repositories migrate, a legacy
|
|
19
|
+
* `CONTEXT.md` that is a module's only glossary still passes with a warning to
|
|
20
|
+
* rename it, and the empty and symlink rules apply to it as they would to
|
|
21
|
+
* `GLOSSARY.md`. A module that has both files fails, because two glossaries for
|
|
22
|
+
* one module drift apart. Legacy support goes away in a later release.
|
|
23
|
+
*
|
|
18
24
|
* Biome cannot express this. A missing file has no syntax to parse.
|
|
19
25
|
*
|
|
20
|
-
* See: .agents/skills/vwala-conventions/references/domain-language-in-
|
|
26
|
+
* See: .agents/skills/vwala-conventions/references/domain-language-in-glossary-md.md
|
|
21
27
|
* See: .agents/skills/vwala-conventions/references/monorepo-structure.md
|
|
22
28
|
*/
|
|
23
29
|
import {
|
|
@@ -28,7 +34,8 @@ import {
|
|
|
28
34
|
|
|
29
35
|
const MODULES_ROOT = "packages/modules/";
|
|
30
36
|
const MANIFEST = "package.json";
|
|
31
|
-
const
|
|
37
|
+
const GLOSSARY_FILE = "GLOSSARY.md";
|
|
38
|
+
const LEGACY_GLOSSARY_FILE = "CONTEXT.md";
|
|
32
39
|
|
|
33
40
|
/**
|
|
34
41
|
* Folders a workspace package never has as an ancestor. A `package.json` below
|
|
@@ -41,6 +48,7 @@ const NOT_A_PACKAGE_ROOT = new Set([
|
|
|
41
48
|
"dist",
|
|
42
49
|
"build",
|
|
43
50
|
"__tests__",
|
|
51
|
+
"__test-support__",
|
|
44
52
|
"test-support",
|
|
45
53
|
"fixtures",
|
|
46
54
|
]);
|
|
@@ -74,43 +82,68 @@ const modules = entries
|
|
|
74
82
|
.sort();
|
|
75
83
|
|
|
76
84
|
const violations = [];
|
|
85
|
+
const warnings = [];
|
|
77
86
|
|
|
78
87
|
for (const module of modules) {
|
|
79
|
-
const
|
|
80
|
-
const
|
|
88
|
+
const glossaryPath = `${module}${GLOSSARY_FILE}`;
|
|
89
|
+
const legacyPath = `${module}${LEGACY_GLOSSARY_FILE}`;
|
|
90
|
+
const current = byPath.get(glossaryPath);
|
|
91
|
+
const legacy = byPath.get(legacyPath);
|
|
92
|
+
const glossary = current ?? legacy;
|
|
81
93
|
|
|
82
|
-
if (
|
|
83
|
-
// macOS filesystems are case-insensitive, so a `
|
|
94
|
+
if (glossary === undefined) {
|
|
95
|
+
// macOS filesystems are case-insensitive, so a `Glossary.md` looks present
|
|
84
96
|
// in an editor while git tracks the name that was actually committed.
|
|
85
97
|
// Saying which is which beats "missing" on a file the author can see.
|
|
86
|
-
const miscased = entries.find(
|
|
87
|
-
(
|
|
88
|
-
entry.path.toLowerCase() ===
|
|
89
|
-
|
|
98
|
+
const miscased = entries.find((entry) =>
|
|
99
|
+
[glossaryPath, legacyPath].some(
|
|
100
|
+
(expected) => entry.path.toLowerCase() === expected.toLowerCase(),
|
|
101
|
+
),
|
|
90
102
|
);
|
|
91
103
|
|
|
92
104
|
violations.push(
|
|
93
105
|
miscased === undefined
|
|
94
|
-
? `${
|
|
95
|
-
: `${miscased.path}\n Wrong case. Rename it to ${
|
|
106
|
+
? `${glossaryPath}\n Missing. Every module under ${MODULES_ROOT} declares its domain language in ${GLOSSARY_FILE}.`
|
|
107
|
+
: `${miscased.path}\n Wrong case. Rename it to ${GLOSSARY_FILE}.`,
|
|
96
108
|
);
|
|
97
109
|
continue;
|
|
98
110
|
}
|
|
99
111
|
|
|
100
|
-
if (
|
|
112
|
+
if (legacy !== undefined) {
|
|
113
|
+
if (current === undefined) {
|
|
114
|
+
warnings.push(
|
|
115
|
+
`${legacyPath}\n Legacy name. Rename it to ${GLOSSARY_FILE}.`,
|
|
116
|
+
);
|
|
117
|
+
} else {
|
|
118
|
+
violations.push(
|
|
119
|
+
`${legacyPath}\n Second glossary. Merge it into ${GLOSSARY_FILE} and delete it.`,
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (glossary.mode === SYMLINK_MODE) {
|
|
101
125
|
violations.push(
|
|
102
|
-
`${
|
|
126
|
+
`${glossary.path}\n Symlink. A module's domain language is its own; it cannot be borrowed from another module.`,
|
|
103
127
|
);
|
|
104
128
|
continue;
|
|
105
129
|
}
|
|
106
130
|
|
|
107
|
-
if (readBlob({ sha:
|
|
131
|
+
if (readBlob({ sha: glossary.sha }).trim() === "") {
|
|
108
132
|
violations.push(
|
|
109
|
-
`${
|
|
133
|
+
`${glossary.path}\n Empty. Write the module's terms, or the file is a placeholder that says nothing.`,
|
|
110
134
|
);
|
|
111
135
|
}
|
|
112
136
|
}
|
|
113
137
|
|
|
138
|
+
if (warnings.length > 0) {
|
|
139
|
+
console.warn(
|
|
140
|
+
`\n ! ${warnings.length} module glossary file(s) still named ${LEGACY_GLOSSARY_FILE} — accepted while repositories migrate to ${GLOSSARY_FILE}:\n`,
|
|
141
|
+
);
|
|
142
|
+
for (const warning of warnings) {
|
|
143
|
+
console.warn(` ${warning}\n`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
114
147
|
if (violations.length > 0) {
|
|
115
148
|
console.error(`\n ✖ ${violations.length} module-context violation(s):\n`);
|
|
116
149
|
for (const violation of violations) {
|
|
@@ -64,7 +64,7 @@ const LIBRARY_MANIFEST = /^packages\//;
|
|
|
64
64
|
// A manifest under one of these is test data — a consumer testing a package
|
|
65
65
|
// generator commits fixture manifests — not a workspace package.
|
|
66
66
|
const FIXTURE_MANIFEST =
|
|
67
|
-
/\/(__tests__|__fixtures__|test-support|node_modules)\//;
|
|
67
|
+
/\/(__tests__|__fixtures__|__test-support__|test-support|node_modules)\//;
|
|
68
68
|
const IGNORED_PREFIXES = [".agents/", ".claude/"];
|
|
69
69
|
|
|
70
70
|
// npm names are lowercase; the scope is what stops `ui` colliding with an
|