@opendesignai/harness 0.0.0-stage → 0.1.0-alpha.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.
@@ -0,0 +1,33 @@
1
+ # od/no-raw-fetch
2
+
3
+ Preset: `base`
4
+
5
+ ## What it reports
6
+
7
+ Calls to the global `fetch()`, including `window.fetch()`, `globalThis.fetch()` and `self.fetch()`. A local or imported `fetch` (for example from `undici`) and methods named `fetch` on other objects are not reported.
8
+
9
+ ## Why
10
+
11
+ Raw `fetch` bypasses the API client: no shared base URL, auth refresh, error mapping, retries or telemetry. In opengame raw `fetch(` went from 59 to 70 call sites while the client existed.
12
+
13
+ ## How to fix
14
+
15
+ Call the endpoint through the typed API client. If the endpoint is missing there, add a typed function for it in the client first.
16
+
17
+ ## Exemptions
18
+
19
+ The API client layer itself (and server code that talks to upstream services, if the repository decides so) is exempted with an `overrides` entry in the lint config:
20
+
21
+ ```json
22
+ { "files": ["studio/src/api/**", "gateway/**"], "rules": { "od/no-raw-fetch": "off" } }
23
+ ```
24
+
25
+ Inline disable comments are rejected; existing debt stays in `oxlint-suppressions.json` and may only shrink.
26
+
27
+ ## Options
28
+
29
+ ```json
30
+ ["error", { "client": "studio/src/api/client.ts" }]
31
+ ```
32
+
33
+ `client` only changes the message text.
@@ -0,0 +1,41 @@
1
+ # od/no-raw-storage
2
+
3
+ Preset: `base`
4
+
5
+ ## What it reports
6
+
7
+ References to the global `localStorage` or `sessionStorage`, directly or as `window.` / `globalThis.` / `self.` members:
8
+
9
+ ```ts
10
+ localStorage.getItem("k");
11
+ const s = window.sessionStorage;
12
+ if (typeof sessionStorage !== "undefined") …
13
+ ```
14
+
15
+ Not reported: object keys and class fields named `localStorage`, parameters, imports and local variables that shadow the global, and type-only positions (`typeof localStorage` in a type).
16
+
17
+ ## Why
18
+
19
+ Raw storage access bypasses the storage wrapper: no key prefixing per product, no handling of quota errors or private mode, and no single place to migrate keys. Once products run inside the shell, storage goes through the shell SDK, which prefixes keys per product; every raw access is a migration hazard.
20
+
21
+ ## How to fix
22
+
23
+ Read and write through the repository's storage wrapper (in opengame/openmotion: `studio/src/utils/safeStorage.ts`). Set the `wrapper` option so the message names it.
24
+
25
+ ## Exemptions
26
+
27
+ The wrapper itself is exempted with an `overrides` entry in the lint config:
28
+
29
+ ```json
30
+ { "files": ["studio/src/utils/safeStorage.ts"], "rules": { "od/no-raw-storage": "off" } }
31
+ ```
32
+
33
+ Inline disable comments are rejected; existing debt stays in `oxlint-suppressions.json` and may only shrink.
34
+
35
+ ## Options
36
+
37
+ ```json
38
+ ["error", { "wrapper": "studio/src/utils/safeStorage.ts" }]
39
+ ```
40
+
41
+ `wrapper` only changes the message text.
@@ -0,0 +1,46 @@
1
+ # od/no-shell-imports-product
2
+
3
+ Preset: `platform-boundary`
4
+
5
+ ## What it reports
6
+
7
+ A static `import`, `export … from` or `export * from` in a **shell** file whose target resolves into a **product** directory:
8
+
9
+ ```ts
10
+ // studio/src/motion/LocaleCases.tsx (shell)
11
+ import { GameStudio } from "./game/GameStudio"; // studio/src/motion/game/ is product
12
+ ```
13
+
14
+ Not reported: `import type` / `export type` (all specifiers type-only), dynamic `import()` (the registry's lazy entry point), files that are themselves inside a product directory, and files outside `shell`.
15
+
16
+ ## Why
17
+
18
+ The platform loads products through the product registry and talks to them through the contract and shell SDK. A static import from shell into product code makes the shell bundle depend on the product, blocks moving the product into its own package, and is how boundaries erode one import at a time.
19
+
20
+ ## How to fix
21
+
22
+ Reach the product through the registry (a lazy `import()` in the registry entry) and shared contracts or the shell SDK. If the shell needs data from the product, add it to the product manifest or a contract type.
23
+
24
+ ## Exemptions
25
+
26
+ The split itself is configuration: the `shell` and `product` options in the lint config are owner-reviewed. Known edges during the migration stay in `oxlint-suppressions.json` until the boundary work removes them. Inline disable comments are rejected.
27
+
28
+ ## Options
29
+
30
+ **The rule is inactive until both `shell` and `product` are set**: enabling it through the `platform-boundary` preset alone checks nothing and reports nothing. After configuring it, check that one known shell-to-product import is reported.
31
+
32
+ ```json
33
+ [
34
+ "error",
35
+ {
36
+ "shell": ["studio/src/"],
37
+ "product": ["studio/src/motion/game/", "studio/src/super-agent/gamePublish/"],
38
+ "aliases": { "@/": "studio/src/" }
39
+ }
40
+ ]
41
+ ```
42
+
43
+ - `shell`, `product`: repo-relative path patterns. `dir/` matches the directory and everything below it; globs support `**`, `*` and `?` (`dir/**` also matches `dir`); anything else is an exact path. A file is shell when it matches `shell` and does not match `product`.
44
+ - `aliases`: import specifier prefix → repo-relative path prefix, for path aliases such as `@/`. An alias matches whole path segments: `"@"` matches `@` and `@/motion/x` but not packages such as `@scope/pkg` or `@motion/game`, and `"@/"` matches specifiers that start with `@/`. Other bare specifiers (packages) are never product paths.
45
+
46
+ Paths are relative to the directory the linter runs in, so run Oxlint from the repository root.
@@ -0,0 +1,75 @@
1
+ # od/no-swallowed-catch
2
+
3
+ Preset: `base`
4
+
5
+ ## What it reports
6
+
7
+ - An empty `catch` block (comments do not count as handling).
8
+ - `.catch(handler)` where the handler only produces `null`, `undefined`, `void …`, `false`, `{}` or `[]`, or has an empty body.
9
+
10
+ ```ts
11
+ try {
12
+ await save();
13
+ } catch {}
14
+ const state = await readState().catch(() => null);
15
+ ```
16
+
17
+ Not reported:
18
+
19
+ - a `try` block that only calls cleanup functions (`close`, `cancel`, `abort`, `destroy`, `dispose`, `release`, `rm`, `unlink`, `removeItem`, …), and `.catch()` on such a call: `body.cancel().catch(() => {})`;
20
+ - handlers that return a real fallback value (`.catch(() => defaultConfig)`);
21
+ - a handler marked with a `// fail-open: <reason>` comment inside it, or on the line of (or just above) the `catch`.
22
+
23
+ ## Why
24
+
25
+ Swallowed errors make failures invisible: a failed write followed by "success" UI, a corrupt state file silently rebuilt, telemetry that never fires. In opengame 459 such sites were counted.
26
+
27
+ ## How to fix
28
+
29
+ Log with context and report to telemetry, return an explicit error result, or rethrow. If the caller can genuinely proceed, say why in code:
30
+
31
+ ```ts
32
+ try {
33
+ await warmCache();
34
+ } catch (error) {
35
+ // fail-open: the cache only speeds up the first paint; the page loads without it
36
+ logger.warn("cache warm-up failed", { error });
37
+ }
38
+ ```
39
+
40
+ ## Exemptions
41
+
42
+ `// fail-open: <reason>` (the reason is required). Cleanup calls listed in `cleanupCallees` are allowed without a comment. Inline disable comments are rejected.
43
+
44
+ ## Options
45
+
46
+ ```json
47
+ [
48
+ "error",
49
+ {
50
+ "cleanupCallees": [
51
+ "abort",
52
+ "cancel",
53
+ "close",
54
+ "destroy",
55
+ "disconnect",
56
+ "dispose",
57
+ "kill",
58
+ "release",
59
+ "removeItem",
60
+ "revokeObjectURL",
61
+ "rm",
62
+ "rmSync",
63
+ "rmdir",
64
+ "rmdirSync",
65
+ "terminate",
66
+ "unlink",
67
+ "unlinkSync"
68
+ ]
69
+ }
70
+ ]
71
+ ```
72
+
73
+ ## Limits
74
+
75
+ The rule cannot judge whether a returned fallback is correct (`.catch(() => game)` after a failed write is still a swallowed failure); that stays a review item.
@@ -0,0 +1,35 @@
1
+ # od/no-window-bus
2
+
3
+ Preset: `base`
4
+
5
+ ## What it reports
6
+
7
+ Using the global object as an untyped event bus:
8
+
9
+ - `dispatchEvent(...)` on `window`, `document`, `globalThis` or `self` (or the bare global `dispatchEvent`);
10
+ - `new CustomEvent(...)` anywhere (reported once, on the dispatch, when it is dispatched on a global object);
11
+ - `addEventListener` / `removeEventListener` on those objects for an application event name, that is, a name containing anything other than letters (`"motion:account-changed"`, `"od-theme"`). The name may be a literal or a same-file string `const`.
12
+
13
+ Standard DOM events (`resize`, `visibilitychange`, `DOMContentLoaded`) and events on elements (`el.dispatchEvent(new Event("change"))`) are not reported.
14
+
15
+ ## Why
16
+
17
+ Global string events have no types, no single owner and no check that every event has both a sender and a listener. In opengame `window.dispatchEvent` went from 20 to 37 sites and `motion:account-changed` from 5 to 14, and dead listeners appeared.
18
+
19
+ ## How to fix
20
+
21
+ Share state through a typed store or context, or call the owning module's API. If a cross-app event is really needed, declare it in the event registry and use its typed emit/subscribe helpers.
22
+
23
+ ## Exemptions
24
+
25
+ Events declared in the registry can be listed in `allowEvents`. The registry module itself is exempted with an `overrides` entry in the lint config (owner review). Inline disable comments are rejected; existing debt stays in `oxlint-suppressions.json` and may only shrink.
26
+
27
+ ## Options
28
+
29
+ ```json
30
+ ["error", { "allowEvents": ["od:ready"] }]
31
+ ```
32
+
33
+ ## Limits
34
+
35
+ Application events whose names are plain letters (`"accountchanged"`) look like DOM events and are not reported when only listened to.
package/docs/size.md ADDED
@@ -0,0 +1,51 @@
1
+ # od-harness size
2
+
3
+ File size budget: a file should be small enough for a person or an agent to read in one go.
4
+
5
+ | Files | Budget |
6
+ | --------------------------------------------------------------------- | ----------- |
7
+ | Source (`.ts`, `.tsx`, `.js`, `.jsx`, `.mjs`, `.cjs`, `.mts`, `.cts`) | 800 lines |
8
+ | Tests (`*.test.*`, `*.spec.*`, `__tests__/`) and stylesheets (`.css`) | 1,500 lines |
9
+
10
+ Files are those git tracks plus untracked files that are not ignored. Lines are counted like `wc -l` (a last line without a newline counts too).
11
+
12
+ - **Which files count as tests**: only the name decides. A file matching `*.test.*` or `*.spec.*`, or inside a `__tests__/` directory, gets 1,500 lines. Helpers in `test/` or `tests/` directories (`test/helpers.ts`, `tests/setup.ts`) are not test files by this rule and get 800 lines like other source.
13
+ - **Which files are not counted**: every other extension. Stylesheets other than `.css` (`.scss`, `.less`), single-file components (`.vue`, `.svelte`), and `.json`, `.md`, `.html` and similar files have no budget. Generated or vendored sources with a counted extension can be excluded (see below).
14
+
15
+ ## Baseline
16
+
17
+ Files that were already over budget when the repository adopted od-harness are frozen in `.harness/size-baseline.json` at their line count:
18
+
19
+ ```json
20
+ { "files": { "studio/src/motion/game/GameStudio.tsx": 1603 } }
21
+ ```
22
+
23
+ `od-harness size` fails when:
24
+
25
+ - a file that is not in the baseline is over budget;
26
+ - a frozen file grew;
27
+ - a frozen file shrank, is back within budget, or was deleted, and the baseline was not tightened.
28
+
29
+ ## Commands
30
+
31
+ ```sh
32
+ od-harness size # check (CI)
33
+ od-harness size --update # tighten the baseline after files shrank; never raises or adds entries
34
+ od-harness size --init # adoption only: create the baseline from the current oversized files
35
+ ```
36
+
37
+ ## How to fix a failure
38
+
39
+ - **New file over budget**: split it into smaller modules by responsibility. New files cannot be added to the baseline.
40
+ - **Frozen file grew**: move the code you added, or more, into a new or existing module.
41
+ - **Baseline not tightened**: run `od-harness size --update` and commit `.harness/size-baseline.json`.
42
+
43
+ ## Exclusions
44
+
45
+ Generated or vendored sources can be excluded in `.harness/config.json` (owner review):
46
+
47
+ ```json
48
+ { "size": { "ignore": ["studio/src/generated/**"] } }
49
+ ```
50
+
51
+ Patterns are repo-relative: `dir/` matches a directory, globs support `**`, `*` and `?`. A file that is not valid JSON fails with exit code 2 and the parse error.
package/package.json CHANGED
@@ -1,6 +1,76 @@
1
1
  {
2
2
  "name": "@opendesignai/harness",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "OpenDesign harness: od/* lint rules for Oxlint (ESLint plugin format), presets, file size budget and baseline ratchet",
5
+ "keywords": [
6
+ "eslint-plugin",
7
+ "harness",
8
+ "opendesign",
9
+ "oxlint"
10
+ ],
11
+ "homepage": "https://github.com/nexu-io/od-harness#readme",
12
+ "bugs": "https://github.com/nexu-io/od-harness/issues",
13
+ "license": "Apache-2.0",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/nexu-io/od-harness.git"
17
+ },
18
+ "bin": {
19
+ "od-harness": "./dist/cli.mjs"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "presets",
24
+ "docs",
25
+ "!docs/upstream"
26
+ ],
27
+ "type": "module",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/plugin.d.mts",
31
+ "default": "./dist/plugin.mjs"
32
+ },
33
+ "./presets/*": "./presets/*",
34
+ "./package.json": "./package.json"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public",
38
+ "tag": "alpha"
39
+ },
40
+ "dependencies": {
41
+ "@eslint-community/eslint-plugin-eslint-comments": "4.8.1"
42
+ },
43
+ "devDependencies": {
44
+ "@od-harness/ts-eslint-parser": "0.0.0",
45
+ "@types/node": "26.6.11",
46
+ "@typescript-eslint/types": "8.74.0",
47
+ "eslint": "10.16.0",
48
+ "knip": "6.50.0",
49
+ "oxfmt": "0.81.0",
50
+ "oxlint": "1.96.0",
51
+ "tsdown": "0.23.8",
52
+ "typescript": "7.0.2",
53
+ "vitest": "5.1.2",
54
+ "yaml": "2.9.1"
55
+ },
56
+ "peerDependencies": {
57
+ "oxlint": "1.96.0"
58
+ },
59
+ "engines": {
60
+ "node": ">=22.18.0"
61
+ },
62
+ "scripts": {
63
+ "build": "tsdown",
64
+ "typecheck": "tsc -p .",
65
+ "test": "vitest run",
66
+ "lint": "oxlint --deny-warnings",
67
+ "format": "oxfmt",
68
+ "format:check": "oxfmt --check",
69
+ "knip": "knip",
70
+ "size": "node src/cli/index.ts size",
71
+ "smoke": "node scripts/smoke-pack.ts",
72
+ "trial": "node scripts/trial.ts",
73
+ "hit-compare": "node scripts/hit-compare.ts",
74
+ "check": "pnpm format:check && pnpm lint && pnpm size && pnpm build && pnpm typecheck && pnpm test && pnpm knip"
75
+ }
6
76
  }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": ["./rules/base.json"],
3
+ "jsPlugins": [
4
+ { "name": "od", "specifier": "../dist/plugin.mjs" },
5
+ { "name": "eslint-comments", "specifier": "../dist/eslint-comments.mjs" }
6
+ ]
7
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": ["./rules/platform-boundary.json"],
3
+ "jsPlugins": [{ "name": "od", "specifier": "../dist/plugin.mjs" }]
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": ["./rules/product.json"],
3
+ "jsPlugins": [{ "name": "od", "specifier": "../dist/plugin.mjs" }]
4
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "plugins": ["react"],
3
+ "rules": {
4
+ "react/refs": "error",
5
+ "react/set-state-in-effect": "error",
6
+ "react/immutability": "error",
7
+ "react/preserve-manual-memoization": "error",
8
+ "react/purity": "error",
9
+ "react/use-memo": "error",
10
+ "react/incompatible-library": "error",
11
+ "react/static-components": "error"
12
+ }
13
+ }
@@ -0,0 +1,47 @@
1
+ {
2
+ "options": { "reportUnusedDisableDirectives": "error" },
3
+ "plugins": ["eslint", "typescript", "unicorn", "oxc", "react"],
4
+ "categories": {
5
+ "correctness": "error"
6
+ },
7
+ "rules": {
8
+ "od/no-locale-branch": "error",
9
+ "od/no-raw-storage": "error",
10
+ "od/no-swallowed-catch": "error",
11
+ "od/no-raw-fetch": "error",
12
+ "od/no-api-path-literal": "error",
13
+ "od/no-window-bus": "error",
14
+ "od/no-process-env": "error",
15
+ "od/no-error-message-match": "error",
16
+ "od/no-cjk-literal": "error",
17
+ "od/no-constant-flag": "error",
18
+ "react/rules-of-hooks": "error",
19
+ "react/exhaustive-deps": "error",
20
+ "react/refs": "off",
21
+ "react/set-state-in-effect": "off",
22
+ "react/immutability": "off",
23
+ "react/preserve-manual-memoization": "off",
24
+ "react/purity": "off",
25
+ "react/use-memo": "off",
26
+ "react/incompatible-library": "off",
27
+ "react/static-components": "off",
28
+ "eslint-comments/no-restricted-disable": [
29
+ "error",
30
+ "od/*",
31
+ "react/rules-of-hooks",
32
+ "react-hooks/rules-of-hooks"
33
+ ]
34
+ },
35
+ "overrides": [
36
+ {
37
+ "files": [
38
+ "**/*.test.*",
39
+ "**/*.spec.*",
40
+ "**/__tests__/**",
41
+ "**/__fixtures__/**",
42
+ "**/fixtures/**"
43
+ ],
44
+ "rules": { "od/no-cjk-literal": "off" }
45
+ }
46
+ ]
47
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "rules": {
3
+ "od/no-product-literal": "error",
4
+ "od/no-shell-imports-product": "error"
5
+ }
6
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "rules": {
3
+ "od/no-product-literal": "error"
4
+ }
5
+ }