Compare commits
3 Commits
main
...
2e09945a6a
| Author | SHA1 | Date | |
|---|---|---|---|
| 2e09945a6a | |||
| 934a3cfd03 | |||
| b170f25c7d |
@@ -6,7 +6,16 @@ description: Shared code comes through # aliases in package.json imports, each d
|
|||||||
|
|
||||||
Shared code is imported through Node subpath imports declared in
|
Shared code is imported through Node subpath imports declared in
|
||||||
`package.json` `imports`, never by a relative path that climbs out of a
|
`package.json` `imports`, never by a relative path that climbs out of a
|
||||||
directory:
|
directory.
|
||||||
|
|
||||||
|
**Targets (user rule, 2026-10-16):** an alias may point ONLY at a direct
|
||||||
|
subfolder of `src/`: its `index.ts` (`"#helpers": "./src/helpers/index.ts"`)
|
||||||
|
or a `#x/*` pattern inside that one folder. Never alias anything outside
|
||||||
|
`src/` (`scripts/`, root files), `src/` itself (no `#plugin` for
|
||||||
|
`./src/index.ts`), or a deeper folder (`./src/a/b/`). Code that would need
|
||||||
|
such an alias uses a relative import instead; `scripts/` and
|
||||||
|
`vite.config.ts` import each other relatively. Layer rules
|
||||||
|
(`enforce-layer-order`) must still pass, so reorder entries if needed.
|
||||||
|
|
||||||
```jsonc
|
```jsonc
|
||||||
"imports": {
|
"imports": {
|
||||||
@@ -46,3 +55,20 @@ so they never reach package consumers.
|
|||||||
|
|
||||||
Relative imports inside one directory (`./sibling.ts`) are fine, with the
|
Relative imports inside one directory (`./sibling.ts`) are fine, with the
|
||||||
`.ts` extension written out.
|
`.ts` extension written out.
|
||||||
|
|
||||||
|
## `scripts/` is flat (user rule, 2026-10-16)
|
||||||
|
|
||||||
|
- `scripts/` has no subfolders and no `index.ts`. Barrels and `index.ts`
|
||||||
|
entries exist only inside `src/`; delete any `index.ts` outside it.
|
||||||
|
- Each tool is one file, `scripts/<name>.ts`, imported directly by file:
|
||||||
|
`import { decorators } from "./scripts/decorators.ts";` in
|
||||||
|
`vite.config.ts`.
|
||||||
|
- Code in a former `scripts/<tool>/` folder is merged or renamed into flat
|
||||||
|
`scripts/<name>.ts` files. Non-TS assets (HTML, images, fixtures) move to
|
||||||
|
where they belong (next to the tool's output, `.agents/`, or a gitignored
|
||||||
|
scratch dir). A subfolder that is really an app moves under `src/` as an
|
||||||
|
aliased folder.
|
||||||
|
- import-check 0.10.0+ checks folder layout only where the importer or the
|
||||||
|
target sits in a `#`-aliased folder, so `vite.config.ts` →
|
||||||
|
`./scripts/x.ts` passes without any override. Remove overrides that only
|
||||||
|
dodged import-check.
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ practice.
|
|||||||
off for `src/rules/index.ts`, the rule registry, which must import every
|
off for `src/rules/index.ts`, the rule registry, which must import every
|
||||||
rule. It is not a precedent for apps.
|
rule. It is not a precedent for apps.
|
||||||
- **`scripts/**`:** a narrow override is allowed when a tooling script truly
|
- **`scripts/**`:** a narrow override is allowed when a tooling script truly
|
||||||
needs it, e.g. `no-console` in a CLI script.
|
needs it, e.g. `no-console` in a CLI script. Never one that only dodges
|
||||||
|
import-check (e.g. `no-relative-bypass` for `vite.config.ts`); import-check
|
||||||
|
ignores folders no `#` alias owns.
|
||||||
- **Generated files:** list them in `ignorePatterns`, never `overrides`.
|
- **Generated files:** list them in `ignorePatterns`, never `overrides`.
|
||||||
- **Anything else needs the user's approval first.** When the user is away,
|
- **Anything else needs the user's approval first.** When the user is away,
|
||||||
don't add it: refactor, or leave the violation failing and log the question.
|
don't add it: refactor, or leave the violation failing and log the question.
|
||||||
|
|||||||
@@ -11,8 +11,9 @@ Decided 2026-10-14 for all repos.
|
|||||||
config needed. Packages publish only `dist/`, so colocated tests cost nothing
|
config needed. Packages publish only `dist/`, so colocated tests cost nothing
|
||||||
in the tarball.
|
in the tarball.
|
||||||
- **Regression and integration tests** live in the top-level `tests/` folder
|
- **Regression and integration tests** live in the top-level `tests/` folder
|
||||||
and use only the public entry point (an alias like `#plugin`), never
|
and use only the public entry point through a relative import
|
||||||
internals. `vp test tests` runs just these.
|
(`../src/index.ts`; no alias may target `src/` itself, see
|
||||||
|
[[imports-aliases-barrels]]), never internals. `vp test tests` runs just these.
|
||||||
- **No in-source tests** (`import.meta.vitest`).
|
- **No in-source tests** (`import.meta.vitest`).
|
||||||
- **`scripts/` gets no tests** (2026-10-15): it is repo tooling, not
|
- **`scripts/` gets no tests** (2026-10-15): it is repo tooling, not
|
||||||
production code (`project-lint.ts`, `decorators.ts`, `lit-check.ts`,
|
production code (`project-lint.ts`, `decorators.ts`, `lit-check.ts`,
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ with everything.
|
|||||||
{ sortPackageJson: false }` and the category-based `lint` block.
|
{ sortPackageJson: false }` and the category-based `lint` block.
|
||||||
- [ ] Delete `deno.json`, `deno.lock`, and Deno-only files. `mod.ts` →
|
- [ ] Delete `deno.json`, `deno.lock`, and Deno-only files. `mod.ts` →
|
||||||
`index.ts`; `deno.json` imports → `package.json` `imports` (`#x/*`
|
`index.ts`; `deno.json` imports → `package.json` `imports` (`#x/*`
|
||||||
patterns for trailing-slash mappings); `jsr:`/`npm:` → npm packages.
|
patterns for trailing-slash mappings; aliases may target only direct
|
||||||
|
subfolders of `src/`, anything else becomes a relative import);
|
||||||
|
`jsr:`/`npm:` → npm packages.
|
||||||
|
|
||||||
**Code**
|
**Code**
|
||||||
|
|
||||||
@@ -38,6 +40,9 @@ with everything.
|
|||||||
- [ ] Decorators stay standard with `accessor`; add `scripts/decorators.ts`
|
- [ ] Decorators stay standard with `accessor`; add `scripts/decorators.ts`
|
||||||
if the repo has any. Lit repos: `scripts/lit-check.ts` + `npm run
|
if the repo has any. Lit repos: `scripts/lit-check.ts` + `npm run
|
||||||
lit-check`.
|
lit-check`.
|
||||||
|
- [ ] `scripts/` is flat: no subfolders, no `index.ts` (barrels live only in
|
||||||
|
`src/`); `vite.config.ts` imports `./scripts/<name>.ts` directly. A
|
||||||
|
scripts subfolder that is really an app moves under `src/`.
|
||||||
|
|
||||||
**Lint**
|
**Lint**
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,13 @@ 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
|
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/*.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/`.
|
||||||
|
`scripts/` is flat: one file per tool, no subfolders and no `index.ts`
|
||||||
|
(barrels live only in `src/`), imported directly by file path.
|
||||||
|
|
||||||
The only config files are `package.json`, `tsconfig.json`, and
|
The only config files are `package.json`, `tsconfig.json`, and
|
||||||
`vite.config.ts`, plus `package-lock.json`. Repo-local lint rules and the rule
|
`vite.config.ts`, plus `package-lock.json`. Repo-local lint rules and the rule
|
||||||
list live in `scripts/project-lint.ts`. Lint disable comments are not allowed;
|
list live in `scripts/project-lint.ts`. Lint disable comments are not allowed;
|
||||||
|
|||||||
+7
-12
@@ -1,8 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* `project` — lint rules this repository holds its own source to. Deno lint
|
* `project` — lint rules this repository holds its own source to, on top of
|
||||||
* ran here with its `recommended` rules and no plugins; the Oxlint categories
|
* the Oxlint categories in `vite.config.ts`. Its rules of its own are `no-disable-comments` and `no-non-ts-imports`.
|
||||||
* in `vite.config.ts` plus the rule list below keep at least that coverage.
|
|
||||||
* Its rules of its own are `no-disable-comments` and `no-non-ts-imports`.
|
|
||||||
*
|
*
|
||||||
* Loaded by `vite.config.ts` as an Oxlint `jsPlugins` entry.
|
* Loaded by `vite.config.ts` as an Oxlint `jsPlugins` entry.
|
||||||
*
|
*
|
||||||
@@ -150,9 +148,8 @@ const noNonTsImportsRule: ProjectRule = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This repository's own rule list, spread by `vite.config.ts`: Deno's
|
* This repository's own rule list, spread by `vite.config.ts`: rules that
|
||||||
* `recommended` rules that sit outside the Oxlint categories, plus the
|
* sit outside the Oxlint categories, plus the template's extras. Built-in Oxlint rule ids sit here too, so
|
||||||
* template's extras. Built-in Oxlint rule ids sit here too, so
|
|
||||||
* `vite.config.ts` lists no rule by name.
|
* `vite.config.ts` lists no rule by name.
|
||||||
*/
|
*/
|
||||||
const rules: DummyRuleMap = {
|
const rules: DummyRuleMap = {
|
||||||
@@ -164,7 +161,7 @@ const rules: DummyRuleMap = {
|
|||||||
"^_*[^_]*_*$|^[^a-z]*$",
|
"^_*[^_]*_*$|^[^a-z]*$",
|
||||||
{ properties: false, classFields: false, onlyDeclarations: false, ignoreDestructuring: true },
|
{ properties: false, classFields: false, onlyDeclarations: false, ignoreDestructuring: true },
|
||||||
],
|
],
|
||||||
// Deno's `recommended` rules outside the categories.
|
// Rules outside the categories.
|
||||||
"no-array-constructor": "error",
|
"no-array-constructor": "error",
|
||||||
"no-case-declarations": "error",
|
"no-case-declarations": "error",
|
||||||
"no-empty": "error",
|
"no-empty": "error",
|
||||||
@@ -189,8 +186,7 @@ const rules: DummyRuleMap = {
|
|||||||
"typescript/prefer-as-const": "error",
|
"typescript/prefer-as-const": "error",
|
||||||
"typescript/prefer-namespace-keyword": "error",
|
"typescript/prefer-namespace-keyword": "error",
|
||||||
"typescript/triple-slash-reference": "error",
|
"typescript/triple-slash-reference": "error",
|
||||||
// Deno's `no-window`, `no-process-global`, and `no-node-globals`: on Node,
|
// On Node, these come from an explicit `node:` import instead of the global scope.
|
||||||
// these come from an explicit `node:` import instead of the global scope.
|
|
||||||
"no-restricted-globals": [
|
"no-restricted-globals": [
|
||||||
"error",
|
"error",
|
||||||
"window",
|
"window",
|
||||||
@@ -205,8 +201,7 @@ const rules: DummyRuleMap = {
|
|||||||
"typescript/consistent-type-imports": "error",
|
"typescript/consistent-type-imports": "error",
|
||||||
"typescript/no-import-type-side-effects": "error",
|
"typescript/no-import-type-side-effects": "error",
|
||||||
"typescript/no-non-null-assertion": "error",
|
"typescript/no-non-null-assertion": "error",
|
||||||
// Deno's `ban-untagged-ignore` and `ban-unused-ignore`, made stricter: no
|
// No disable comments at all.
|
||||||
// disable comments at all.
|
|
||||||
"project/no-disable-comments": "error",
|
"project/no-disable-comments": "error",
|
||||||
"project/no-non-ts-imports": "error",
|
"project/no-non-ts-imports": "error",
|
||||||
"unicorn/no-abusive-eslint-disable": "error",
|
"unicorn/no-abusive-eslint-disable": "error",
|
||||||
|
|||||||
Reference in New Issue
Block a user