@shivaedev/quality 0.42.0 → 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 +33 -0
- package/README.md +45 -1
- package/biome/declarations.json +5 -0
- package/biome/plugins/ambient-runtime.grit +3 -1
- package/biome/preset.json +2 -2
- package/dist/rules/builtIn.d.ts +1 -1
- package/dist/rules/builtIn.d.ts.map +1 -1
- package/dist/rules/builtIn.js +6 -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/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 +2 -1
- 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/rules/builtIn.ts +6 -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/react/jsxConditionals.ts +59 -0
- package/src/rules/stories/engineOf.ts +2 -1
- package/src/rules/stories/namedValues.ts +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
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
|
+
|
|
3
36
|
## 0.42.0 - 2026-10-27
|
|
4
37
|
|
|
5
38
|
### Added
|
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`.
|
|
@@ -158,7 +168,7 @@ Every package tests its real engine through its own story kit, so setup and acti
|
|
|
158
168
|
|
|
159
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.
|
|
160
170
|
|
|
161
|
-
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.
|
|
162
172
|
|
|
163
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.
|
|
164
174
|
|
|
@@ -223,10 +233,44 @@ Git calls `quality baseline merge <ancestor> <current> <other>`. Entries are key
|
|
|
223
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`.
|
|
224
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.
|
|
225
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.
|
|
226
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.
|
|
227
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.
|
|
228
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.
|
|
229
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
|
+
|
|
230
274
|
### API
|
|
231
275
|
|
|
232
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:
|
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
|
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/rules/builtIn.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const builtInRules: readonly [import("../rule.ts").Rule<"structure/max-lines", {
|
|
1
|
+
export declare const builtInRules: readonly [import("../rule.ts").Rule<"effect/boundary", undefined>, import("../rule.ts").Rule<"effect/service-parameters", undefined>, import("../rule.ts").Rule<"react/jsx-conditionals", undefined>, import("../rule.ts").Rule<"structure/max-lines", {
|
|
2
2
|
readonly source?: number;
|
|
3
3
|
readonly test?: number;
|
|
4
4
|
}>, import("../rule.ts").Rule<"nesting/max-depth", undefined>, import("../rule.ts").Rule<"structure/no-barrel", undefined>, import("../rule.ts").Rule<"comments/no-jsdoc", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtIn.d.ts","sourceRoot":"","sources":["../../src/rules/builtIn.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"builtIn.d.ts","sourceRoot":"","sources":["../../src/rules/builtIn.ts"],"names":[],"mappings":"AA+CA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+HA+Cf,CAAC"}
|
package/dist/rules/builtIn.js
CHANGED
|
@@ -5,6 +5,8 @@ import { noJsdoc } from "#rules/comments/noJsdoc.ts";
|
|
|
5
5
|
import { noLineReference } from "#rules/comments/noLineReference.ts";
|
|
6
6
|
import { noPrReference } from "#rules/comments/noPrReference.ts";
|
|
7
7
|
import { noTodo } from "#rules/comments/noTodo.ts";
|
|
8
|
+
import { effectBoundary } from "#rules/effect/boundary.ts";
|
|
9
|
+
import { serviceParameters } from "#rules/effect/serviceParameters.ts";
|
|
8
10
|
import { distinctCase } from "#rules/files/distinctCase.ts";
|
|
9
11
|
import { folderNames } from "#rules/files/folderNames.ts";
|
|
10
12
|
import { namedAfterExport } from "#rules/files/namedAfterExport.ts";
|
|
@@ -16,6 +18,7 @@ import { importsManifest } from "#rules/imports/manifest.ts";
|
|
|
16
18
|
import { noTestCode } from "#rules/imports/noTestCode.ts";
|
|
17
19
|
import { importsResolvable } from "#rules/imports/resolvable.ts";
|
|
18
20
|
import { importsRuntime } from "#rules/imports/runtime.ts";
|
|
21
|
+
import { jsxConditionals } from "#rules/react/jsxConditionals.ts";
|
|
19
22
|
import { authSql } from "#rules/stories/authSql.ts";
|
|
20
23
|
import { storyEngine } from "#rules/stories/engine.ts";
|
|
21
24
|
import { httpStatus } from "#rules/stories/httpStatus.ts";
|
|
@@ -42,6 +45,9 @@ import { maxDepth } from "./maxDepth.js";
|
|
|
42
45
|
import { maxLines } from "./maxLines.js";
|
|
43
46
|
import { noBarrel } from "./noBarrel.js";
|
|
44
47
|
export const builtInRules = [
|
|
48
|
+
effectBoundary,
|
|
49
|
+
serviceParameters,
|
|
50
|
+
jsxConditionals,
|
|
45
51
|
maxLines,
|
|
46
52
|
maxDepth,
|
|
47
53
|
noBarrel,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtIn.js","sourceRoot":"","sources":["../../src/rules/builtIn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B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P,QAAQ;IACR,WAAW;IACX,UAAU;IACV,WAAW;IACX,cAAc;CACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundary.d.ts","sourceRoot":"","sources":["../../../src/rules/effect/boundary.ts"],"names":[],"mappings":"AA8CA,eAAO,MAAM,cAAc,uDA4BzB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { defineRule } from "#rule.ts";
|
|
3
|
+
import { parse } from "#rules/parse.ts";
|
|
4
|
+
function asyncConstruct(node) {
|
|
5
|
+
if (!(ts.isFunctionLike(node) && ts.canHaveModifiers(node) && ts.getModifiers(node)?.some((modifier) => modifier.kind === ts.SyntaxKind.AsyncKeyword))) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
if (ts.isArrowFunction(node)) {
|
|
9
|
+
return "async arrow";
|
|
10
|
+
}
|
|
11
|
+
return ts.isMethodDeclaration(node) ? "async method" : "async function";
|
|
12
|
+
}
|
|
13
|
+
function thenCall(node) {
|
|
14
|
+
if (!ts.isCallExpression(node)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const callee = node.expression;
|
|
18
|
+
return ((ts.isPropertyAccessExpression(callee) && callee.name.text === "then")
|
|
19
|
+
|| (ts.isElementAccessExpression(callee) && ts.isStringLiteral(callee.argumentExpression) && callee.argumentExpression.text === "then"));
|
|
20
|
+
}
|
|
21
|
+
function construct(node) {
|
|
22
|
+
if (ts.isVariableDeclarationList(node) && (node.flags & ts.NodeFlags.AwaitUsing) === ts.NodeFlags.AwaitUsing) {
|
|
23
|
+
return "await";
|
|
24
|
+
}
|
|
25
|
+
if (ts.isAwaitExpression(node) || (ts.isForOfStatement(node) && node.awaitModifier !== undefined)) {
|
|
26
|
+
return "await";
|
|
27
|
+
}
|
|
28
|
+
if (ts.isNewExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "Promise") {
|
|
29
|
+
return "new Promise(...)";
|
|
30
|
+
}
|
|
31
|
+
if (thenCall(node)) {
|
|
32
|
+
return ".then(...)";
|
|
33
|
+
}
|
|
34
|
+
if (ts.isTryStatement(node)) {
|
|
35
|
+
return "try statement";
|
|
36
|
+
}
|
|
37
|
+
return ts.isThrowStatement(node) ? "throw statement" : asyncConstruct(node);
|
|
38
|
+
}
|
|
39
|
+
export const effectBoundary = defineRule({
|
|
40
|
+
check: ({ sources }) => sources.flatMap((file) => {
|
|
41
|
+
if (/(?:^|\/)(?:adapters|test-support)\//u.test(file.path)) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
const source = parse(file);
|
|
45
|
+
const findings = [];
|
|
46
|
+
function visit(node) {
|
|
47
|
+
const name = construct(node);
|
|
48
|
+
if (name !== undefined && source !== undefined) {
|
|
49
|
+
findings.push({
|
|
50
|
+
file: file.path,
|
|
51
|
+
line: source.getLineAndCharacterOfPosition(node.getStart(source)).line + 1,
|
|
52
|
+
message: `Uses ${name}. Model the work with Effect; fail with a tagged error (or Effect.die for a defect). Move a bridge to an outside library into an adapters/ folder, returning Effect values.`,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
ts.forEachChild(node, visit);
|
|
56
|
+
}
|
|
57
|
+
if (source !== undefined) {
|
|
58
|
+
visit(source);
|
|
59
|
+
}
|
|
60
|
+
return findings;
|
|
61
|
+
}),
|
|
62
|
+
description: "All checked source, tooling and specs use Effect instead of async, await, new Promise, .then, try or throw. Only adapters/ and test-support/ folders at any depth are exempt. adapters/ bridges outside libraries to Effect; it remains subject to service-parameter and ambient runtime bans. Use tagged errors or Effect.die for defects. Config exceptions and inline suppressions are refused; baseline existing debt.",
|
|
63
|
+
id: "effect/boundary",
|
|
64
|
+
registrable: false,
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=boundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundary.js","sourceRoot":"","sources":["../../../src/rules/effect/boundary.ts"],"names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M,QAAQ,GAAc,EAAE,CAAC;QAC/B,SAAS,KAAK,CAAC,IAAa;YAC3B,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;YAC7B,IAAI,IAAI,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBAChD,QAAQ,CAAC,IAAI,CAAC;oBACb,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,IAAI,EAAE,MAAM,CAAC,6BAA6B,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC;oBAC1E,OAAO,EAAE,QAAQ,IAAI,6KAA6K;iBAClM,CAAC,CAAC;YACJ,CAAC;YACD,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC9B,CAAC;QACD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1B,KAAK,CAAC,MAAM,CAAC,CAAC;QACf,CAAC;QACD,OAAO,QAAQ,CAAC;IACjB,CAAC,CAAC;IACH,WAAW,EACV,4ZAA4Z;IAC7Z,EAAE,EAAE,iBAAiB;IACrB,WAAW,EAAE,KAAK;CAClB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layerConstructor.d.ts","sourceRoot":"","sources":["../../../src/rules/effect/layerConstructor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAgB5B,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,CAAC,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,GAAG,OAAO,CAuBxH"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { returnValues } from "#rules/stories/returnValues.ts";
|
|
3
|
+
function declaredLayer(checker, declaration) {
|
|
4
|
+
const type = declaration?.type;
|
|
5
|
+
if (type === undefined || !ts.isTypeReferenceNode(type)) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const symbol = checker.getSymbolAtLocation(type.typeName);
|
|
9
|
+
if (symbol === undefined) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
const target = symbol.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
13
|
+
return checker.getDeclaredTypeOfSymbol(target).getProperty("~effect/Layer") !== undefined;
|
|
14
|
+
}
|
|
15
|
+
export function layerConstructor(checker, declaration) {
|
|
16
|
+
if (declaredLayer(checker, declaration)) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
if (ts.getCombinedModifierFlags(declaration) & ts.ModifierFlags.Async
|
|
20
|
+
|| ("asteriskToken" in declaration && declaration.asteriskToken !== undefined)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
const returns = returnValues(declaration);
|
|
24
|
+
// Native Layer constructors declare the result independently of their inputs;
|
|
25
|
+
// resolving their instantiated result can expand an entire application graph.
|
|
26
|
+
return (returns.length > 0
|
|
27
|
+
&& returns.every((value) => {
|
|
28
|
+
if (value === undefined || !ts.isCallExpression(value)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const signatures = checker.getTypeAtLocation(value.expression).getCallSignatures();
|
|
32
|
+
return signatures.length > 0 && signatures.every((signature) => declaredLayer(checker, signature.declaration));
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=layerConstructor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layerConstructor.js","sourceRoot":"","sources":["../../../src/rules/effect/layerConstructor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAE9D,SAAS,aAAa,CAAC,OAAuB,EAAE,WAAwC;IACvF,MAAM,IAAI,GAAG,WAAW,EAAE,IAAI,CA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AAC;YACD,MAAM,UAAU,GAAG,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,iBAAiB,EAAE,CAAC;YACnF,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;QAChH,CAAC,CAAC,CACF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ownsParameters.d.ts","sourceRoot":"","sources":["../../../src/rules/effect/ownsParameters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAU5B,wBAAgB,cAAc,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,WAAW,CAAC,EAAE,CAAC,UAAU,CAAC,UAE1E,EAAE,CAAC,IAAI,KAAG,OAAO,CAiC/B"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
function declaredName(node) {
|
|
3
|
+
const parent = node.parent;
|
|
4
|
+
if (ts.isBindingElement(parent)) {
|
|
5
|
+
return parent.name === node || parent.propertyName === node;
|
|
6
|
+
}
|
|
7
|
+
return "name" in parent && parent.name === node && !ts.isPropertyAccessExpression(parent) && !ts.isShorthandPropertyAssignment(parent);
|
|
8
|
+
}
|
|
9
|
+
export function ownsParameters(checker, local) {
|
|
10
|
+
const known = new Map();
|
|
11
|
+
return (root) => {
|
|
12
|
+
const previous = known.get(root);
|
|
13
|
+
if (previous !== undefined) {
|
|
14
|
+
return previous;
|
|
15
|
+
}
|
|
16
|
+
const seen = new Set();
|
|
17
|
+
function reference(node) {
|
|
18
|
+
const symbol = ts.isShorthandPropertyAssignment(node.parent)
|
|
19
|
+
? checker.getShorthandAssignmentValueSymbol(node.parent)
|
|
20
|
+
: checker.getSymbolAtLocation(node);
|
|
21
|
+
if (symbol === undefined) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const target = symbol.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
25
|
+
return (target.declarations ?? []).some((declaration) => local.has(declaration.getSourceFile()) && visit(declaration));
|
|
26
|
+
}
|
|
27
|
+
function visit(node) {
|
|
28
|
+
if (seen.has(node)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
seen.add(node);
|
|
32
|
+
if (ts.isParameter(node)) {
|
|
33
|
+
return local.has(node.getSourceFile());
|
|
34
|
+
}
|
|
35
|
+
if (ts.isIdentifier(node) && !declaredName(node) && reference(node)) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
return ts.forEachChild(node, visit) ?? false;
|
|
39
|
+
}
|
|
40
|
+
const result = visit(root);
|
|
41
|
+
known.set(root, result);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=ownsParameters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ownsParameters.js","sourceRoot":"","sources":["../../../src/rules/effect/ownsParameters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,SAAS,YAAY,CAAC,IAAmB;IACxC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3B,IAAI,EAAE,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC,IAAI,KAAK,IAAI,IAAI,MAAM,CAAC,YAAY,KAAK,IAAI,CAAC;IAC7D,CAAC;IACD,OAAO,MAAM,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,EAAE,CAAC,0BAA0B,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,6BAA6B,CAAC,MAAM,CAAC,CAAC;AACxI,CAAC;AAED,MAAM,UAA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,EAAE,CAAC;gBAC1B,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;YACxC,CAAC;YACD,IAAI,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrE,OAAO,IAAI,CAAC;YACb,CAAC;YACD,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,KAAK,CAAC;QAC9C,CAAC;QACD,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3B,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACxB,OAAO,MAAM,CAAC;IACf,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../../src/rules/effect/program.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,EAAE,CAAC,OAAO,CAoB5D"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
import { projectsFor } from "#imports/projects.ts";
|
|
4
|
+
export function effectProgram(inputs) {
|
|
5
|
+
const projectOf = projectsFor(inputs.root);
|
|
6
|
+
const options = {
|
|
7
|
+
allowJs: true,
|
|
8
|
+
jsx: ts.JsxEmit.Preserve,
|
|
9
|
+
skipLibCheck: true,
|
|
10
|
+
strict: true,
|
|
11
|
+
target: ts.ScriptTarget.ESNext,
|
|
12
|
+
types: [],
|
|
13
|
+
};
|
|
14
|
+
const host = ts.createCompilerHost(options);
|
|
15
|
+
const texts = new Map(inputs.sources.map((source) => [join(inputs.root, source.path), source.text]));
|
|
16
|
+
const read = host.readFile;
|
|
17
|
+
host.readFile = (path) => texts.get(path) ?? read(path);
|
|
18
|
+
host.resolveModuleNames = (names, from) => names.map((name) => {
|
|
19
|
+
const project = projectOf(from);
|
|
20
|
+
return ts.resolveModuleName(name, from, project.typesOptions, host, project.typesCache).resolvedModule;
|
|
21
|
+
});
|
|
22
|
+
return ts.createProgram([...texts.keys()], options, host);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=program.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program.js","sourceRoot":"","sources":["../../../src/rules/effect/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,MAAM,UAAU,aAAa,CAAC,MAAkB;IAC/C,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAuB;QACnC,OAAO,EAAE,IAAI;QACb,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ;QACxB,YAAY,EAAE,IAAI;QAClB,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM;QAC9B,KAAK,EAAE,EAAE;KACT,CAAC;IACF,MAAM,IAAI,GAAG,EAAE,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrG,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC3B,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IACxD,IAAI,CAAC,kBAAkB,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CACzC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAClB,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;QAChC,OAAO,EAAE,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,YAAY,EAAE,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC;IACxG,CAAC,CAAC,CAAC;IACJ,OAAO,EAAE,CAAC,aAAa,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publicFunctions.d.ts","sourceRoot":"","sources":["../../../src/rules/effect/publicFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAG5B,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,GAAG,IAAI,CAkElI"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { ownsParameters } from "#rules/effect/ownsParameters.ts";
|
|
3
|
+
export function publicFunctions(sources, checker, surface) {
|
|
4
|
+
const local = new Set(sources);
|
|
5
|
+
const owned = ownsParameters(checker, local);
|
|
6
|
+
const visited = new Set();
|
|
7
|
+
function wrapped(value) {
|
|
8
|
+
if (checker.getTypeAtLocation(value).getCallSignatures().length === 0) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
for (const argument of value.arguments) {
|
|
12
|
+
surface(checker.getTypeAtLocation(argument));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function variable(declaration, symbol) {
|
|
16
|
+
surface(checker.getTypeOfSymbol(symbol));
|
|
17
|
+
if (declaration.initializer !== undefined && ts.isCallExpression(declaration.initializer)) {
|
|
18
|
+
wrapped(declaration.initializer);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function declarationSurface(declaration, target) {
|
|
22
|
+
if (!(local.has(declaration.getSourceFile()) && owned(declaration))) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (ts.isBindingElement(declaration)) {
|
|
26
|
+
surface(checker.getTypeOfSymbol(target));
|
|
27
|
+
}
|
|
28
|
+
if (ts.isExportAssignment(declaration)) {
|
|
29
|
+
surface(checker.getTypeAtLocation(declaration.expression));
|
|
30
|
+
}
|
|
31
|
+
if (ts.isInterfaceDeclaration(declaration)) {
|
|
32
|
+
surface(checker.getDeclaredTypeOfSymbol(target));
|
|
33
|
+
}
|
|
34
|
+
if (ts.isFunctionDeclaration(declaration) || ts.isClassDeclaration(declaration)) {
|
|
35
|
+
surface(checker.getTypeOfSymbol(target));
|
|
36
|
+
}
|
|
37
|
+
if (ts.isVariableDeclaration(declaration)) {
|
|
38
|
+
variable(declaration, target);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function exported(symbol) {
|
|
42
|
+
if (symbol === undefined) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const target = symbol.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
46
|
+
if (visited.has(target)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
visited.add(target);
|
|
50
|
+
for (const declaration of target.declarations ?? []) {
|
|
51
|
+
declarationSurface(declaration, target);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function publicClasses(node) {
|
|
55
|
+
if (ts.isClassDeclaration(node) && node.name !== undefined && owned(node)) {
|
|
56
|
+
surface(checker.getTypeAtLocation(node.name));
|
|
57
|
+
}
|
|
58
|
+
ts.forEachChild(node, publicClasses);
|
|
59
|
+
}
|
|
60
|
+
for (const source of sources) {
|
|
61
|
+
publicClasses(source);
|
|
62
|
+
const module = checker.getSymbolAtLocation(source);
|
|
63
|
+
for (const symbol of module === undefined ? [] : checker.getExportsOfModule(module)) {
|
|
64
|
+
exported(symbol);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=publicFunctions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publicFunctions.js","sourceRoot":"","sources":["../../../src/rules/effect/publicFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,MAAM,UAAU,eAAe,CAAC,OAAiC,EAAE,OAAuB,EAAE,OAAgC;IAC3H,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAC/B,MAAM,KAAK,GAAG,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAa,CAAC;IACrC,SAAS,OAAO,CAAC,KAAwB;QACxC,IAAI,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvE,OAAO;QACR,CAAC;QACD,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACxC,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC9C,CAAC;IACF,CAAC;IAED,SAAS,QAAQ,CAAC,WAAmC,EAAE,MAAiB;QACvE,OAAO,CAAC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ript";
|
|
2
|
+
export declare function serviceCatalog(program: ts.Program, checker: ts.TypeChecker): {
|
|
3
|
+
carries: (type: ts.Type) => boolean;
|
|
4
|
+
computation: (type: ts.Type) => boolean;
|
|
5
|
+
implementation: (type: ts.Type) => boolean;
|
|
6
|
+
remember: (type: ts.Type) => void;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=serviceCatalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serviceCatalog.d.ts","sourceRoot":"","sources":["../../../src/rules/effect/serviceCatalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAI5B,wBAAgB,cAAc,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW;;;;;EAoD1E"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { serviceOrigin } from "#rules/effect/serviceOrigin.ts";
|
|
3
|
+
import { serviceTypes } from "#rules/effect/serviceTypes.ts";
|
|
4
|
+
export function serviceCatalog(program, checker) {
|
|
5
|
+
const services = serviceTypes(checker);
|
|
6
|
+
function imported(node) {
|
|
7
|
+
const symbol = checker.getSymbolAtLocation(node.name);
|
|
8
|
+
if (symbol === undefined) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const target = symbol.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
12
|
+
const candidates = target.flags & ts.SymbolFlags.Module ? checker.getExportsOfModule(target) : [target];
|
|
13
|
+
for (const candidate of candidates) {
|
|
14
|
+
const resolved = candidate.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(candidate) : candidate;
|
|
15
|
+
if (serviceOrigin(checker, resolved)) {
|
|
16
|
+
services.remember(checker.getTypeOfSymbol(resolved));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function referenced(node) {
|
|
21
|
+
if (!serviceOrigin(checker, node.typeName)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const symbol = checker.getSymbolAtLocation(node.typeName);
|
|
25
|
+
if (symbol === undefined) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const target = symbol.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
29
|
+
services.remember(checker.getTypeOfSymbol(target));
|
|
30
|
+
}
|
|
31
|
+
function discover(node) {
|
|
32
|
+
if (ts.isCallExpression(node) && serviceOrigin(checker, node.expression)) {
|
|
33
|
+
services.remember(checker.getTypeAtLocation(node));
|
|
34
|
+
}
|
|
35
|
+
if (ts.isImportSpecifier(node) || ts.isNamespaceImport(node)) {
|
|
36
|
+
imported(node);
|
|
37
|
+
}
|
|
38
|
+
if (ts.isClassDeclaration(node) && node.name !== undefined && serviceOrigin(checker, node.name)) {
|
|
39
|
+
services.remember(checker.getTypeAtLocation(node.name));
|
|
40
|
+
}
|
|
41
|
+
if (ts.isVariableDeclaration(node) && serviceOrigin(checker, node.name)) {
|
|
42
|
+
services.remember(checker.getTypeAtLocation(node.name));
|
|
43
|
+
}
|
|
44
|
+
if (ts.isTypeReferenceNode(node)) {
|
|
45
|
+
referenced(node);
|
|
46
|
+
}
|
|
47
|
+
ts.forEachChild(node, discover);
|
|
48
|
+
}
|
|
49
|
+
for (const source of program.getSourceFiles()) {
|
|
50
|
+
if (!source.fileName.includes("/node_modules/") || source.fileName.includes("/@shivaedev/")) {
|
|
51
|
+
discover(source);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return services;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=serviceCatalog.js.map
|