Route tests through a #testing alias, ban ../ imports, and document the alias ownership rule
Check / check (pull_request) Successful in 46s
Check / check (pull_request) Successful in 46s
This commit is contained in:
@@ -19,10 +19,14 @@ dependency. Keep the sources to erasable syntax and `.ts` imports, which
|
||||
type-checks, and `vp test` runs Vitest. Unit tests sit next to the code as
|
||||
`src/*.test.ts`; repository-level tests live in `tests/`.
|
||||
|
||||
`src/` is flat, so `package.json` has no `imports` aliases and modules, tests,
|
||||
and `scripts/` import each other relatively. If one is ever added, it may point
|
||||
only at a direct subfolder of `src/` (its `index.ts`, or a `#x/*` pattern
|
||||
inside it); never at `src/` itself, a deeper folder, or anything outside `src/`.
|
||||
An alias in `package.json` `imports` owns its target: a folder's `index.ts`
|
||||
owns that folder and everything below it, any other file owns only that file.
|
||||
No file may be owned by 2 aliases. Outside an area, only the exact alias
|
||||
reaches it (no deeper `#` specifier, no relative path); inside it, relative
|
||||
imports of siblings and subfolders are free. `../` is banned in every file
|
||||
(`import/no-relative-parent-imports`). The one alias is `#testing`
|
||||
(`./src/testing.ts`): every test imports it by alias, and `tests/` reaches
|
||||
`src/` only through it. Other `src/` files import `./` siblings freely.
|
||||
`scripts/` is flat: one file per tool, no subfolders and no `index.ts`
|
||||
(barrels live only in `src/`), imported directly by file path.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user