@systemfsoftware/stryker-ignorer-effect-schema-declarations 0.1.1 → 0.3.1

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 CHANGED
@@ -1,5 +1,35 @@
1
1
  # @systemfsoftware/stryker-ignorer-effect-schema-declarations
2
2
 
3
+ ## 0.3.1
4
+
5
+ Build and lint with effect 4.1.0 and @effect/tsgo 0.63.0; the published code is unchanged.
6
+
7
+ ## 0.3.0
8
+
9
+ A schema that annotates a `recursionBudget` beside a behaviour key such as `toEquivalence` no longer fails the dry run with `Budget_RequiresTransform`.
10
+
11
+ - The object holding a `recursionBudget` in the first argument of `annotate` or `annotations` is now ignored whatever its other keys are. The other keys' values are still mutated.
12
+ - The `recursion-budget` reason calls `recursionBudget` metadata that only the recursion-budget transform, its runtime and the schema recursion laws read. The `recursion-budget-holder` reason and `RECURSION_BUDGET_HOLDER_IGNORED` drop "beside documentation only".
13
+ - New `KEEP_ADVICE` maps every reason code to the next action that keeps its mutants tested: `KEEP_RECURSION_BUDGET_MUTANT` (remove the `recursionBudget` annotation) for the two budget codes, `KEEP_IGNORED_MUTANT` for the rest. A `recursionBudget` annotation on a recursive schema is no longer mutated, so a run over a project using `@systemfsoftware/effect-schema-recursion-budget` no longer fails its dry run with `Budget_RequiresTransform`. Both the annotate object holding the budget and the budget value are reported as `Ignored`.
14
+
15
+ Every reason the ignorer reports now starts with a stable code, as `effect-schema-declarations/<code>: <why>`. `REASON_CODES` maps each code to what it means, and `KEEP_IGNORED_MUTANT` says how to keep a mutant the ignorer removes.
16
+
17
+ Breaking: the exported reason constants (`BRAND_NAME_IGNORED`, `TYPE_ID_IGNORED`, and the rest) now hold the coded text. Code that compares against the old text must use the constants or match on the code.
18
+
19
+ ## 0.2.1
20
+
21
+ Effect moves to `4.0.0-rc.117`, together with the `@effect/*` packages these libraries use. Projects that install `effect` next to them need the same release.
22
+
23
+ - The TypeScript checker and test-runner workers now bundle their own runtime, so the only modules they load from your project are the TypeScript compiler and your test framework.
24
+ - The test-runner plugin supports the framework's fifth major release.
25
+ - The ignorer interface re-exports the `oxc-parser` 0.150 AST, in which `FormalParameterRest.decorators` is `Array<Decorator>`. Enable the `@effect/language-service` tsgo plugin in every source package's `tsconfig.app.json` and `tsconfig.test.json`, and bump `@effect/tsgo` to `^0.50.0`. This turns on Effect-aware diagnostics during `effect-tsgo` type checking; it changes no runtime behaviour or public API.
26
+
27
+ ## 0.2.0
28
+
29
+ ### Minor Changes
30
+
31
+ - The ignorer recognizes the declaration forms Effect Schema files use today, so far fewer unkillable mutants reach your report. A `TaggedStruct` tag, an `annotate({ identifier, description, title })` object, a filter or check annotation object such as `makeFilter(predicate, { expected })`, a declaration's `toCodecArbitrary` callback and the arbitrary link transformation it returns, a decoding or constructor default, and a `TypeId` identity constant are all reported as `Ignored` now. Predicates, bounds, patterns, literal vocabularies, struct field sets, and codec decode/encode transformations keep being mutated. Each newly recognized form carries its own exported reason constant.
32
+
3
33
  ## 0.1.1
4
34
 
5
35
  ### Patch Changes
package/README.md CHANGED
@@ -17,34 +17,46 @@ pnpm add -D @systemfsoftware/stryker-ignorer-effect-schema-declarations
17
17
 
18
18
  ## Setup in `stryker.config.ts`
19
19
 
20
- Add the plugin URL to `ignorers`. Every ignorer the module exports is then active.
20
+ Add the package name to `ignorers`. Every ignorer the module exports is then active.
21
21
 
22
22
  ```ts
23
23
  import { defineConfig } from '@systemfsoftware/stryker-js/config'
24
24
 
25
25
  export default defineConfig({
26
26
  testRunner: {
27
- plugin: import.meta.resolve('@systemfsoftware/stryker-js-vitest-runner'),
27
+ plugin: '@systemfsoftware/stryker-js-vitest-runner',
28
28
  },
29
- ignorers: [
30
- import.meta.resolve('@systemfsoftware/stryker-ignorer-effect-schema-declarations'),
31
- ],
29
+ ignorers: ['@systemfsoftware/stryker-ignorer-effect-schema-declarations'],
32
30
  })
33
31
  ```
34
32
 
35
- Mutants recognized by the ignorer are reported with status `Ignored`, carrying the exact reason why skipping is safe.
33
+ Mutants recognized by the ignorer are reported with status `Ignored`. Their `statusReason` is `ignorer: effect-schema-declarations/<code>: <meaning>`: the engine's `ignorer` rule id, then a stable code from `REASON_CODES`, which maps each code to what it means. Renaming or removing a code is a breaking change. `KEEP_ADVICE` maps each code to the next action that keeps its mutants tested: for every code but the two `recursion-budget` ones, remove the package from `ignorers`.
36
34
 
37
35
  ## What It Ignores
38
36
 
39
- | Declaration | Example |
40
- | ----------------------------------------- | ----------------------------------------------------------------- |
41
- | Brand descriptions | `Symbol.for('UserId')` |
42
- | `TaggedClass` / `TaggedError` tag strings | `S.TaggedClass<A>()('Placed', { ... })` |
43
- | Schema property declarations | Property definition schema trees in tagged classes |
44
- | `optionalWith` default values | `S.optionalWith(S.Number, { default: () => 0 })` |
45
- | Documentation annotations | `identifier`, `description`, `title`, `documentation`, `examples` |
46
- | Pure documentation `annotations({ ... })` | `S.annotations({ title: 'Amount' })` |
37
+ | Declaration | Example |
38
+ | --------------------------------------------------------- | ------------------------------------------------------------------------------------ |
39
+ | Brand descriptions | `Symbol.for('UserId')` |
40
+ | `TaggedClass` / `TaggedError` tag strings | `S.TaggedClass<A>()('Placed', { ... })` |
41
+ | `TaggedStruct` tag strings | `S.TaggedStruct('PeerMissing', { ... })` |
42
+ | Schema property declarations | Property definition schema trees in tagged classes |
43
+ | `optionalWith` default values | `S.optionalWith(S.Number, { default: () => 0 })` |
44
+ | `withDecodingDefault` / `withConstructorDefault` defaults | `S.withDecodingDefaultKey(Effect.succeed(true))` |
45
+ | Documentation annotations | `identifier`, `description`, `title`, `documentation`, `examples` |
46
+ | Pure documentation `annotations({ ... })` | `S.annotations({ title: 'Amount' })` |
47
+ | Pure documentation `annotate({ ... })` | `S.annotate({ identifier: 'PackageExport' })` |
48
+ | Filter/check annotation objects | `S.makeFilter(pred, { expected: 'a canonical file' })` |
49
+ | Generation-only declaration callbacks | `S.declare(pred, { toCodecArbitrary: () => arbitrary })` |
50
+ | Arbitrary link transformations | `S.link<T>()(S.Null, { decode: …, encode: … })` outside a production `toCodec*` slot |
51
+ | Type identity constants | `const TypeId = '…/StageError' as const` |
52
+ | `recursionBudget` annotation values | `S.suspend(() => …).annotate({ recursionBudget: { maxDepth: 6 } })` |
53
+
54
+ ## What Stays Graded
55
+
56
+ Everything a mutant can still change at run time stays live: filter predicates and bounds, patterns, literal vocabularies, struct field sets, codec decode/encode transformations, and any object or string a schema uses to decide acceptance. The ignorer only removes mutants whose position cannot change a decoded value, a routing decision, or an encoded value.
57
+
58
+ `recursionBudget` is the one exception, and it is not an equivalence claim. Its value is test and generation metadata: only the [`@systemfsoftware/effect-schema-recursion-budget`](https://www.npmjs.com/package/@systemfsoftware/effect-schema-recursion-budget) build transform, that package's runtime, and the recursion laws of `@systemfsoftware/effect-schema-law` read it. The ignorer drops the mutants inside a `recursionBudget` value in the first argument of `annotate` or `annotations`. It also drops the mutants of the object holding that value, whatever the object's other keys are, because the transform only reads the budget from an annotate object written as a literal: a mutated object fails the dry run with `Budget_RequiresTransform`. The other keys' own values stay graded, so a behaviour key such as `toEquivalence` is still mutated inside its value. A `recursionBudget` key anywhere else stays mutated. Removing the ignorer does not keep these mutants: the transform reads the annotate object as written, so the dry run fails with `Budget_RequiresTransform`.
47
59
 
48
60
  ## License
49
61
 
50
- [Apache-2.0](../../../LICENSE)
62
+ [Apache-2.0](../../LICENSE)
package/dist/index.d.ts CHANGED
@@ -1,21 +1,45 @@
1
- import { Ignorer } from '@systemfsoftware/stryker-ignorer-interface';
2
-
3
- export declare const ANNOTATION_OBJECT_IGNORED: 'annotations object holding only documentation is a declaration, not behaviour';
4
-
5
- export declare const ANNOTATION_TEXT_IGNORED: 'annotation documentation value is declaration data, not behaviour';
6
-
7
- export declare const BRAND_NAME_IGNORED: 'Schema.brand name is identity-only data, not behaviour';
8
-
9
- export declare const CLASS_ID_IGNORED: 'Schema.Class identifier is a declaration name, not behaviour';
10
-
11
- export declare const OPTIONAL_DEFAULT_IGNORED: 'optionalWith default value is config, not behaviour';
12
-
13
- export declare const strykerIgnorers: readonly Ignorer[];
14
-
15
- export declare const SYMBOL_DESCRIPTION_IGNORED: 'Symbol.for() brand description is identity-only data, not behaviour';
16
-
17
- export declare const TAGGED_FIELDS_IGNORED: 'TaggedClass/TaggedError field schema is a declaration, not behaviour';
18
-
19
- export declare const TAGGED_TAG_IGNORED: 'TaggedClass/TaggedError _tag is a declaration discriminant, not behaviour';
20
-
21
- export { }
1
+ import { Ignorer } from "@systemfsoftware/stryker-ignorer-interface";
2
+ //#region src/effect-schema-declarations.d.ts
3
+ export declare const REASON_CODES: {
4
+ readonly 'symbol-description': 'Symbol.for() brand description is identity-only data, not behaviour';
5
+ readonly 'tagged-tag': 'TaggedClass/TaggedError _tag is a declaration discriminant, not behaviour';
6
+ readonly 'tagged-struct-tag': 'TaggedStruct _tag is a declaration discriminant, not behaviour';
7
+ readonly 'tagged-fields': 'TaggedClass/TaggedError field schema is a declaration, not behaviour';
8
+ readonly 'class-id': 'Schema.Class identifier is a declaration name, not behaviour';
9
+ readonly 'brand-name': 'Schema.brand name is identity-only data, not behaviour';
10
+ readonly 'optional-default': 'optionalWith default value is config, not behaviour';
11
+ readonly 'decoding-default': 'withDecodingDefault/withConstructorDefault default is config, not behaviour';
12
+ readonly 'annotation-object': 'annotations object holding only documentation is a declaration, not behaviour';
13
+ readonly 'annotation-text': 'annotation documentation value is declaration data, not behaviour';
14
+ readonly 'check-annotation-object': 'filter/check annotation object holds documentation and generation hints, not behaviour';
15
+ readonly 'check-annotation-text': 'filter/check annotation value is documentation data, not behaviour';
16
+ readonly 'generation-annotation': 'arbitrary-generation annotation never runs in production, not behaviour';
17
+ readonly 'link-transformation': 'S.link() transformation feeds arbitrary generation only, not production codecs';
18
+ readonly 'type-id': 'a TypeId constant is a declaration identity, not behaviour';
19
+ readonly 'recursion-budget-holder': 'annotate object holding a recursionBudget must stay a literal object for the recursion-budget transform to read it';
20
+ readonly 'recursion-budget': 'recursionBudget is test/generation-only metadata: only the recursion-budget transform, its runtime and the schema recursion laws read it';
21
+ };
22
+ type ReasonCode = keyof typeof REASON_CODES;
23
+ export declare const KEEP_IGNORED_MUTANT: "To keep these mutants, remove '@systemfsoftware/stryker-ignorer-effect-schema-declarations' from `ignorers`.";
24
+ export declare const KEEP_RECURSION_BUDGET_MUTANT: 'These mutants cannot be kept while the recursion-budget transform runs: it reads the annotate object as written, so removing this ignorer fails the dry run with `Budget_RequiresTransform`. To have them tested, remove the `recursionBudget` annotation.';
25
+ export declare const KEEP_ADVICE: Record<ReasonCode, string>;
26
+ export declare const SYMBOL_DESCRIPTION_IGNORED: "effect-schema-declarations/symbol-description: Symbol.for() brand description is identity-only data, not behaviour";
27
+ export declare const TAGGED_TAG_IGNORED: "effect-schema-declarations/tagged-tag: TaggedClass/TaggedError _tag is a declaration discriminant, not behaviour";
28
+ export declare const TAGGED_STRUCT_TAG_IGNORED: "effect-schema-declarations/tagged-struct-tag: TaggedStruct _tag is a declaration discriminant, not behaviour";
29
+ export declare const TAGGED_FIELDS_IGNORED: "effect-schema-declarations/tagged-fields: TaggedClass/TaggedError field schema is a declaration, not behaviour";
30
+ export declare const CLASS_ID_IGNORED: "effect-schema-declarations/class-id: Schema.Class identifier is a declaration name, not behaviour";
31
+ export declare const BRAND_NAME_IGNORED: "effect-schema-declarations/brand-name: Schema.brand name is identity-only data, not behaviour";
32
+ export declare const OPTIONAL_DEFAULT_IGNORED: "effect-schema-declarations/optional-default: optionalWith default value is config, not behaviour";
33
+ export declare const DECODING_DEFAULT_IGNORED: "effect-schema-declarations/decoding-default: withDecodingDefault/withConstructorDefault default is config, not behaviour";
34
+ export declare const ANNOTATION_OBJECT_IGNORED: "effect-schema-declarations/annotation-object: annotations object holding only documentation is a declaration, not behaviour";
35
+ export declare const ANNOTATION_TEXT_IGNORED: "effect-schema-declarations/annotation-text: annotation documentation value is declaration data, not behaviour";
36
+ export declare const CHECK_ANNOTATION_OBJECT_IGNORED: "effect-schema-declarations/check-annotation-object: filter/check annotation object holds documentation and generation hints, not behaviour";
37
+ export declare const CHECK_ANNOTATION_TEXT_IGNORED: "effect-schema-declarations/check-annotation-text: filter/check annotation value is documentation data, not behaviour";
38
+ export declare const GENERATION_ANNOTATION_IGNORED: "effect-schema-declarations/generation-annotation: arbitrary-generation annotation never runs in production, not behaviour";
39
+ export declare const LINK_TRANSFORMATION_IGNORED: "effect-schema-declarations/link-transformation: S.link() transformation feeds arbitrary generation only, not production codecs";
40
+ export declare const TYPE_ID_IGNORED: "effect-schema-declarations/type-id: a TypeId constant is a declaration identity, not behaviour";
41
+ export declare const RECURSION_BUDGET_HOLDER_IGNORED: "effect-schema-declarations/recursion-budget-holder: annotate object holding a recursionBudget must stay a literal object for the recursion-budget transform to read it";
42
+ export declare const RECURSION_BUDGET_IGNORED: "effect-schema-declarations/recursion-budget: recursionBudget is test/generation-only metadata: only the recursion-budget transform, its runtime and the schema recursion laws read it";
43
+ export declare const strykerIgnorers: readonly Ignorer[];
44
+ //#endregion
45
+ export type { ReasonCode };
package/dist/index.mjs CHANGED
@@ -1,13 +1,63 @@
1
1
  import { defineIgnorer } from "@systemfsoftware/stryker-ignorer-kit";
2
- //#region src/SchemaDeclarationIgnore.ts
3
- const SYMBOL_DESCRIPTION_IGNORED = "Symbol.for() brand description is identity-only data, not behaviour";
4
- const TAGGED_TAG_IGNORED = "TaggedClass/TaggedError _tag is a declaration discriminant, not behaviour";
5
- const TAGGED_FIELDS_IGNORED = "TaggedClass/TaggedError field schema is a declaration, not behaviour";
6
- const CLASS_ID_IGNORED = "Schema.Class identifier is a declaration name, not behaviour";
7
- const BRAND_NAME_IGNORED = "Schema.brand name is identity-only data, not behaviour";
8
- const OPTIONAL_DEFAULT_IGNORED = "optionalWith default value is config, not behaviour";
9
- const ANNOTATION_OBJECT_IGNORED = "annotations object holding only documentation is a declaration, not behaviour";
10
- const ANNOTATION_TEXT_IGNORED = "annotation documentation value is declaration data, not behaviour";
2
+ //#region src/effect-schema-declarations.ts
3
+ const REASON_CODES = {
4
+ "symbol-description": "Symbol.for() brand description is identity-only data, not behaviour",
5
+ "tagged-tag": "TaggedClass/TaggedError _tag is a declaration discriminant, not behaviour",
6
+ "tagged-struct-tag": "TaggedStruct _tag is a declaration discriminant, not behaviour",
7
+ "tagged-fields": "TaggedClass/TaggedError field schema is a declaration, not behaviour",
8
+ "class-id": "Schema.Class identifier is a declaration name, not behaviour",
9
+ "brand-name": "Schema.brand name is identity-only data, not behaviour",
10
+ "optional-default": "optionalWith default value is config, not behaviour",
11
+ "decoding-default": "withDecodingDefault/withConstructorDefault default is config, not behaviour",
12
+ "annotation-object": "annotations object holding only documentation is a declaration, not behaviour",
13
+ "annotation-text": "annotation documentation value is declaration data, not behaviour",
14
+ "check-annotation-object": "filter/check annotation object holds documentation and generation hints, not behaviour",
15
+ "check-annotation-text": "filter/check annotation value is documentation data, not behaviour",
16
+ "generation-annotation": "arbitrary-generation annotation never runs in production, not behaviour",
17
+ "link-transformation": "S.link() transformation feeds arbitrary generation only, not production codecs",
18
+ "type-id": "a TypeId constant is a declaration identity, not behaviour",
19
+ "recursion-budget-holder": "annotate object holding a recursionBudget must stay a literal object for the recursion-budget transform to read it",
20
+ "recursion-budget": "recursionBudget is test/generation-only metadata: only the recursion-budget transform, its runtime and the schema recursion laws read it"
21
+ };
22
+ const KEEP_IGNORED_MUTANT = "To keep these mutants, remove '@systemfsoftware/stryker-ignorer-effect-schema-declarations' from `ignorers`.";
23
+ const KEEP_RECURSION_BUDGET_MUTANT = "These mutants cannot be kept while the recursion-budget transform runs: it reads the annotate object as written, so removing this ignorer fails the dry run with `Budget_RequiresTransform`. To have them tested, remove the `recursionBudget` annotation.";
24
+ const KEEP_ADVICE = {
25
+ "symbol-description": KEEP_IGNORED_MUTANT,
26
+ "tagged-tag": KEEP_IGNORED_MUTANT,
27
+ "tagged-struct-tag": KEEP_IGNORED_MUTANT,
28
+ "tagged-fields": KEEP_IGNORED_MUTANT,
29
+ "class-id": KEEP_IGNORED_MUTANT,
30
+ "brand-name": KEEP_IGNORED_MUTANT,
31
+ "optional-default": KEEP_IGNORED_MUTANT,
32
+ "decoding-default": KEEP_IGNORED_MUTANT,
33
+ "annotation-object": KEEP_IGNORED_MUTANT,
34
+ "annotation-text": KEEP_IGNORED_MUTANT,
35
+ "check-annotation-object": KEEP_IGNORED_MUTANT,
36
+ "check-annotation-text": KEEP_IGNORED_MUTANT,
37
+ "generation-annotation": KEEP_IGNORED_MUTANT,
38
+ "link-transformation": KEEP_IGNORED_MUTANT,
39
+ "type-id": KEEP_IGNORED_MUTANT,
40
+ "recursion-budget-holder": KEEP_RECURSION_BUDGET_MUTANT,
41
+ "recursion-budget": KEEP_RECURSION_BUDGET_MUTANT
42
+ };
43
+ const reasonFor = (code) => `effect-schema-declarations/${code}: ${REASON_CODES[code]}`;
44
+ const SYMBOL_DESCRIPTION_IGNORED = reasonFor("symbol-description");
45
+ const TAGGED_TAG_IGNORED = reasonFor("tagged-tag");
46
+ const TAGGED_STRUCT_TAG_IGNORED = reasonFor("tagged-struct-tag");
47
+ const TAGGED_FIELDS_IGNORED = reasonFor("tagged-fields");
48
+ const CLASS_ID_IGNORED = reasonFor("class-id");
49
+ const BRAND_NAME_IGNORED = reasonFor("brand-name");
50
+ const OPTIONAL_DEFAULT_IGNORED = reasonFor("optional-default");
51
+ const DECODING_DEFAULT_IGNORED = reasonFor("decoding-default");
52
+ const ANNOTATION_OBJECT_IGNORED = reasonFor("annotation-object");
53
+ const ANNOTATION_TEXT_IGNORED = reasonFor("annotation-text");
54
+ const CHECK_ANNOTATION_OBJECT_IGNORED = reasonFor("check-annotation-object");
55
+ const CHECK_ANNOTATION_TEXT_IGNORED = reasonFor("check-annotation-text");
56
+ const GENERATION_ANNOTATION_IGNORED = reasonFor("generation-annotation");
57
+ const LINK_TRANSFORMATION_IGNORED = reasonFor("link-transformation");
58
+ const TYPE_ID_IGNORED = reasonFor("type-id");
59
+ const RECURSION_BUDGET_HOLDER_IGNORED = reasonFor("recursion-budget-holder");
60
+ const RECURSION_BUDGET_IGNORED = reasonFor("recursion-budget");
11
61
  const DOCUMENTATION_KEYS = {
12
62
  identifier: true,
13
63
  description: true,
@@ -15,73 +65,167 @@ const DOCUMENTATION_KEYS = {
15
65
  documentation: true,
16
66
  examples: true
17
67
  };
68
+ const CHECK_TEXT_KEYS = {
69
+ ...DOCUMENTATION_KEYS,
70
+ expected: true,
71
+ message: true
72
+ };
73
+ const GENERATION_KEYS = {
74
+ toCodecArbitrary: true,
75
+ toArbitrary: true,
76
+ arbitraryConstraint: true,
77
+ arbitrary: true
78
+ };
79
+ const RECURSION_BUDGET_KEYS = { recursionBudget: true };
80
+ const PRODUCTION_CODEC_KEYS = {
81
+ toCodec: true,
82
+ toCodecJson: true,
83
+ toCodecStringTree: true,
84
+ toCodecIso: true
85
+ };
18
86
  const TAGGED_FACTORIES = ["TaggedClass", "TaggedError"];
19
- const CLASS_FACTORY = "Class";
87
+ const TAGGED_STRUCT_FACTORIES = ["TaggedStruct"];
88
+ const ANNOTATION_CALLEES = ["annotations", "annotate"];
89
+ const ANNOTATION_OBJECT_CALLEES = [
90
+ "makeFilter",
91
+ "makeFilterGroup",
92
+ "declare"
93
+ ];
94
+ const DEFAULT_CALLEES = [
95
+ "withDecodingDefault",
96
+ "withDecodingDefaultKey",
97
+ "withConstructorDefault"
98
+ ];
20
99
  const isIdentifierNamed = (node, name) => node.type === "Identifier" && node.name === name;
21
100
  const isIdentifierAmong = (node, names) => node.type === "Identifier" && names.includes(node.name);
22
101
  const isPlainMember = (node) => node.type === "MemberExpression" && node.computed === false;
23
102
  const isMemberObjectNamed = (node, object) => isPlainMember(node) && isIdentifierNamed(node.object, object);
24
103
  const isMemberPropertyNamed = (node, property) => isPlainMember(node) && isIdentifierNamed(node.property, property);
104
+ const isMemberPropertyAmong = (node, properties) => isPlainMember(node) && isIdentifierAmong(node.property, properties);
25
105
  const isSymbolForCallee = (callee) => isMemberObjectNamed(callee, "Symbol") && isMemberPropertyNamed(callee, "for");
26
106
  const isFactoryReference = (reference, factories) => isPlainMember(reference) && isIdentifierAmong(reference.property, factories);
27
107
  const isTaggedFactoryCallee = (callee) => callee.type === "CallExpression" && isFactoryReference(callee.callee, TAGGED_FACTORIES);
28
- const isClassFactoryCallee = (callee) => isMemberPropertyNamed(callee, CLASS_FACTORY);
108
+ const isTaggedStructCallee = (callee) => isFactoryReference(callee, TAGGED_STRUCT_FACTORIES);
109
+ const isClassFactoryCallee = (callee) => isMemberPropertyNamed(callee, "Class");
29
110
  const isBrandCallee = (callee) => isMemberPropertyNamed(callee, "brand");
30
- const isAnnotationsCallee = (callee) => isMemberPropertyNamed(callee, "annotations");
111
+ const isLinkMember = (callee) => isMemberPropertyNamed(callee, "link");
112
+ const isLinkFactoryCall = (callee) => callee.type === "CallExpression" && isLinkMember(callee.callee);
113
+ const isLinkCallee = (callee) => isLinkMember(callee) || isLinkFactoryCall(callee);
114
+ const isAnnotationsCallee = (callee) => isMemberPropertyAmong(callee, ANNOTATION_CALLEES);
115
+ const isAnnotationObjectCallee = (callee) => isMemberPropertyAmong(callee, ANNOTATION_OBJECT_CALLEES);
116
+ const isDefaultCallee = (callee) => isMemberPropertyAmong(callee, DEFAULT_CALLEES);
31
117
  const isOptionalWithCallee = (callee) => isMemberObjectNamed(callee, "S") && isMemberPropertyNamed(callee, "optionalWith");
32
118
  const holdsCallOf = (call, callee) => call !== void 0 && callee(call.callee);
33
119
  const holdsArgumentOf = (node, call, index, callee) => holdsCallOf(call, callee) && call.arguments[index] === node;
34
- const isDocumentationKey = (value) => typeof value === "string" && DOCUMENTATION_KEYS[value] === true;
35
- const isLiteralKeyNamed = (key) => key.type === "Literal" && isDocumentationKey(key.value);
36
- const isDocumentationKeyNode = (key) => key.type === "Identifier" ? isDocumentationKey(key.name) : isLiteralKeyNamed(key);
37
- const isComputedFreeProperty = (property) => property.type === "Property" && property.computed === false;
38
- const isDocumentationEntry = (property) => isComputedFreeProperty(property) && isDocumentationKeyNode(property.key);
39
- const holdsDocumentationEntries = (properties) => properties.length > 0 && properties.every(isDocumentationEntry);
40
- const isDocumentationOnlyObject = (node) => node.type === "ObjectExpression" && holdsDocumentationEntries(node.properties);
41
- const holdsDocumentationObjectArgument = (node, call) => isDocumentationOnlyObject(node) && holdsArgumentOf(node, call, 0, isAnnotationsCallee);
120
+ const isKeyedByName = (value, keys) => typeof value === "string" && keys[value] === true;
121
+ const isLiteralKeyOf = (key, keys) => key.type === "Literal" && isKeyedByName(key.value, keys);
122
+ const isKeyOf = (key, keys) => key.type === "Identifier" ? isKeyedByName(key.name, keys) : isLiteralKeyOf(key, keys);
123
+ const isPropertyNode = (node) => node !== void 0 && node.type === "Property";
124
+ const isComputedFreeProperty = (node) => isPropertyNode(node) && node.computed === false;
42
125
  const isCallNode = (node) => node !== void 0 && node.type === "CallExpression";
43
- const asCall = (node) => isCallNode(node) ? node : void 0;
44
- const isEntryNode = (property) => property !== void 0 && isDocumentationEntry(property);
45
- const isDocumentationEntryValue = (property, node) => isEntryNode(property) && property.value === node;
46
126
  const isObjectNode = (node) => node !== void 0 && node.type === "ObjectExpression";
47
- const isObjectArgumentOfAnnotations = (object, call) => isObjectNode(object) && holdsArgumentOf(object, asCall(call), 0, isAnnotationsCallee);
48
- const argumentRule = (index, callee, reason) => ({
127
+ const isVariableDeclarator = (node) => node?.type === "VariableDeclarator";
128
+ const asCall = (node) => isCallNode(node) ? node : void 0;
129
+ const isDocumentationKeyNode = (key) => isKeyOf(key, DOCUMENTATION_KEYS);
130
+ const isCheckTextKeyNode = (key) => isKeyOf(key, CHECK_TEXT_KEYS);
131
+ const isGenerationKeyNode = (key) => isKeyOf(key, GENERATION_KEYS);
132
+ const isRecursionBudgetKeyNode = (key) => isKeyOf(key, RECURSION_BUDGET_KEYS);
133
+ const isDocumentationOrCheckKeyNode = (key) => isDocumentationKeyNode(key) || isCheckTextKeyNode(key);
134
+ const isDeclarationKeyNode = (key) => isDocumentationOrCheckKeyNode(key) || isGenerationKeyNode(key);
135
+ const isDocumentationEntry = (property) => isComputedFreeProperty(property) && isDocumentationKeyNode(property.key);
136
+ const isDeclarationEntry = (property) => isComputedFreeProperty(property) && isDeclarationKeyNode(property.key);
137
+ const isRecursionBudgetEntry = (property) => isComputedFreeProperty(property) && isRecursionBudgetKeyNode(property.key);
138
+ const holdsEntries = (properties, holds) => properties.length > 0 && properties.every(holds);
139
+ const isDocumentationOnlyObject = (node) => isObjectNode(node) && holdsEntries(node.properties, isDocumentationEntry);
140
+ const isDeclarationAnnotationObject = (node) => isObjectNode(node) && holdsEntries(node.properties, isDeclarationEntry);
141
+ const isBudgetHolderObject = (node) => isObjectNode(node) && node.properties.some(isRecursionBudgetEntry);
142
+ const isArgumentAt = (node, call, index, callee) => isObjectNode(node) && holdsArgumentOf(node, asCall(call), index, callee);
143
+ const isDocumentationObjectArgument = (node, call) => isDocumentationOnlyObject(node) && holdsArgumentOf(node, call, 0, isAnnotationsCallee);
144
+ const isBudgetHolderArgument = (node, call) => isBudgetHolderObject(node) && holdsArgumentOf(node, call, 0, isAnnotationsCallee);
145
+ const isDeclarationAnnotationArgument = (node, call) => isDeclarationAnnotationObject(node) && holdsArgumentOf(node, call, 1, isAnnotationObjectCallee);
146
+ const simpleArgumentRule = (index, callee, reason) => ({
49
147
  holds: (node, call) => holdsArgumentOf(node, call, index, callee),
50
148
  reason
51
149
  });
52
150
  const LITERAL_ARGUMENT_RULES = [
53
- argumentRule(0, isSymbolForCallee, SYMBOL_DESCRIPTION_IGNORED),
54
- argumentRule(0, isTaggedFactoryCallee, TAGGED_TAG_IGNORED),
55
- argumentRule(0, isClassFactoryCallee, CLASS_ID_IGNORED),
56
- argumentRule(0, isBrandCallee, BRAND_NAME_IGNORED)
151
+ simpleArgumentRule(0, isSymbolForCallee, SYMBOL_DESCRIPTION_IGNORED),
152
+ simpleArgumentRule(0, isTaggedFactoryCallee, TAGGED_TAG_IGNORED),
153
+ simpleArgumentRule(0, isTaggedStructCallee, TAGGED_STRUCT_TAG_IGNORED),
154
+ simpleArgumentRule(0, isClassFactoryCallee, CLASS_ID_IGNORED),
155
+ simpleArgumentRule(0, isBrandCallee, BRAND_NAME_IGNORED)
57
156
  ];
58
- const OBJECT_ARGUMENT_RULES = [argumentRule(1, isTaggedFactoryCallee, TAGGED_FIELDS_IGNORED), {
59
- holds: holdsDocumentationObjectArgument,
60
- reason: ANNOTATION_OBJECT_IGNORED
61
- }];
62
- const ARROW_ARGUMENT_RULES = [argumentRule(1, isOptionalWithCallee, OPTIONAL_DEFAULT_IGNORED)];
157
+ const OBJECT_ARGUMENT_RULES = [
158
+ simpleArgumentRule(1, isTaggedFactoryCallee, TAGGED_FIELDS_IGNORED),
159
+ {
160
+ holds: isDocumentationObjectArgument,
161
+ reason: ANNOTATION_OBJECT_IGNORED
162
+ },
163
+ {
164
+ holds: isBudgetHolderArgument,
165
+ reason: RECURSION_BUDGET_HOLDER_IGNORED
166
+ },
167
+ {
168
+ holds: isDeclarationAnnotationArgument,
169
+ reason: CHECK_ANNOTATION_OBJECT_IGNORED
170
+ }
171
+ ];
172
+ const ARROW_ARGUMENT_RULES = [simpleArgumentRule(1, isOptionalWithCallee, OPTIONAL_DEFAULT_IGNORED)];
63
173
  const firstArgumentReason = (rules, node, call) => rules.find((rule) => rule.holds(node, call))?.reason;
64
- const isDocumentedAnnotationValue = (node, ctx) => {
65
- const property = ctx.parentIf("Property");
66
- return isDocumentationEntryValue(property, node) && isObjectArgumentOfAnnotations(ctx.ancestors[1], ctx.ancestors[2]);
174
+ const slotsOf = (node, ancestors) => [node, ...ancestors].map((child, index) => ({
175
+ child,
176
+ ancestor: ancestors[index],
177
+ holder: ancestors[index + 1],
178
+ call: asCall(ancestors[index + 2])
179
+ }));
180
+ const isEntrySlot = (slot) => isComputedFreeProperty(slot.ancestor) && slot.ancestor.value === slot.child;
181
+ const isAnnotationEntrySlot = (slot) => isEntrySlot(slot) && isArgumentAt(slot.holder, slot.call, 1, isAnnotationObjectCallee);
182
+ const isDocumentationEntrySlot = (slot) => isEntrySlot(slot) && isDocumentationKeyNode(slot.ancestor.key);
183
+ const isDocumentationSlot = (slot) => isDocumentationEntrySlot(slot) && isArgumentAt(slot.holder, slot.call, 0, isAnnotationsCallee);
184
+ const isRecursionBudgetEntrySlot = (slot) => isEntrySlot(slot) && isRecursionBudgetKeyNode(slot.ancestor.key);
185
+ const isRecursionBudgetSlot = (slot) => isRecursionBudgetEntrySlot(slot) && isArgumentAt(slot.holder, slot.call, 0, isAnnotationsCallee);
186
+ const isCallArgumentSlot = (slot, index) => isCallNode(slot.ancestor) && slot.ancestor.arguments[index] === slot.child;
187
+ const isArgumentSlot = (slot, index, callee) => isCallArgumentSlot(slot, index) && callee(slot.ancestor.callee);
188
+ const isDeclaratorSlot = (slot) => isVariableDeclarator(slot.ancestor) && slot.ancestor.init === slot.child;
189
+ const isDirectDeclaratorSlot = (node) => (slot) => isDeclaratorSlot(slot) && isDirectInitializer(slot, node);
190
+ const isTypeIdSlot = (node) => (slot) => isDirectDeclaratorSlot(node)(slot) && isTypeIdName(slot);
191
+ const isDirectInitializer = (slot, node) => slot.child === node || isAsExpressionOf(slot.child, node);
192
+ const isAsExpressionOf = (child, node) => child.type === "TSAsExpression" && child.expression === node;
193
+ const isTypeIdName = (slot) => slot.ancestor.id.type === "Identifier" && slot.ancestor.id.name === "TypeId";
194
+ const generationKeyReason = (key) => isGenerationKeyNode(key) ? GENERATION_ANNOTATION_IGNORED : void 0;
195
+ const textKeyReason = (key) => isCheckTextKeyNode(key) ? CHECK_ANNOTATION_TEXT_IGNORED : void 0;
196
+ const keyReason = (key) => generationKeyReason(key) ?? textKeyReason(key);
197
+ const entrySlotReason = (slot) => isAnnotationEntrySlot(slot) ? keyReason(slot.ancestor.key) : void 0;
198
+ const documentationSlotReason = (slot) => isDocumentationSlot(slot) ? ANNOTATION_TEXT_IGNORED : void 0;
199
+ const recursionBudgetSlotReason = (slot) => isRecursionBudgetSlot(slot) ? RECURSION_BUDGET_IGNORED : void 0;
200
+ const argumentSlotReason = (index, callee, reason) => (slot) => isArgumentSlot(slot, index, callee) ? reason : void 0;
201
+ const typeIdSlotReason = (node) => (slot) => isTypeIdSlot(node)(slot) ? TYPE_ID_IGNORED : void 0;
202
+ const isProductionCodecKey = (key) => isKeyOf(key, PRODUCTION_CODEC_KEYS);
203
+ const isProductionCodecSlot = (slot) => isAnnotationEntrySlot(slot) && isProductionCodecKey(slot.ancestor.key);
204
+ const isOutsideProductionCodec = (slots) => !slots.some(isProductionCodecSlot);
205
+ const isIgnorableLinkSlot = (slot, slots) => isArgumentSlot(slot, 1, isLinkCallee) && isOutsideProductionCodec(slots);
206
+ const linkSlotReason = (slot, slots) => isIgnorableLinkSlot(slot, slots) ? LINK_TRANSFORMATION_IGNORED : void 0;
207
+ const rulesFor = (node) => [
208
+ documentationSlotReason,
209
+ recursionBudgetSlotReason,
210
+ entrySlotReason,
211
+ linkSlotReason,
212
+ argumentSlotReason(0, isDefaultCallee, DECODING_DEFAULT_IGNORED),
213
+ typeIdSlotReason(node)
214
+ ];
215
+ const firstReasonOf = (slots, rules) => slots.flatMap((slot) => rules.map((rule) => rule(slot, slots))).find((reason) => reason !== void 0);
216
+ const subtreeReasonOf = (node, ctx) => firstReasonOf(slotsOf(node, ctx.ancestors), rulesFor(node));
217
+ const objectReasonOf = (node, ctx) => firstArgumentReason(OBJECT_ARGUMENT_RULES, node, ctx.parentIf("CallExpression")) ?? subtreeReasonOf(node, ctx);
218
+ const literalReasonOf = (node, ctx) => firstArgumentReason(LITERAL_ARGUMENT_RULES, node, ctx.parentIf("CallExpression")) ?? subtreeReasonOf(node, ctx);
219
+ const arrowReasonOf = (node, ctx) => firstArgumentReason(ARROW_ARGUMENT_RULES, node, ctx.parentIf("CallExpression")) ?? subtreeReasonOf(node, ctx);
220
+ const BY_TYPE_REASON = {
221
+ ObjectExpression: objectReasonOf,
222
+ Literal: literalReasonOf,
223
+ ArrowFunctionExpression: arrowReasonOf
67
224
  };
68
- const documentationValueReason = (node, ctx) => isDocumentedAnnotationValue(node, ctx) ? ANNOTATION_TEXT_IGNORED : void 0;
225
+ const ignoredReasonOf = (node, ctx) => (BY_TYPE_REASON[node.type] ?? subtreeReasonOf)(node, ctx);
69
226
  const strykerIgnorers = [defineIgnorer({
70
227
  name: "effect-schema-declarations",
71
- visitors: {
72
- Literal: (node, ctx) => {
73
- const parent = ctx.parentIf("CallExpression");
74
- return firstArgumentReason(LITERAL_ARGUMENT_RULES, node, parent) ?? documentationValueReason(node, ctx);
75
- },
76
- ObjectExpression: (node, ctx) => {
77
- const parent = ctx.parentIf("CallExpression");
78
- return firstArgumentReason(OBJECT_ARGUMENT_RULES, node, parent);
79
- },
80
- ArrowFunctionExpression: (node, ctx) => {
81
- const parent = ctx.parentIf("CallExpression");
82
- return firstArgumentReason(ARROW_ARGUMENT_RULES, node, parent);
83
- }
84
- }
228
+ visitors: { onAnyNode: ignoredReasonOf }
85
229
  })];
86
230
  //#endregion
87
- export { ANNOTATION_OBJECT_IGNORED, ANNOTATION_TEXT_IGNORED, BRAND_NAME_IGNORED, CLASS_ID_IGNORED, OPTIONAL_DEFAULT_IGNORED, SYMBOL_DESCRIPTION_IGNORED, TAGGED_FIELDS_IGNORED, TAGGED_TAG_IGNORED, strykerIgnorers };
231
+ export { ANNOTATION_OBJECT_IGNORED, ANNOTATION_TEXT_IGNORED, BRAND_NAME_IGNORED, CHECK_ANNOTATION_OBJECT_IGNORED, CHECK_ANNOTATION_TEXT_IGNORED, CLASS_ID_IGNORED, DECODING_DEFAULT_IGNORED, GENERATION_ANNOTATION_IGNORED, KEEP_ADVICE, KEEP_IGNORED_MUTANT, KEEP_RECURSION_BUDGET_MUTANT, LINK_TRANSFORMATION_IGNORED, OPTIONAL_DEFAULT_IGNORED, REASON_CODES, RECURSION_BUDGET_HOLDER_IGNORED, RECURSION_BUDGET_IGNORED, SYMBOL_DESCRIPTION_IGNORED, TAGGED_FIELDS_IGNORED, TAGGED_STRUCT_TAG_IGNORED, TAGGED_TAG_IGNORED, TYPE_ID_IGNORED, strykerIgnorers };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@systemfsoftware/stryker-ignorer-effect-schema-declarations",
3
3
  "license": "Apache-2.0",
4
- "version": "0.1.1",
4
+ "version": "0.3.1",
5
5
  "author": "Ryan Lee <drdgvhbh@gmail.com>",
6
6
  "repository": {
7
7
  "type": "git",
@@ -22,7 +22,8 @@
22
22
  ],
23
23
  "type": "module",
24
24
  "files": [
25
- "dist"
25
+ "dist",
26
+ "CHANGELOG.md"
26
27
  ],
27
28
  "exports": {
28
29
  ".": {
@@ -32,24 +33,25 @@
32
33
  "./package.json": "./package.json"
33
34
  },
34
35
  "dependencies": {
35
- "@systemfsoftware/stryker-ignorer-interface": "^0.1.1",
36
- "@systemfsoftware/stryker-ignorer-kit": "^0.1.1"
36
+ "@systemfsoftware/stryker-ignorer-interface": "^0.1.3",
37
+ "@systemfsoftware/stryker-ignorer-kit": "^0.1.3"
37
38
  },
38
39
  "devDependencies": {
39
- "@effect/tsgo": "^0.45.0",
40
+ "@effect/tsgo": "^0.63.0",
40
41
  "@microsoft/api-extractor": "^7",
41
42
  "@systemfsoftware/arethetypeswrong-cli": "^4.2.0",
42
- "@systemfsoftware/tsconfig": "^1.3.6",
43
+ "@systemfsoftware/oxlint-ignorer-config": "^0.1.3",
44
+ "@systemfsoftware/tsconfig": "^2.0.1",
45
+ "@systemfsoftware/tsdown-config": "^0.1.0",
46
+ "@systemfsoftware/vitest": "^2.0.0",
47
+ "@systemfsoftware/vitest-config": "^0.1.0",
43
48
  "@types/node": "^24",
44
49
  "@vitest/coverage-v8": "^5",
45
- "oxlint": "^1",
50
+ "oxlint": "~1.90.0",
46
51
  "rimraf": "^6.1.3",
47
52
  "tsdown": "^0.23.0",
48
53
  "typescript": "^7",
49
- "vitest": "^5",
50
- "@systemfsoftware/tsdown-config": "^0.1.0",
51
- "@systemfsoftware/oxlint-ignorer-config": "^0.1.1",
52
- "@systemfsoftware/vitest-config": "^0.1.0"
54
+ "vitest": "^5"
53
55
  },
54
56
  "publishConfig": {
55
57
  "access": "public",
@@ -58,12 +60,12 @@
58
60
  "scripts": {
59
61
  "build": "tsdown",
60
62
  "clean": "rimraf dist",
61
- "typecheck": "tsc --noEmit --incremental && tsc -p tsconfig.node.json --noEmit",
63
+ "typecheck": "tsc -b",
62
64
  "test": "vitest run",
63
65
  "lint": "f=${OXLINT_FORMAT:-${AGENT:+agent}}; oxlint . --format=${f:-default}",
64
66
  "attw": "attw --pack .",
65
67
  "api:check": "api-extractor run",
66
68
  "api:update": "api-extractor run --local",
67
- "lint:tsgo": "effect-tsgo diagnostics --project tsconfig.json --format ${TSGO_FORMAT:-text}"
69
+ "lint:tsgo": "effect-tsgo diagnostics --project tsconfig.app.json --format ${TSGO_FORMAT:-text} && effect-tsgo diagnostics --project tsconfig.test.json --format ${TSGO_FORMAT:-text}"
68
70
  }
69
71
  }