@systemfsoftware/stryker-js-typescript-checker 0.1.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.
Files changed (55) hide show
  1. package/.turbo/turbo-build.log +15 -0
  2. package/.turbo/turbo-lint.log +3 -0
  3. package/LICENSE +21 -0
  4. package/dist/index.d.mts +122 -0
  5. package/dist/index.mjs +602 -0
  6. package/oxlint.config.ts +9 -0
  7. package/package.json +37 -0
  8. package/schema/typescript-checker-options.json +22 -0
  9. package/src/fs/hybrid-file-system.ts +118 -0
  10. package/src/fs/index.ts +2 -0
  11. package/src/fs/script-file.ts +44 -0
  12. package/src/grouping/create-groups.ts +77 -0
  13. package/src/grouping/ts-file-node.ts +54 -0
  14. package/src/index.ts +18 -0
  15. package/src/plugin-tokens.ts +2 -0
  16. package/src/tsconfig-helpers.ts +168 -0
  17. package/src/typescript-checker-options-with-stryker-options.ts +9 -0
  18. package/src/typescript-checker.ts +223 -0
  19. package/src/typescript-compiler.ts +406 -0
  20. package/test/integration/e2e-plugin-entry.it.spec.ts +153 -0
  21. package/test/integration/project-references.it.spec.ts +146 -0
  22. package/test/integration/project-with-ts-buildinfo.it.spec.ts +92 -0
  23. package/test/integration/single-project.it.spec.ts +263 -0
  24. package/test/integration/typescript-checkers-errors.it.spec.ts +87 -0
  25. package/test/unit/fs/hybrid-file-system.spec.ts +109 -0
  26. package/test/unit/grouping/create-groups.spec.ts +122 -0
  27. package/test/unit/grouping/ts-file-node.spec.ts +132 -0
  28. package/testResources/errors/compile-error/add.ts +3 -0
  29. package/testResources/errors/compile-error/tsconfig.json +6 -0
  30. package/testResources/errors/empty-dir/.gitkeep +0 -0
  31. package/testResources/errors/invalid-tsconfig/tsconfig.json +1 -0
  32. package/testResources/project-references/src/index.ts +5 -0
  33. package/testResources/project-references/src/job.ts +6 -0
  34. package/testResources/project-references/src/src.tsbuildinfo +1 -0
  35. package/testResources/project-references/src/tsconfig.json +10 -0
  36. package/testResources/project-references/tsconfig.root.json +7 -0
  37. package/testResources/project-references/tsconfig.settings.json +17 -0
  38. package/testResources/project-references/utils/math.ts +3 -0
  39. package/testResources/project-references/utils/text.ts +3 -0
  40. package/testResources/project-references/utils/tsconfig.json +7 -0
  41. package/testResources/project-references/utils/utils.tsbuildinfo +1 -0
  42. package/testResources/project-with-ts-buildinfo/do-not-delete.tsbuildinfo +1 -0
  43. package/testResources/project-with-ts-buildinfo/src/index.ts +3 -0
  44. package/testResources/project-with-ts-buildinfo/tsconfig.json +17 -0
  45. package/testResources/single-project/src/counter.ts +9 -0
  46. package/testResources/single-project/src/errorInFileAbove2Mutants/counter.ts +9 -0
  47. package/testResources/single-project/src/errorInFileAbove2Mutants/todo-counter.ts +7 -0
  48. package/testResources/single-project/src/errorInFileAbove2Mutants/todo.spec.ts +11 -0
  49. package/testResources/single-project/src/errorInFileAbove2Mutants/todo.ts +22 -0
  50. package/testResources/single-project/src/not-type-checked.js +1 -0
  51. package/testResources/single-project/src/todo.spec.ts +11 -0
  52. package/testResources/single-project/src/todo.ts +22 -0
  53. package/testResources/single-project/tsconfig.json +15 -0
  54. package/tsconfig.json +10 -0
  55. package/vitest.config.ts +11 -0
@@ -0,0 +1,15 @@
1
+ $ tsdown
2
+ ℹ tsdown v0.22.7 powered by rolldown v1.1.5
3
+ ℹ config file: /mnt/projects/God/systemfsoftware/packages/stryker-js/typescript-checker/package.json
4
+ ℹ entry: src/index.ts
5
+ ℹ tsconfig: tsconfig.json
6
+ ℹ Build start
7
+ ℹ Cleaning 2 files
8
+
9
+ WARN TypeScript 7.0 does not yet have a stable API and is experimental. Some options will be unavailable.
10
+
11
+ ℹ Emit types with typescript@7.0.2
12
+ ℹ dist/index.mjs 23.95 kB │ gzip: 6.75 kB
13
+ ℹ dist/index.d.mts 4.66 kB │ gzip: 1.52 kB
14
+ ℹ 2 files, total: 28.61 kB
15
+ ✔ Build complete in 1441ms
@@ -0,0 +1,3 @@
1
+ $ oxlint . --format=github
2
+ Found 0 warnings and 0 errors.
3
+ Finished in 103ms on 21 files with 94 rules using 12 threads.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ryan Lee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,122 @@
1
+ import { PluginKind } from "@stryker-mutator/api/plugin";
2
+ import { CheckResult, Checker } from "@stryker-mutator/api/check";
3
+ import { Diagnostic } from "typescript/unstable/sync";
4
+ import { Mutant, StrykerOptions } from "@stryker-mutator/api/core";
5
+ import { Logger } from "@stryker-mutator/api/logging";
6
+ import { FileSystem, FileSystemEntries } from "typescript/unstable/fs";
7
+ //#region src/fs/script-file.d.ts
8
+ declare class ScriptFile {
9
+ content: string;
10
+ fileName: string;
11
+ modifiedTime: Date;
12
+ private readonly originalContent;
13
+ constructor(content: string, fileName: string, modifiedTime?: Date);
14
+ write(content: string): void;
15
+ mutate(mutant: Pick<Mutant, 'location' | 'replacement'>): void;
16
+ private getOffset;
17
+ resetMutant(): void;
18
+ private touch;
19
+ }
20
+ //#endregion
21
+ //#region src/fs/hybrid-file-system.d.ts
22
+ /**
23
+ * A very simple hybrid file system.
24
+ * * Readonly from disk
25
+ * * Writes in-memory
26
+ * * Hard caching
27
+ * * Ability to mutate one file
28
+ */
29
+ declare class HybridFileSystem implements FileSystem {
30
+ private readonly files;
31
+ /**
32
+ * Map of absolute tsconfig file paths to their adjusted JSON content.
33
+ * This allows the TS7 API to read overridden compiler options.
34
+ */
35
+ tsConfigOverrides: Map<string, string>;
36
+ readFile: (fileName: string) => string | null | undefined;
37
+ fileExists: (fileName: string) => boolean | undefined;
38
+ directoryExists: () => boolean | undefined;
39
+ getAccessibleEntries: () => FileSystemEntries | undefined;
40
+ realpath: () => string | undefined;
41
+ writeFile(fileName: string, data: string): void;
42
+ getFile(fileName: string): ScriptFile | undefined;
43
+ mutateFile(fileName: string, mutant: Parameters<ScriptFile['mutate']>[0]): void;
44
+ resetFile(fileName: string): void;
45
+ existsInMemory(fileName: string): boolean;
46
+ private fileNameIsBuildInfo;
47
+ }
48
+ //#endregion
49
+ //#region src/grouping/ts-file-node.d.ts
50
+ declare class TSFileNode {
51
+ fileName: string;
52
+ parents: TSFileNode[];
53
+ children: TSFileNode[];
54
+ constructor(fileName: string, parents: TSFileNode[], children: TSFileNode[]);
55
+ getAllParentReferencesIncludingSelf(allParentReferences?: Set<TSFileNode>): Set<TSFileNode>;
56
+ getAllChildReferencesIncludingSelf(allChildReferences?: Set<TSFileNode>): Set<TSFileNode>;
57
+ getMutantsWithReferenceToChildrenOrSelf(mutants: Mutant[], nodesChecked?: string[]): Mutant[];
58
+ }
59
+ //#endregion
60
+ //#region src/typescript-compiler.d.ts
61
+ interface ITypescriptCompiler {
62
+ init(): Promise<Diagnostic[]>;
63
+ check(mutants: Mutant[]): Promise<Diagnostic[]>;
64
+ }
65
+ interface IFileRelationCreator {
66
+ get nodes(): Map<string, TSFileNode>;
67
+ }
68
+ declare class TypescriptCompiler implements ITypescriptCompiler, IFileRelationCreator {
69
+ private readonly log;
70
+ private readonly options;
71
+ private readonly fs;
72
+ static inject: ["logger", "options", "fs"];
73
+ private readonly allTSConfigFiles;
74
+ private readonly tsconfigFile;
75
+ private api?;
76
+ private snapshot?;
77
+ private readonly sourceFiles;
78
+ private readonly _nodes;
79
+ private lastMutants;
80
+ private lastMutatedFileNames;
81
+ constructor(log: Logger, options: StrykerOptions, fs: HybridFileSystem);
82
+ init(): Promise<Diagnostic[]>;
83
+ check(mutants: Mutant[]): Promise<Diagnostic[]>;
84
+ get nodes(): Map<string, TSFileNode>;
85
+ close(): void;
86
+ getLineAndCharacterOfPosition(fileName: string, position: number): {
87
+ line: number;
88
+ character: number;
89
+ } | undefined;
90
+ private getPrograms;
91
+ private collectAllTSConfigFiles;
92
+ private buildDependencyGraph;
93
+ private extractImports;
94
+ private resolveModuleSpecifier;
95
+ private getResolutionCandidates;
96
+ private resolveTSInputFile;
97
+ private guardTSConfigFileExists;
98
+ }
99
+ //#endregion
100
+ //#region src/typescript-checker.d.ts
101
+ declare class TypescriptChecker implements Checker {
102
+ private readonly logger;
103
+ private readonly tsCompiler;
104
+ static inject: ["logger", "options", "tsCompiler"];
105
+ private readonly options;
106
+ constructor(logger: Logger, options: StrykerOptions, tsCompiler: TypescriptCompiler);
107
+ init(): Promise<void>;
108
+ check(mutants: Mutant[]): Promise<Record<string, CheckResult>>;
109
+ group(mutants: Mutant[]): Promise<string[][]>;
110
+ private checkErrors;
111
+ private createErrorText;
112
+ private formatDiagnostic;
113
+ }
114
+ //#endregion
115
+ //#region src/index.d.ts
116
+ declare const strykerPlugins: import("@stryker-mutator/api/plugin").FactoryPlugin<PluginKind.Checker, ["$injector"]>[];
117
+ declare const createTypescriptChecker: ((injector: import("@stryker-mutator/api/plugin").Injector<import("@stryker-mutator/api/plugin").PluginContext>) => TypescriptChecker) & {
118
+ inject: ["$injector"];
119
+ };
120
+ declare const strykerValidationSchema: Record<string, unknown>;
121
+ //#endregion
122
+ export { createTypescriptChecker, strykerPlugins, strykerValidationSchema };