@shivaedev/quality 0.41.1 → 0.43.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/CHANGELOG.md +47 -0
- package/README.md +56 -8
- package/biome/declarations.json +5 -0
- package/biome/plugins/ambient-runtime.grit +3 -1
- package/biome/plugins/effect-test-bodies.grit +1 -1
- package/biome/preset.json +2 -2
- package/dist/appTestConfig.js +1 -1
- package/dist/appTestConfig.js.map +1 -1
- package/dist/biome/withoutEntryPointImports.d.ts +4 -0
- package/dist/biome/withoutEntryPointImports.d.ts.map +1 -0
- package/dist/biome/withoutEntryPointImports.js +46 -0
- package/dist/biome/withoutEntryPointImports.js.map +1 -0
- package/dist/imports/pnpmWorkspacePatterns.d.ts +1 -0
- package/dist/imports/pnpmWorkspacePatterns.d.ts.map +1 -1
- package/dist/imports/pnpmWorkspacePatterns.js +28 -22
- package/dist/imports/pnpmWorkspacePatterns.js.map +1 -1
- package/dist/imports/runtime.d.ts +6 -0
- package/dist/imports/runtime.d.ts.map +1 -1
- package/dist/imports/runtime.js +54 -8
- package/dist/imports/runtime.js.map +1 -1
- package/dist/manifests/entryPoints.d.ts +15 -0
- package/dist/manifests/entryPoints.d.ts.map +1 -0
- package/dist/manifests/entryPoints.js +60 -0
- package/dist/manifests/entryPoints.js.map +1 -0
- package/dist/rules/biome.d.ts.map +1 -1
- package/dist/rules/biome.js +4 -2
- package/dist/rules/biome.js.map +1 -1
- package/dist/rules/builtIn.d.ts +2 -2
- package/dist/rules/builtIn.d.ts.map +1 -1
- package/dist/rules/builtIn.js +8 -0
- package/dist/rules/builtIn.js.map +1 -1
- package/dist/rules/effect/boundary.d.ts +2 -0
- package/dist/rules/effect/boundary.d.ts.map +1 -0
- package/dist/rules/effect/boundary.js +66 -0
- package/dist/rules/effect/boundary.js.map +1 -0
- package/dist/rules/effect/layerConstructor.d.ts +3 -0
- package/dist/rules/effect/layerConstructor.d.ts.map +1 -0
- package/dist/rules/effect/layerConstructor.js +35 -0
- package/dist/rules/effect/layerConstructor.js.map +1 -0
- package/dist/rules/effect/ownsParameters.d.ts +3 -0
- package/dist/rules/effect/ownsParameters.d.ts.map +1 -0
- package/dist/rules/effect/ownsParameters.js +45 -0
- package/dist/rules/effect/ownsParameters.js.map +1 -0
- package/dist/rules/effect/program.d.ts +4 -0
- package/dist/rules/effect/program.d.ts.map +1 -0
- package/dist/rules/effect/program.js +24 -0
- package/dist/rules/effect/program.js.map +1 -0
- package/dist/rules/effect/publicFunctions.d.ts +3 -0
- package/dist/rules/effect/publicFunctions.d.ts.map +1 -0
- package/dist/rules/effect/publicFunctions.js +68 -0
- package/dist/rules/effect/publicFunctions.js.map +1 -0
- package/dist/rules/effect/serviceCatalog.d.ts +8 -0
- package/dist/rules/effect/serviceCatalog.d.ts.map +1 -0
- package/dist/rules/effect/serviceCatalog.js +56 -0
- package/dist/rules/effect/serviceCatalog.js.map +1 -0
- package/dist/rules/effect/serviceFindings.d.ts +5 -0
- package/dist/rules/effect/serviceFindings.d.ts.map +1 -0
- package/dist/rules/effect/serviceFindings.js +88 -0
- package/dist/rules/effect/serviceFindings.js.map +1 -0
- package/dist/rules/effect/serviceOrigin.d.ts +3 -0
- package/dist/rules/effect/serviceOrigin.d.ts.map +1 -0
- package/dist/rules/effect/serviceOrigin.js +85 -0
- package/dist/rules/effect/serviceOrigin.js.map +1 -0
- package/dist/rules/effect/serviceParameters.d.ts +2 -0
- package/dist/rules/effect/serviceParameters.d.ts.map +1 -0
- package/dist/rules/effect/serviceParameters.js +33 -0
- package/dist/rules/effect/serviceParameters.js.map +1 -0
- package/dist/rules/effect/serviceTypes.d.ts +8 -0
- package/dist/rules/effect/serviceTypes.d.ts.map +1 -0
- package/dist/rules/effect/serviceTypes.js +94 -0
- package/dist/rules/effect/serviceTypes.js.map +1 -0
- package/dist/rules/imports/fences.d.ts +1 -1
- package/dist/rules/imports/manifest.d.ts.map +1 -1
- package/dist/rules/imports/manifest.js +27 -14
- package/dist/rules/imports/manifest.js.map +1 -1
- package/dist/rules/imports/runtime.d.ts.map +1 -1
- package/dist/rules/imports/runtime.js +10 -4
- package/dist/rules/imports/runtime.js.map +1 -1
- package/dist/rules/manifestsApplication.d.ts +2 -0
- package/dist/rules/manifestsApplication.d.ts.map +1 -0
- package/dist/rules/manifestsApplication.js +99 -0
- package/dist/rules/manifestsApplication.js.map +1 -0
- package/dist/rules/manifestsExportsShape.d.ts.map +1 -1
- package/dist/rules/manifestsExportsShape.js +5 -2
- package/dist/rules/manifestsExportsShape.js.map +1 -1
- package/dist/rules/react/jsxConditionals.d.ts +2 -0
- package/dist/rules/react/jsxConditionals.d.ts.map +1 -0
- package/dist/rules/react/jsxConditionals.js +54 -0
- package/dist/rules/react/jsxConditionals.js.map +1 -0
- package/dist/rules/stories/engineOf.d.ts.map +1 -1
- package/dist/rules/stories/engineOf.js +3 -2
- package/dist/rules/stories/engineOf.js.map +1 -1
- package/dist/rules/stories/namedValues.js +4 -4
- package/dist/rules/stories/namedValues.js.map +1 -1
- package/package.json +3 -3
- package/src/appTestConfig.ts +1 -1
- package/src/biome/withoutEntryPointImports.ts +52 -0
- package/src/imports/pnpmWorkspacePatterns.ts +29 -22
- package/src/imports/runtime.ts +69 -9
- package/src/manifests/entryPoints.ts +87 -0
- package/src/rules/biome.ts +4 -2
- package/src/rules/builtIn.ts +8 -0
- package/src/rules/effect/boundary.ts +75 -0
- package/src/rules/effect/layerConstructor.ts +40 -0
- package/src/rules/effect/ownsParameters.ts +46 -0
- package/src/rules/effect/program.ts +26 -0
- package/src/rules/effect/publicFunctions.ts +70 -0
- package/src/rules/effect/serviceCatalog.ts +57 -0
- package/src/rules/effect/serviceFindings.ts +96 -0
- package/src/rules/effect/serviceOrigin.ts +94 -0
- package/src/rules/effect/serviceParameters.ts +35 -0
- package/src/rules/effect/serviceTypes.ts +101 -0
- package/src/rules/imports/manifest.ts +42 -14
- package/src/rules/imports/runtime.ts +10 -4
- package/src/rules/manifestsApplication.ts +117 -0
- package/src/rules/manifestsExportsShape.ts +6 -2
- package/src/rules/react/jsxConditionals.ts +59 -0
- package/src/rules/stories/engineOf.ts +3 -2
- package/src/rules/stories/namedValues.ts +4 -4
- package/tsconfig/package.json +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.43.0 - 2026-10-28
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- The application host provides Effect's native Crypto service during preflight and deferred construction as well as in application handlers, so commands can generate secure invite codes without ambient randomness.
|
|
8
|
+
- Story kits provide native TestCrypto with a fresh seed of 0 for each story, making generated invite codes reproducible. The application’s @effect/platform-node peer supplies its digest implementation.
|
|
9
|
+
- Ambient-randomness findings name Effect's Crypto service for secure values and Random for non-secure values.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Keep Biome's `useIncludes` findings while disabling its automatic fix, so formatting leaves `indexOf` comparisons for developers to change by hand.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- Enforce declared query read policies at the hosted RPC handler boundary, including contracts without identity middleware, whose viewer is anonymous. Query RPC error schemas include `QueryReadDenied` so native clients receive typed refusals before handlers run.
|
|
18
|
+
- Keep collection methods and untyped schema internals from making data parameters appear to carry callable services. Direct service implementations, nested dependency fields and service arrays remain subject to `effect/service-parameters`.
|
|
19
|
+
- Pure unit tests can import `effect/http/HttpStatus` without being reported as network I/O; HTTP client imports still require a story.
|
|
20
|
+
- Recognize service implementation parameters by their declared service shape instead of incidental assignability to a discovered service. Ordinary atoms, schemas, records and tuples no longer count as services; service tags, class instances, implementation shapes and non-empty Contexts remain checked.
|
|
21
|
+
|
|
22
|
+
### Breaking
|
|
23
|
+
|
|
24
|
+
- Enforce `effect/boundary` across source, tooling and specs: async, await, new Promise, .then, try and throw belong only in `adapters/` and `test-support/` folders at any depth. Use Effect and tagged failures elsewhere. The fixed `adapters/` convention bridges outside libraries to Effect values without consumer configuration.
|
|
25
|
+
- Enforce `effect/service-parameters`: exported functions and public methods read services from Effect's environment, including aliased and wrapped implementation shapes. Effect and Stream requirements, service implementation methods and Layer constructors are accepted; only `test-support/` is exempt. Adapters still follow this rule and ambient runtime bans. Both rules refuse config exceptions and inline suppressions. Consumers adopting the upgrade record existing debt with `quality baseline write --rule effect/boundary` and `quality baseline write --rule effect/service-parameters`.
|
|
26
|
+
- Apps get new findings from `react/jsx-conditionals` for `&&` and ternaries in JSX children. Decide before the JSX with early returns or a precomputed variable, or extract a component that returns `null`; inside `.map`, extract an item component. Attribute values remain accepted. Record existing findings with `quality baseline write --rule react/jsx-conditionals`. The shared Biome preset turns off `noLeakedRender`, whose ternary repair is also reported by the new rule.
|
|
27
|
+
- Move key imports from `@shivaedev/contract/keys.ts` to `@shivaedev/changes/keys.ts`. Declare bucket fields with `collection(name, idSchema, fields)` and publish affected buckets alongside record keys.
|
|
28
|
+
- Replace collection policy maps, `mergeReadPolicies`, `ReadPolicy` and `ReadPolicyMemoWindow` with each query's `readPolicy(payload, viewer)`. Declare the same query's live scope with `reads(payload, viewer)`. Bound query atoms and subscriptions refuse missing policies with a declaration error; one-off query `run` calls remain available. Denied queries refuse the entire subscription. Server adapters replace `QueryReads` and `ChangesReads` with `QueryDefinition` and `ChangesQueries`. Custom middleware calls `authorizeReads(effect, request, viewer)` and declares `MissingReadPolicy` and `QueryReadDenied` errors.
|
|
29
|
+
- Custom subscription adapters yield `ChangesQueries.resolve(references)`, call `querySubscription(requests, viewer)` and pass the authorized result to `makeLiveServer.subscribe(subscription, context)`. Metadata values expose `QueryDefinition.definition` and `CommandInvalidation.invalidates` instead of bare definitions and callbacks. Yield the Effect returned by `queryKeys(queries, references)` when projecting keys for a custom stream. `resolveChanges` supplies the authorized subscription in hosted applications. Changed hints can carry query positions so bindings can rerun session-scoped reads without deriving session scopes in the browser.
|
|
30
|
+
- Remove `appHost`'s `readPolicy` option and module policy registration. Session and permission middleware apply query policies using the current session viewer. Handle the new typed policy errors in native clients, including `QueryReadDenied` on query RPCs without identity middleware; widen explicit query error annotations accordingly.
|
|
31
|
+
- Replace `sessionCommandChanges` with `commandChanges` for custom session middleware. Command invalidation callbacks can receive the session viewer as their third argument. Announce viewer buckets there; background writers must explicitly publish those bucket keys after commit.
|
|
32
|
+
- Built-in admin queries declare their permission policies alongside their schemas and read scopes. Consumers keep supplying the existing session and permission middleware layers.
|
|
33
|
+
- Local Work Board and Fleet queries declare their existing loopback read access explicitly so their generated live subscriptions remain available.
|
|
34
|
+
- Bare HTTP status literals in tests are now reported by `tests/named-values`. Import `HttpStatus` from `effect/http/HttpStatus` and write `HttpStatus.fromLiteral("NotFound")` instead of `404`. Subjects named `status` or `code` no longer exempt numeric assertions; process `exitCode` literals remain accepted.
|
|
35
|
+
|
|
36
|
+
## 0.42.0 - 2026-10-27
|
|
37
|
+
|
|
38
|
+
### Added
|
|
39
|
+
|
|
40
|
+
- A package whose code all runs in one runtime declares it in its manifest with `"quality": { "runtime": "server" }` or `"client"`. `imports/runtime` then treats every source file as that runtime without `src/server/` or `src/client/` folders, and reports a declaration beside runtime folders or an unknown value on the manifest.
|
|
41
|
+
- `manifests/exports-shape` accepts a package without modules, such as a dependency shell, whose exports hold only exact assets like `./package.json`.
|
|
42
|
+
- Applications, packages that depend on `@shivaedev/platform`, import the pieces their entry points bring by their own names: `imports/manifest` and the `biome` rule's undeclared-dependency check accept a piece that `@shivaedev/platform` brings for any code or `@shivaedev/test-story` brings for test code, and a private package missing that entry point is told which one to add.
|
|
43
|
+
- `manifests/application` asks an application for `publicHoistPattern: ["@shivaedev/*"]` in its nearest `pnpm-workspace.yaml` and rejects a dependency entry beside the entry point that already brings it.
|
|
44
|
+
|
|
45
|
+
### Changed
|
|
46
|
+
|
|
47
|
+
- `@shivaedev/quality/tsconfig/package.json` resolves modules as `NodeNext`, so package builds emit declarations whose relative imports name resolvable files. Remove per-package `module` and `moduleResolution` overrides from build configs; type-checking through `tsconfig/base.json` is unchanged.
|
|
48
|
+
- `appTestConfig` inlines every `@shivaedev` package for the test server instead of `@shivaedev/platform` alone, because an application now imports each framework piece by its own name.
|
|
49
|
+
|
|
3
50
|
## 0.41.1 - 2026-10-26
|
|
4
51
|
|
|
5
52
|
### Changed
|
package/README.md
CHANGED
|
@@ -29,6 +29,16 @@ Exceptions apply first, then the baseline. With the default rule settings, remai
|
|
|
29
29
|
|
|
30
30
|
The work has three parts: connect the repository to the shared tools once; describe an import boundary when its architecture needs one; run the gate and repair findings every day. Writing local rules is not an adoption requirement.
|
|
31
31
|
|
|
32
|
+
### Effect boundaries and services
|
|
33
|
+
|
|
34
|
+
`effect/boundary` checks every TypeScript or JavaScript source in Quality's inventory, including shipped code, tooling and specs. It reports async functions, methods and arrows, await (including `for await`), `new Promise(...)`, `.then(...)`, try statements and throw statements. Model the work with Effect, fail with a tagged error, and use `Effect.die` for defects. Effect's resource and finalizer primitives model cleanup.
|
|
35
|
+
|
|
36
|
+
Only folders named `adapters/` or `test-support/`, at any depth, are exempt from this boundary rule. An `adapters/` folder bridges an outside library and hands the rest of the application Effect values. The name is fixed by convention, with no config or copied Biome plugin globs. Code that cannot be Effect belongs in that bridge or calls for a better Effect primitive. Adapter code still follows `effect/service-parameters` and the ambient time, randomness, console and environment bans.
|
|
37
|
+
|
|
38
|
+
`effect/service-parameters` reports parameters carrying a service in exported functions and public methods, including returned factories. It follows service classes and tags, non-empty Contexts and service implementation shapes through aliases, interfaces, generic constraints, inferred parameters and destructuring. Read services from Effect's environment instead. An Effect or Stream requiring a service is a computation and is accepted. Methods implementing a service and functions constructing Layers may take services as parameters. Only `test-support/` folders are exempt from this rule; `adapters/` folders are checked.
|
|
39
|
+
|
|
40
|
+
Both rules refuse config exceptions and inline suppressions. Record existing debt with `quality baseline write --rule effect/boundary` and `quality baseline write --rule effect/service-parameters`; the normal report and baseline burn-down apply.
|
|
41
|
+
|
|
32
42
|
### 1. Once per repository: connect the shared policy
|
|
33
43
|
|
|
34
44
|
A new repository needs no `quality.config.ts`. Quality checks sources from the current directory with every built-in rule at its default error level. Baseline entries for `packages/<package>/...` live in `packages/<package>/quality-baseline.jsonl`; entries outside packages live in the root `quality-baseline.jsonl`. A package with no entries has no shard file. Permanent exceptions belong in `quality.config.ts`.
|
|
@@ -102,11 +112,15 @@ An app says where its code runs through folder names. A package adopts the runti
|
|
|
102
112
|
|
|
103
113
|
`imports/runtime` rejects client imports of server code or Node built-ins. Shared code may import neither client nor server code, use browser globals such as `window`, `document` or `localStorage`, or import Node built-ins. Both client and server code may import shared code. The check includes type imports and re-exports and resolves aliases through the shared import graph. Locally bound names and property names are not browser globals; portable web APIs such as `URL`, `fetch` and `AbortController` remain available to shared code. Test files and `test-support/` ship nowhere and are outside this runtime policy.
|
|
104
114
|
|
|
105
|
-
A package
|
|
115
|
+
A package whose code all runs in one runtime declares it in its manifest instead of nesting everything in one folder: `"quality": { "runtime": "server" }` makes every source file server code, and `"client"` makes every file browser code. Package-root tooling stays server code. A declaration beside `src/client/` or `src/server/` is reported on the manifest, as is any value other than `"client"` or `"server"`; choose one convention per package.
|
|
116
|
+
|
|
117
|
+
A package with a nonempty `bin` entry and no runtime folders is server code throughout. Runtime folders take precedence when a package also ships browser code. A Node library without a CLI declares `"runtime": "server"` or uses `src/server/`; `engines.node` alone does not say that a package is Node-only. Packages without runtime folders or a `bin` entry retain their existing source policies. Existing explicit fences continue to run in every package. Runtime folders are detected independently of `sources`, including empty folders; `sources` still selects the code that is checked.
|
|
106
118
|
|
|
107
119
|
Tooling is server code in every package, including the workspace root: files under its top-level `script/`, `scripts/` and `tooling/` folders, and top-level JavaScript or TypeScript config files such as `vitest.config.ts`. A tooling folder or config file nested under `src/` follows the source runtime policy. Browser and shared code cannot import package-root tooling.
|
|
108
120
|
|
|
109
|
-
The manifest owns ordinary workspace dependencies.
|
|
121
|
+
The manifest owns ordinary workspace dependencies. An **application** is a package whose manifest depends on `@shivaedev/platform`, the dependency shell that brings every runtime piece of the ShivaeDev framework. It imports each piece by its own name without listing it: `imports/manifest` and the `biome` rule's undeclared-dependency check count an import as declared when an entry point the application declares lists the piece among its dependencies. `@shivaedev/platform` is the entry point for any code and `@shivaedev/test-story` for test code, tooling and test support only. When a private package's import would be covered by an entry point it lacks, the finding names the entry point to add. `manifests/application` asks an application for `publicHoistPattern: ["@shivaedev/*"]` in the nearest `pnpm-workspace.yaml`, searching upward from the package, because pnpm does not link the pieces where the application can resolve them otherwise. It also rejects a dependency entry beside the entry point that already brings it, such as `@shivaedev/sql` beside `@shivaedev/platform`, and names the entry to remove. A library never depends on platform, so it declares every piece it imports.
|
|
122
|
+
|
|
123
|
+
When a package promises more, put `quality.fences.config.ts` beside its `package.json`, exporting an array of fences as the default. Quality discovers this file at the repository root and in workspace packages, even when `sources` includes only their source folders. The root config does not list boundary files.
|
|
110
124
|
|
|
111
125
|
A **fence** is a prohibition on imports, with a reason and one illegal and one legal example. Quality validates all discovered fences together, so duplicate names or contradictory examples stop the run. An unreadable file or invalid default export also stops the run. Fences remain an internal `imports/fences` module of Quality and use its shared import graph, resolver and report.
|
|
112
126
|
|
|
@@ -154,7 +168,7 @@ Every package tests its real engine through its own story kit, so setup and acti
|
|
|
154
168
|
|
|
155
169
|
Quality's `tests/story-setup` rule reports top-level test functions named with the words `seed`, `make`, `build` or `setup`, and fixture-writing calls imported from Node's `fs` or `fs/promises`. It leaves source and `test-support/` files alone. This is a check for those syntax patterns; a passing test file still needs review of what it tests.
|
|
156
170
|
|
|
157
|
-
Specs keep expectations visible. `tests/spec-helpers` moves all module-level helper functions out of specs and into the kit; `tests/no-expect-in-support` moves `expect` calls into the spec, except in test-support files that register tests at module top level and are not imported by any module, so nested Vitest runs can execute them as test files with real assertions. `tests/named-values` rejects numeric literals passed to `toBe` or `toHaveLength` in specs, except zero and
|
|
171
|
+
Specs keep expectations visible. `tests/spec-helpers` moves all module-level helper functions out of specs and into the kit; `tests/no-expect-in-support` moves `expect` calls into the spec, except in test-support files that register tests at module top level and are not imported by any module, so nested Vitest runs can execute them as test files with real assertions. `tests/named-values` rejects numeric literals passed to `toBe` or `toHaveLength` in specs, except zero and process exit codes asserted on an `exitCode` subject: assert the observed items or use a domain name that comes from the story's inputs or the product. For HTTP statuses, import `* as HttpStatus` from `effect/http/HttpStatus` and use `HttpStatus.fromLiteral("NotFound")`; subjects named `status` or `code` do not exempt numeric assertions. A spec-local numeric const that only feeds these matchers is reported, including aliases for zero and codes. `tests/no-limit-imports` rejects importing `MAX_*` constants from a `limits` module into specs, so a story proves behavior instead of copying an implementation cap.
|
|
158
172
|
|
|
159
173
|
`boundaries/queue-sql` rejects SQL mentioning the private `pgboss.` schema. Apps use their queue definitions and let workers process jobs; there is no queue-purge API by design. `boundaries/auth-sql` rejects SQL accessing Better Auth's `user`, `account`, `session` and `verification` tables. Apps use platform's auth API; `options.owners` names platform's own auth implementation and its migrations. These rules inspect SQL templates, literal query calls and query variables, and inventoried `.sql` files. They do not evaluate arbitrary runtime SQL construction.
|
|
160
174
|
|
|
@@ -217,12 +231,46 @@ Git calls `quality baseline merge <ancestor> <current> <other>`. Entries are key
|
|
|
217
231
|
- **Structure:** `structure/max-lines` allows 150 lines in a source file and 300 in test code, `nesting/max-depth` rejects lines indented eight tabs deep, and `structure/no-barrel` rejects `index` modules. The preset rejects every re-export, types included; when `noExportedImports` suggests `export … from`, import the name where it is used instead. A module does one job.
|
|
218
232
|
- **Comments:** the `comments/*` rules reject JSDoc, TODOs, banners, line and pull request references, environment pragmas and more than two comments per file. A comment says why, never what the code already says or what it used to be. A tool pragma such as `@jsxImportSource` counts as a comment until both `comments/no-jsdoc` and `comments/max-per-file` list its tag in their `allow` option.
|
|
219
233
|
- **Suppressions:** the `suppressions/*` rules reject inline lint and compiler directives, casts through `unknown`, `any` or `never`, Biome settings that weaken a check, recommended Biome rules the preset leaves below `error`, and `ignoreDeprecations`. None of them takes exceptions. A type test (`*.typecheck.test.ts`) may use `@ts-expect-error`; a test that must pass a rejected value at run time calls the API through `Reflect.apply`.
|
|
220
|
-
- **Imports:** cycles, unresolvable imports, workspace imports missing from the manifest, relative imports that leave their folder, production imports of test code, runtime folders and fences, as described above.
|
|
234
|
+
- **Imports:** cycles, unresolvable imports, workspace imports missing from the manifest or an entry point, relative imports that leave their folder, production imports of test code, runtime folders and fences, as described above.
|
|
221
235
|
- **Names and files:** the Biome preset's naming rules and plugins, and the `files/*` rules, which name a file after its main export with its folders as the prefix. No naming rule renames anything; the author picks the name. A name an outside system owns, such as a query parameter or an environment variable, is written as a quoted key, which the naming rules skip. A `Schema.Struct` field stays camelCase even when quoted and maps to the outside name with `Schema.encodeKeys`. Biome's naming messages print only a pattern: spell acronyms as words (`HttpClient`, `userId`, `parseUrl`) rather than turning off `strictCase` as its hint suggests, give a type no `I` prefix, and name a type parameter `T`, `T` plus a PascalCase name (`TItem`), or Effect's `A`, `E` and `R`. No rule checks these, so review does: a boolean reads as a question (`isOpen`, `canRetry`) unless the DOM or React names it (`open`, `disabled`); a schema shares its name with its type (`type Item = typeof Item.Type`); an unused parameter is removed rather than renamed with the `_` prefix TypeScript accepts. The naming rules take repository facts: `toolOwned` lists `.gitignore` patterns whose names a tool fixes, and a configured list extends the rule's defaults, so list only repository-specific additions; `content` lists snake_case content folders and files; `tests/follow` and `tests/colocated` take `suites` for test folders with their own layout, such as a Playwright suite.
|
|
236
|
+
- **React:** `react/jsx-conditionals` reports `&&` and ternaries in JSX children, including nested decisions. Decide before the JSX or extract a component that receives the data and returns `null` when it has nothing to show. Inside `.map`, extract an item component that makes its own decision. Conditional attributes such as `className` are accepted. This rule owns the check, so the shared Biome preset leaves `noLeakedRender` off.
|
|
222
237
|
- **Tests:** `tests/follow` and `tests/colocated` keep a test beside the code it covers, named `<file>[.<modifier>].test.ts` or `<behaviour>[.<modifier>].spec.ts` with at most one modifier of `dom`, `slow`, `typecheck` and `unit`; a unit test runs without the DOM, so `.unit.dom` is rejected. `tests/colocated` always treats `__tests__/` as a test folder. It treats `test/`, `tests/` and `spec/` as test folders only when their directly contained checked files are all tests or test support; a product folder with source beside its specs is an ordinary source folder. Declared `suites` keep their own layout. Shared test support belongs in `test-support/`, the sanctioned test-only folder. A test covering a whole module may sit at its root or directly beside its folder. The story rules above keep setup in the kit.
|
|
223
|
-
- **Manifests:** `manifests/sorted` keeps every `package.json` in sort-package-json order, and `manifests/source-first` puts the `source` condition first in `exports` and `imports`. `manifests/exports-shape` checks the package root and workspace members with exports. They use one file-preserving TypeScript wildcard: for example, `./*.ts` maps to `./src/*.ts`, `./dist/*.d.ts` and `./dist/*.js` under `source`, `types` and `default`. A subtree pattern such as `./server/*.ts` keeps that same subtree in its targets. An optional root entry, exact-path non-code assets such as JSON presets, `./package.json` and `null` blocks are allowed. Import each module at its path under `src/`; named aliases, flattened paths, per-file module lists and additional non-null wildcards fail.
|
|
238
|
+
- **Manifests:** `manifests/sorted` keeps every `package.json` in sort-package-json order, and `manifests/source-first` puts the `source` condition first in `exports` and `imports`. `manifests/exports-shape` checks the package root and workspace members with exports. They use one file-preserving TypeScript wildcard: for example, `./*.ts` maps to `./src/*.ts`, `./dist/*.d.ts` and `./dist/*.js` under `source`, `types` and `default`. A subtree pattern such as `./server/*.ts` keeps that same subtree in its targets. An optional root entry, exact-path non-code assets such as JSON presets, `./package.json` and `null` blocks are allowed. A package without modules, such as a dependency shell, exports only exact assets and needs no wildcard. Import each module at its path under `src/`; named aliases, flattened paths, per-file module lists and additional non-null wildcards fail. `manifests/application` keeps an application on its entry points, as described above.
|
|
224
239
|
- **Biome:** the `biome` rule reports Biome's error findings as `biome/<category>`. A Biome run that fails without an error finding, such as one whose config leaves no file to check, fails lint and fix with Biome's message. The preset leaves out the `.worktrees` folder at the root, so a checkout does not lint its linked worktrees, while a worktree inside it lints all of its own files. The preset's plugins ban ambient time, randomness, `console` and `process.env` in favour of Effect's services.
|
|
225
240
|
|
|
241
|
+
### Decide before JSX
|
|
242
|
+
|
|
243
|
+
Replace a child decision such as `<section>{ready && <Content />}</section>` with an early return:
|
|
244
|
+
|
|
245
|
+
```tsx
|
|
246
|
+
function Panel({ ready }) {
|
|
247
|
+
if (!ready) return null;
|
|
248
|
+
return <section><Content /></section>;
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Replace `<section>{ready ? <Content /> : <Loading />}</section>` with content computed above the return:
|
|
253
|
+
|
|
254
|
+
```tsx
|
|
255
|
+
function Panel({ ready }) {
|
|
256
|
+
const content = ready ? <Content /> : <Loading />;
|
|
257
|
+
return <section>{content}</section>;
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Replace `<ul>{items.map(item => item.visible ? <li key={item.id}>{item.name}</li> : null)}</ul>` with an item component that receives the data and returns `null`:
|
|
262
|
+
|
|
263
|
+
```tsx
|
|
264
|
+
function Item({ item }) {
|
|
265
|
+
if (!item.visible) return null;
|
|
266
|
+
return <li>{item.name}</li>;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function List({ items }) {
|
|
270
|
+
return <ul>{items.map(item => <Item key={item.id} item={item} />)}</ul>;
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
226
274
|
### API
|
|
227
275
|
|
|
228
276
|
Import names from their defining module; there is no root entry. The package's `./*.ts` export pattern also exposes the gate's implementation modules; the following table lists the config, tool and extension entry points:
|
|
@@ -303,7 +351,7 @@ pnpm add --save-dev @shivaedev/quality @effect/platform-node@4.0.5 @effect/platf
|
|
|
303
351
|
|
|
304
352
|
Node 24 or later is required. The CLI loads the TypeScript config through Node's native import; use erasable syntax and `.ts` extensions for relative TypeScript imports.
|
|
305
353
|
|
|
306
|
-
The package includes `@shivaedev/quality/biome/preset.json`, `@shivaedev/quality/tsconfig/base.json` for type-checking with `noEmit`, and `@shivaedev/quality/tsconfig/package.json` for package builds, which adds declarations, maps and `rewriteRelativeImportExtensions` so relative `.ts` imports are emitted as `.js`. Read the preset files for their settings. The preset's plugins load from `./node_modules/@shivaedev/quality/biome/preset.json/plugins`, so install the package at the repository root. Biome sorts a specifier that starts with `#`, `@/`, `~`, `$` or `%` as an alias; a tsconfig path such as `@app/*` sorts with the packages and Biome's `noUndeclaredDependencies` takes it for one, so name aliases in a form Biome recognizes.
|
|
354
|
+
The package includes `@shivaedev/quality/biome/preset.json`, `@shivaedev/quality/tsconfig/base.json` for type-checking with `noEmit`, and `@shivaedev/quality/tsconfig/package.json` for package builds, which adds declarations, maps and `rewriteRelativeImportExtensions` so relative `.ts` imports are emitted as `.js`, and resolves modules as `NodeNext` so emitted declarations name the files Node and TypeScript consumers resolve. Type-checking stays on `bundler` resolution, so an emit problem surfaces in the build rather than in `tsc --noEmit`. Read the preset files for their settings. The preset's plugins load from `./node_modules/@shivaedev/quality/biome/preset.json/plugins`, so install the package at the repository root. Biome sorts a specifier that starts with `#`, `@/`, `~`, `$` or `%` as an alias; a tsconfig path such as `@app/*` sorts with the packages and Biome's `noUndeclaredDependencies` takes it for one, so name aliases in a form Biome recognizes.
|
|
307
355
|
|
|
308
356
|
The TypeScript base leaves `types`, `jsx`, `paths`, `include` and output directories to each project. A project that needs more built-ins, such as the DOM, sets `lib` itself and keeps `ESNext` in it. A package that type-checks its tests with one config and builds `src` with another extends both, the package preset last:
|
|
309
357
|
|
|
@@ -335,7 +383,7 @@ import { appTestConfig } from "@shivaedev/quality/appTestConfig.ts";
|
|
|
335
383
|
export default appTestConfig();
|
|
336
384
|
```
|
|
337
385
|
|
|
338
|
-
Use this in `vitest.config.ts`. It composes `testProjects` with browser and server resolution and inlines
|
|
386
|
+
Use this in `vitest.config.ts`. It composes `testProjects` with browser and server resolution and inlines the `@shivaedev` packages for the test server, since an application imports each framework piece by its own name. Both helpers accept extra export conditions for workspace development: `appViteConfig(plugins, ["source"])` and `appTestConfig(["source"])`. Published apps use the defaults.
|
|
339
387
|
|
|
340
388
|
For Vitest, install `vitest`, and add `@shivaedev/test-story` and `happy-dom` when the repository has DOM tests, then use:
|
|
341
389
|
|
|
@@ -376,7 +424,7 @@ export default defineConfig({
|
|
|
376
424
|
|
|
377
425
|
A skipped test proves nothing. `noSkippedTests` reports unconditional skips as errors, and its automatic fix is disabled: repair the test or remove a claim it cannot prove. Slow tests belong in the slow project.
|
|
378
426
|
|
|
379
|
-
The **PostgreSQL URL gate** is the only permitted skip convention: a test that needs real PostgreSQL registers conditionally on its `
|
|
427
|
+
The **PostgreSQL URL gate** is the only permitted skip convention: a test that needs real PostgreSQL registers conditionally on its `PLATFORM_*_TEST_DATABASE_URL`. Skip only when that URL is absent; with a URL, execute the body against PostgreSQL and let connection or setup failures fail the test. Nothing else may skip. Keep the condition next to the database setup, either in the test file or its shared `test-support` module:
|
|
380
428
|
|
|
381
429
|
```ts
|
|
382
430
|
import { test } from "vitest";
|
package/biome/declarations.json
CHANGED
|
@@ -51,5 +51,10 @@
|
|
|
51
51
|
"includes": ["**"],
|
|
52
52
|
"reason": "An inline style is the right tool for a value computed at run time, such as a position, a transform or a drag offset.",
|
|
53
53
|
"rule": "lint/nursery/noInlineStyles"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"includes": ["**"],
|
|
57
|
+
"reason": "react/jsx-conditionals owns conditional rendering in JSX children and asks for decisions before JSX or extracted components; noLeakedRender suggests a ternary that the Quality rule also rejects.",
|
|
58
|
+
"rule": "lint/suspicious/noLeakedRender"
|
|
54
59
|
}
|
|
55
60
|
]
|
|
@@ -6,7 +6,9 @@ or {
|
|
|
6
6
|
`Date.now()` as $match,
|
|
7
7
|
`new Date()` as $match
|
|
8
8
|
} where { register_diagnostic(span=$match, message="Ambient time is banned. Read time through Effect's Clock service.") },
|
|
9
|
-
`Math.random()` as $match where {
|
|
9
|
+
`Math.random()` as $match where {
|
|
10
|
+
register_diagnostic(span=$match, message="Ambient randomness is banned. Use Effect's Crypto service for secure values and Random for non-secure values.")
|
|
11
|
+
},
|
|
10
12
|
or {
|
|
11
13
|
`console.$method($...)` as $match,
|
|
12
14
|
`console[$method]($...)` as $match
|
|
@@ -8,5 +8,5 @@ language js(typescript, jsx)
|
|
|
8
8
|
`Effect.gen(function* () { $... })`,
|
|
9
9
|
JsFunctionBody(statements=[JsReturnStatement(argument=`Effect.gen(function* () { $... })`)])
|
|
10
10
|
},
|
|
11
|
-
register_diagnostic(span=$callback, message="A test body that is only Effect.gen is the generator itself: pass the function* to the test, as in it.effect('loads the item', function* () { ... }), and the test helper runs it with Effect.gen. @shivaedev/
|
|
11
|
+
register_diagnostic(span=$callback, message="A test body that is only Effect.gen is the generator itself: pass the function* to the test, as in it.effect('loads the item', function* () { ... }), and the test helper runs it with Effect.gen. @shivaedev/test/it.ts provides an it whose effect and live testers take one.")
|
|
12
12
|
}
|
package/biome/preset.json
CHANGED
|
@@ -358,7 +358,7 @@
|
|
|
358
358
|
}
|
|
359
359
|
},
|
|
360
360
|
"useIframeSandbox": "error",
|
|
361
|
-
"useIncludes": "error",
|
|
361
|
+
"useIncludes": { "fix": "none", "level": "error" },
|
|
362
362
|
"useNamedCaptureGroup": "error",
|
|
363
363
|
"useNamedLayer": "error",
|
|
364
364
|
"usePromiseRejectErrors": "error",
|
|
@@ -562,7 +562,7 @@
|
|
|
562
562
|
"noImportantInKeyframe": "error",
|
|
563
563
|
"noIrregularWhitespace": "error",
|
|
564
564
|
"noLabelVar": "error",
|
|
565
|
-
"noLeakedRender": "
|
|
565
|
+
"noLeakedRender": "off",
|
|
566
566
|
"noMisleadingCharacterClass": "error",
|
|
567
567
|
"noMisleadingInstantiator": "error",
|
|
568
568
|
"noMisrefactoredShorthandAssign": "error",
|
package/dist/appTestConfig.js
CHANGED
|
@@ -4,7 +4,7 @@ export function appTestConfig(conditions = []) {
|
|
|
4
4
|
return defineConfig({
|
|
5
5
|
resolve: { conditions: [...conditions, "module", "browser", "development|production"] },
|
|
6
6
|
ssr: { resolve: { conditions: [...conditions, "node", "development|production"] } },
|
|
7
|
-
test: { ...testProjects(), server: { deps: { inline: [
|
|
7
|
+
test: { ...testProjects(), server: { deps: { inline: [/^@shivaedev\//u] } } },
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=appTestConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appTestConfig.js","sourceRoot":"","sources":["../src/appTestConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,UAAU,aAAa,CAAC,UAAU,GAAa,EAAE;IACtD,OAAO,YAAY,CAAC;QACnB,OAAO,EAAE,EAAE,UAAU,EAAE,CAAC,GAAG,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,wBAAwB,CAAC,EAAE;QACvF,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,CAAC,GAAG,UAAU,EAAE,MAAM,EAAE,wBAAwB,CAAC,EAAE,EAAE;QACnF,IAAI,EAAE,EAAE,GAAG,YAAY,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"appTestConfig.js","sourceRoot":"","sources":["../src/appTestConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,UAAU,aAAa,CAAC,UAAU,GAAa,EAAE;IACtD,OAAO,YAAY,CAAC;QACnB,OAAO,EAAE,EAAE,UAAU,EAAE,CAAC,GAAG,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,wBAAwB,CAAC,EAAE;QACvF,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,CAAC,GAAG,UAAU,EAAE,MAAM,EAAE,wBAAwB,CAAC,EAAE,EAAE;QACnF,IAAI,EAAE,EAAE,GAAG,YAAY,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,gBAAgB,CAAC,EAAE,EAAE,EAAE;KAC7E,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RuleInputs } from "#rule.ts";
|
|
2
|
+
import type { Diagnostic } from "./report.ts";
|
|
3
|
+
export declare function withoutEntryPointImports(readText: RuleInputs["readText"], diagnostics: readonly Diagnostic[]): Promise<readonly Diagnostic[]>;
|
|
4
|
+
//# sourceMappingURL=withoutEntryPointImports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withoutEntryPointImports.d.ts","sourceRoot":"","sources":["../../src/biome/withoutEntryPointImports.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA2C9C,wBAAsB,wBAAwB,CAAC,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,EAAE,WAAW,EAAE,SAAS,UAAU,EAAE,GAAG,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,CAGnJ"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { posix } from "node:path";
|
|
2
|
+
import { isTooling } from "#imports/isTooling.ts";
|
|
3
|
+
import { entryPointsOf, isApplication, provider } from "#manifests/entryPoints.ts";
|
|
4
|
+
import { isTestCode } from "#naming/testName.ts";
|
|
5
|
+
const UNDECLARED = "lint/correctness/noUndeclaredDependencies";
|
|
6
|
+
const DEPENDENCY = /^Dependency (?<name>\S+) isn't specified in /u;
|
|
7
|
+
function parsed(text) {
|
|
8
|
+
if (text === undefined) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
return JSON.parse(text);
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async function ownerOf(readText, path) {
|
|
19
|
+
let directory = posix.dirname(path);
|
|
20
|
+
for (;;) {
|
|
21
|
+
const manifest = parsed(await readText(posix.join(directory, "package.json")));
|
|
22
|
+
if (manifest !== undefined || directory === ".") {
|
|
23
|
+
return { directory, manifest };
|
|
24
|
+
}
|
|
25
|
+
directory = posix.dirname(directory);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async function brought(readText, diagnostic) {
|
|
29
|
+
const name = DEPENDENCY.exec(diagnostic.message)?.groups?.name;
|
|
30
|
+
const path = diagnostic.location.path;
|
|
31
|
+
if (diagnostic.category !== UNDECLARED || name === undefined || path === undefined) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const owner = await ownerOf(readText, path);
|
|
35
|
+
if (!isApplication(owner.manifest)) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
const entryPoints = await entryPointsOf({ readText }, owner.directory, owner.manifest, new Map());
|
|
39
|
+
const development = isTestCode(path) || isTooling(owner.directory, path);
|
|
40
|
+
return provider(entryPoints, name, development, true) !== undefined;
|
|
41
|
+
}
|
|
42
|
+
export async function withoutEntryPointImports(readText, diagnostics) {
|
|
43
|
+
const covered = await Promise.all(diagnostics.map((diagnostic) => brought(readText, diagnostic)));
|
|
44
|
+
return diagnostics.filter((_, index) => !covered[index]);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=withoutEntryPointImports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withoutEntryPointImports.js","sourceRoot":"","sources":["../../src/biome/withoutEntryPointImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIjD,MAAM,UAAU,GAAG,2CAA2C,CAAC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,QAAQ,CAAC,EAAE,CAAC;QACpC,OAAO,KAAK,CAAC;IACd,CAAC;IACD,MAAM,WAAW,GAAG,MAAM,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;IAClG,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACzE,OAAO,QAAQ,CAAC,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,KAAK,SAAS,CAAC;AACrE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,QAAgC,EAAE,WAAkC;IAClH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAClG,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pnpmWorkspacePatterns.d.ts","sourceRoot":"","sources":["../../src/imports/pnpmWorkspacePatterns.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pnpmWorkspacePatterns.d.ts","sourceRoot":"","sources":["../../src/imports/pnpmWorkspacePatterns.ts"],"names":[],"mappings":"AAuHA,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAiB9E;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAErE"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
function keyPattern(key) {
|
|
2
|
+
return new RegExp(`^(?:${key}|"${key}"|'${key}')\\s*:`, "u");
|
|
3
|
+
}
|
|
2
4
|
const ITEM = "-";
|
|
3
5
|
const SPACE = /\s/u;
|
|
4
6
|
const LINE_BREAK = /\r?\n/u;
|
|
@@ -21,38 +23,38 @@ function withoutComment(line) {
|
|
|
21
23
|
}
|
|
22
24
|
return line.trimEnd();
|
|
23
25
|
}
|
|
24
|
-
function scalar(raw) {
|
|
26
|
+
function scalar(raw, key) {
|
|
25
27
|
const value = raw.trim();
|
|
26
28
|
if (value.startsWith('"') && value.endsWith('"') && value.length > 1) {
|
|
27
29
|
try {
|
|
28
30
|
return String(JSON.parse(value));
|
|
29
31
|
}
|
|
30
32
|
catch (error) {
|
|
31
|
-
throw failure(`cannot read "${value}" in
|
|
33
|
+
throw failure(`cannot read "${value}" in ${key}`, error);
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
if (value.startsWith("'") && value.endsWith("'") && value.length > 1) {
|
|
35
37
|
return value.slice(1, -1).replaceAll("''", "'");
|
|
36
38
|
}
|
|
37
39
|
if (value === "" || value.includes(": ") || value.endsWith(":") || ["[", "{", "'", '"'].some((opening) => value.startsWith(opening))) {
|
|
38
|
-
throw failure(`cannot read "${value}" in
|
|
40
|
+
throw failure(`cannot read "${value}" in ${key}`);
|
|
39
41
|
}
|
|
40
42
|
return value;
|
|
41
43
|
}
|
|
42
44
|
const FLOW_INDICATOR = /[{}[\]]/u;
|
|
43
|
-
function flowScalar(raw) {
|
|
45
|
+
function flowScalar(raw, key) {
|
|
44
46
|
const value = raw.trim();
|
|
45
47
|
const quoted = value.startsWith('"') || value.startsWith("'");
|
|
46
48
|
if (!quoted && FLOW_INDICATOR.test(value)) {
|
|
47
|
-
throw failure(`cannot read "${value}" in
|
|
49
|
+
throw failure(`cannot read "${value}" in ${key}; quote a pattern that holds { } [ ] or ,`);
|
|
48
50
|
}
|
|
49
|
-
return scalar(value);
|
|
51
|
+
return scalar(value, key);
|
|
50
52
|
}
|
|
51
|
-
function closed(scan, rest) {
|
|
53
|
+
function closed(scan, rest, key) {
|
|
52
54
|
if (rest.trim() !== "") {
|
|
53
|
-
throw failure(`cannot read "${rest.trim()}" after the
|
|
55
|
+
throw failure(`cannot read "${rest.trim()}" after the ${key} list`);
|
|
54
56
|
}
|
|
55
|
-
return [...scan.entries, scan.current].filter((entry) => entry.trim() !== "").map(flowScalar);
|
|
57
|
+
return [...scan.entries, scan.current].filter((entry) => entry.trim() !== "").map((entry) => flowScalar(entry, key));
|
|
56
58
|
}
|
|
57
59
|
function scanned(scan, char) {
|
|
58
60
|
if (scan.quote !== undefined) {
|
|
@@ -72,19 +74,19 @@ function scanned(scan, char) {
|
|
|
72
74
|
scan.current += char;
|
|
73
75
|
return undefined;
|
|
74
76
|
}
|
|
75
|
-
function flowList(lines) {
|
|
77
|
+
function flowList(lines, key) {
|
|
76
78
|
const scan = { current: "", entries: [], quote: undefined };
|
|
77
79
|
for (const [number, line] of lines.map(withoutComment).entries()) {
|
|
78
80
|
for (let index = number === 0 ? 1 : 0; index < line.length; index += 1) {
|
|
79
81
|
if (scanned(scan, line[index] ?? "") === "close") {
|
|
80
|
-
return closed(scan, line.slice(index + 1));
|
|
82
|
+
return closed(scan, line.slice(index + 1), key);
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
scan.current += " ";
|
|
84
86
|
}
|
|
85
|
-
throw failure(
|
|
87
|
+
throw failure(`the ${key} list never closes`);
|
|
86
88
|
}
|
|
87
|
-
function blockList(lines) {
|
|
89
|
+
function blockList(lines, key) {
|
|
88
90
|
const patterns = [];
|
|
89
91
|
for (const line of lines.map(withoutComment)) {
|
|
90
92
|
const trimmed = line.trim();
|
|
@@ -96,27 +98,31 @@ function blockList(lines) {
|
|
|
96
98
|
break;
|
|
97
99
|
}
|
|
98
100
|
if (!item) {
|
|
99
|
-
throw failure(`cannot read "${trimmed}" in
|
|
101
|
+
throw failure(`cannot read "${trimmed}" in ${key}`);
|
|
100
102
|
}
|
|
101
|
-
patterns.push(scalar(trimmed.slice(ITEM.length)));
|
|
103
|
+
patterns.push(scalar(trimmed.slice(ITEM.length), key));
|
|
102
104
|
}
|
|
103
105
|
return patterns;
|
|
104
106
|
}
|
|
105
|
-
export function
|
|
107
|
+
export function pnpmWorkspaceList(text, key) {
|
|
108
|
+
const pattern = keyPattern(key);
|
|
106
109
|
const lines = text.split(LINE_BREAK);
|
|
107
|
-
const start = lines.findIndex((line) =>
|
|
110
|
+
const start = lines.findIndex((line) => pattern.test(line));
|
|
108
111
|
if (start === -1) {
|
|
109
112
|
return [];
|
|
110
113
|
}
|
|
111
114
|
const rest = withoutComment(lines[start] ?? "")
|
|
112
|
-
.replace(
|
|
115
|
+
.replace(pattern, "")
|
|
113
116
|
.trim();
|
|
114
117
|
if (rest.startsWith("[")) {
|
|
115
|
-
return flowList([rest, ...lines.slice(start + 1)]);
|
|
118
|
+
return flowList([rest, ...lines.slice(start + 1)], key);
|
|
116
119
|
}
|
|
117
120
|
if (rest !== "") {
|
|
118
|
-
throw failure(`cannot read "${rest}" in
|
|
121
|
+
throw failure(`cannot read "${rest}" in ${key}`);
|
|
119
122
|
}
|
|
120
|
-
return blockList(lines.slice(start + 1));
|
|
123
|
+
return blockList(lines.slice(start + 1), key);
|
|
124
|
+
}
|
|
125
|
+
export function pnpmWorkspacePatterns(text) {
|
|
126
|
+
return pnpmWorkspaceList(text, "packages");
|
|
121
127
|
}
|
|
122
128
|
//# sourceMappingURL=pnpmWorkspacePatterns.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pnpmWorkspacePatterns.js","sourceRoot":"","sources":["../../src/imports/pnpmWorkspacePatterns.ts"],"names":[],"mappings":"AAAA,MAAM,GAAG,GAAG,
|
|
1
|
+
{"version":3,"file":"pnpmWorkspacePatterns.js","sourceRoot":"","sources":["../../src/imports/pnpmWorkspacePatterns.ts"],"names":[],"mappings":"AAAA,SAAS,U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E,CAAC;QAC1B,OAAO,QAAQ,CAAC,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACzD,CAAC;IACD,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QACjB,MAAM,OAAO,CAAC,gBAAgB,IAAI,QAAQ,GAAG,EAAE,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAY;IACjD,OAAO,iBAAiB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { RuleInputs } from "#rule.ts";
|
|
2
2
|
import { type WorkspacePackage } from "./workspace.ts";
|
|
3
3
|
export type Runtime = "client" | "server" | "shared";
|
|
4
|
+
export type DeclaredRuntime = "client" | "server";
|
|
5
|
+
export interface RuntimeDeclarationProblem {
|
|
6
|
+
readonly directory: string;
|
|
7
|
+
readonly message: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function runtimeDeclarationProblems(inputs: RuleInputs, packages: readonly WorkspacePackage[]): readonly RuntimeDeclarationProblem[];
|
|
4
10
|
export declare function runtimeOf(inputs: RuleInputs, packages: readonly WorkspacePackage[]): (path: string) => Runtime | undefined;
|
|
5
11
|
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/imports/runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElE,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/imports/runtime.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElE,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAErD,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAsDlD,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,gBAAgB,EAAE,GAAG,SAAS,yBAAyB,EAAE,CAwB1I;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,gBAAgB,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GAAG,SAAS,CA6B1H"}
|
package/dist/imports/runtime.js
CHANGED
|
@@ -5,23 +5,34 @@ import { packageOf } from "./workspace.js";
|
|
|
5
5
|
function executablePath(value) {
|
|
6
6
|
return typeof value === "string" && value.trim().length > 0;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function readManifest(root, directory) {
|
|
9
9
|
const path = join(root, directory, "package.json");
|
|
10
10
|
try {
|
|
11
11
|
const manifest = JSON.parse(readFileSync(path, "utf8"));
|
|
12
12
|
if (typeof manifest !== "object" || manifest === null || Array.isArray(manifest)) {
|
|
13
13
|
throw new Error("the manifest must be an object");
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
return executablePath(bin) || (typeof bin === "object" && bin !== null && !Array.isArray(bin) && Object.values(bin).some(executablePath));
|
|
15
|
+
return manifest;
|
|
17
16
|
}
|
|
18
17
|
catch (cause) {
|
|
19
18
|
if (cause instanceof Error && "code" in cause && cause.code === "ENOENT") {
|
|
20
|
-
return
|
|
19
|
+
return undefined;
|
|
21
20
|
}
|
|
22
21
|
throw new Error(`cannot read runtime policy at ${path}`, { cause });
|
|
23
22
|
}
|
|
24
23
|
}
|
|
24
|
+
function hasExecutable(manifest) {
|
|
25
|
+
const bin = manifest === undefined ? undefined : Reflect.get(manifest, "bin");
|
|
26
|
+
return executablePath(bin) || (typeof bin === "object" && bin !== null && !Array.isArray(bin) && Object.values(bin).some(executablePath));
|
|
27
|
+
}
|
|
28
|
+
function declaredValue(manifest) {
|
|
29
|
+
const quality = manifest === undefined ? undefined : Reflect.get(manifest, "quality");
|
|
30
|
+
return typeof quality === "object" && quality !== null ? Reflect.get(quality, "runtime") : undefined;
|
|
31
|
+
}
|
|
32
|
+
function declaredRuntime(manifest) {
|
|
33
|
+
const value = declaredValue(manifest);
|
|
34
|
+
return value === "client" || value === "server" ? value : undefined;
|
|
35
|
+
}
|
|
25
36
|
function directoryExists(path) {
|
|
26
37
|
try {
|
|
27
38
|
return statSync(path).isDirectory();
|
|
@@ -33,17 +44,52 @@ function directoryExists(path) {
|
|
|
33
44
|
throw cause;
|
|
34
45
|
}
|
|
35
46
|
}
|
|
47
|
+
function runtimeFoldersOf(root, owner) {
|
|
48
|
+
return ["client", "server"].filter((folder) => directoryExists(join(root, owner.directory, "src", folder)));
|
|
49
|
+
}
|
|
50
|
+
export function runtimeDeclarationProblems(inputs, packages) {
|
|
51
|
+
return [...packages, { directory: ".", name: "." }].flatMap((owner) => {
|
|
52
|
+
const value = declaredValue(readManifest(inputs.root, owner.directory));
|
|
53
|
+
if (value === undefined) {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
if (value !== "client" && value !== "server") {
|
|
57
|
+
return [
|
|
58
|
+
{
|
|
59
|
+
directory: owner.directory,
|
|
60
|
+
message: `"quality.runtime" is ${JSON.stringify(value)}. Declare "client" or "server" for a package whose code runs in one runtime, or remove the field and use src/client/ and src/server/.`,
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
const folders = runtimeFoldersOf(inputs.root, owner);
|
|
65
|
+
return folders.length === 0
|
|
66
|
+
? []
|
|
67
|
+
: [
|
|
68
|
+
{
|
|
69
|
+
directory: owner.directory,
|
|
70
|
+
message: `"quality.runtime" declares the whole package ${value} code, but it also has ${folders.map((folder) => `src/${folder}/`).join(" and ")}. Keep one convention: remove the declaration and classify code by runtime folders, or move the code out of the runtime folders.`,
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
});
|
|
74
|
+
}
|
|
36
75
|
export function runtimeOf(inputs, packages) {
|
|
37
76
|
const owners = [...packages, { directory: ".", name: "." }];
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
77
|
+
const manifests = new Map(owners.map((owner) => [owner.directory, readManifest(inputs.root, owner.directory)]));
|
|
78
|
+
const adopted = new Set(owners.filter((owner) => runtimeFoldersOf(inputs.root, owner).length > 0).map((owner) => owner.directory));
|
|
79
|
+
const declared = new Map(owners.flatMap((owner) => {
|
|
80
|
+
const runtime = declaredRuntime(manifests.get(owner.directory));
|
|
81
|
+
return runtime === undefined || adopted.has(owner.directory) ? [] : [[owner.directory, runtime]];
|
|
82
|
+
}));
|
|
83
|
+
const executable = new Set(owners.filter((owner) => hasExecutable(manifests.get(owner.directory))).map((owner) => owner.directory));
|
|
42
84
|
return (path) => {
|
|
43
85
|
const owner = packageOf(packages, path)?.directory ?? ".";
|
|
44
86
|
if (isTooling(owner, path)) {
|
|
45
87
|
return "server";
|
|
46
88
|
}
|
|
89
|
+
const whole = declared.get(owner);
|
|
90
|
+
if (whole !== undefined) {
|
|
91
|
+
return whole;
|
|
92
|
+
}
|
|
47
93
|
if (!adopted.has(owner)) {
|
|
48
94
|
return executable.has(owner) ? "server" : undefined;
|
|
49
95
|
}
|