no-mistakes 0.26.0 → 0.27.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/README.md CHANGED
@@ -8,6 +8,7 @@ npm install --save-dev no-mistakes
8
8
  npx no-mistakes dependencies src/main.mts --json
9
9
  npx no-mistakes dependents src/utils.mts --json
10
10
  npx no-mistakes symbols src/utils.mts --json
11
+ npx no-mistakes import-usages --root . --filter 'src/**' --json
11
12
  npx no-mistakes check --json
12
13
  ```
13
14
 
@@ -19,15 +20,19 @@ const {
19
20
  dependents,
20
21
  check,
21
22
  fetches,
23
+ importUsages,
24
+ flow,
22
25
  playwrightRelated,
23
26
  symbols,
24
27
  testsPlan,
28
+ testsTargets,
25
29
  queueEdges,
26
30
  queueRelated,
27
31
  queueCheck,
28
32
  serverRouteList,
29
33
  serverRouteEdges,
30
34
  serverRouteRelated,
35
+ serverContracts,
31
36
  reactAnalyze,
32
37
  reactCheck,
33
38
  } = require("no-mistakes");
@@ -48,6 +53,10 @@ const {
48
53
  files: ["src/utils.mts"],
49
54
  include: "both",
50
55
  });
56
+ const imports = await importUsages({
57
+ root: process.cwd(),
58
+ filters: ["src/**"],
59
+ });
51
60
  const signatureImpact = await symbols({
52
61
  root: process.cwd(),
53
62
  files: ["src/utils.mts"],
@@ -59,10 +68,21 @@ const {
59
68
  framework: "vitest", // also supports "playwright" and "swift"
60
69
  changedFiles: ["src/utils.mts"],
61
70
  });
71
+ const targetCommands = await testsTargets({
72
+ root: process.cwd(),
73
+ framework: "vitest",
74
+ files: ["src/utils.test.mts"],
75
+ });
62
76
  const projectCheck = await check({
63
77
  root: process.cwd(),
64
78
  tsconfig: "tsconfig.json",
65
79
  });
80
+ const localFlow = await flow({
81
+ root: process.cwd(),
82
+ target: "src/utils.mts#parseDate",
83
+ direction: "dependents",
84
+ depth: 1,
85
+ });
66
86
  const coveredByPlaywright = await playwrightRelated({
67
87
  root: process.cwd(),
68
88
  files: ["web/app/users/page.tsx"],
@@ -77,6 +97,10 @@ const {
77
97
  root: process.cwd(),
78
98
  roots: ["src/server.ts"],
79
99
  });
100
+ const contracts = await serverContracts({
101
+ root: process.cwd(),
102
+ roots: ["src/server.ts"],
103
+ });
80
104
  const components = await reactAnalyze({
81
105
  root: process.cwd(),
82
106
  targets: ["app/**/*.tsx"],
@@ -0,0 +1,41 @@
1
+ import type { Relationship } from "./traversal-types";
2
+
3
+ export interface FlowOptions {
4
+ target: string;
5
+ root?: string;
6
+ tsconfig?: string;
7
+ config?: string;
8
+ direction?: "deps" | "dependents" | "both";
9
+ depth?: number;
10
+ relationships?: Relationship[];
11
+ }
12
+
13
+ export interface FlowNode {
14
+ id: string;
15
+ kind: "file" | "symbol" | "module" | "queue-job";
16
+ depth: number;
17
+ file?: string;
18
+ symbol?: string;
19
+ module?: string;
20
+ queueFile?: string;
21
+ job?: string;
22
+ }
23
+
24
+ export interface FlowEdge {
25
+ from: string;
26
+ to: string;
27
+ kind: string;
28
+ }
29
+
30
+ export interface FlowReport {
31
+ root: string;
32
+ target: string;
33
+ nodes: FlowNode[];
34
+ edges: FlowEdge[];
35
+ }
36
+
37
+ export interface FetchesOptions {
38
+ root?: string;
39
+ config?: string;
40
+ targets?: string[];
41
+ }
@@ -0,0 +1,27 @@
1
+ export type ImportUsageKind = "static" | "type" | "dynamic" | "require" | "require-resolve";
2
+
3
+ export interface ImportUsage {
4
+ specifier: string;
5
+ packageName: string | null;
6
+ kind: ImportUsageKind;
7
+ line: number;
8
+ sideEffectOnly: boolean;
9
+ reExport: boolean;
10
+ }
11
+
12
+ export interface ImportUsageFile {
13
+ path: string;
14
+ imports: ImportUsage[];
15
+ }
16
+
17
+ export interface ImportUsagesOptions {
18
+ files?: string[];
19
+ root?: string;
20
+ scanRoots?: string[];
21
+ filters?: string[];
22
+ }
23
+
24
+ export interface ImportUsagesResult {
25
+ roots: string[];
26
+ files: ImportUsageFile[];
27
+ }
package/index.d.ts CHANGED
@@ -22,8 +22,12 @@ import type {
22
22
  ExportsOfOptions,
23
23
  ExportsOfResult,
24
24
  FetchesOptions,
25
+ FlowOptions,
26
+ FlowReport,
25
27
  ImpactedChecksOptions,
26
28
  ImpactedChecksReport,
29
+ ImportUsagesOptions,
30
+ ImportUsagesResult,
27
31
  ImportersOptions,
28
32
  ImportersResult,
29
33
  ResolveCheckOptions,
@@ -42,6 +46,7 @@ import type {
42
46
  ReactViolation,
43
47
  ResourceRefRow,
44
48
  ServerRoutesReport,
49
+ ServerContractsReport,
45
50
  SignatureImpactResult,
46
51
  SwiftImporterRow,
47
52
  SwiftOptions,
@@ -56,6 +61,8 @@ import type {
56
61
  TestsImpactOptions,
57
62
  TestsPlanDocumentOptions,
58
63
  TestsPlanOptions,
64
+ TestsTargetsOptions,
65
+ TestsTargetsReport,
59
66
  TestsWhyOptions,
60
67
  TraverseOptions,
61
68
  WhyStep,
@@ -70,15 +77,18 @@ export function analyzeProject(options: AnalyzeProjectOptions): Promise<AnalyzeP
70
77
  export function symbols(options: SymbolsSignatureImpactOptions): Promise<SignatureImpactResult>;
71
78
  export function symbols(options: SymbolsListOptions): Promise<SymbolsResult>;
72
79
  export function symbols(options: SymbolsOptions): Promise<SymbolsResult | SignatureImpactResult>;
80
+ export function importUsages(options?: ImportUsagesOptions): Promise<ImportUsagesResult>;
73
81
  export function importers(options: ImportersOptions): Promise<ImportersResult>;
74
82
  export function exportsOf(options: ExportsOfOptions): Promise<ExportsOfResult>;
75
83
  export function deadExports(options: DeadExportsOptions): Promise<DeadExportsResult>;
76
84
  export function callSites(options: CallSitesOptions): Promise<CallSitesResult>;
77
85
  export function resolveCheck(options: ResolveCheckOptions): Promise<ResolveCheckResult>;
78
86
  export function fetches(options?: FetchesOptions): Promise<unknown>;
87
+ export function flow(options: FlowOptions): Promise<FlowReport>;
79
88
  export function check(options?: ProjectOptions): Promise<CheckReport>;
80
89
  export function testsPlan(options: TestsPlanOptions): Promise<TestPlan>;
81
90
  export function testsImpact(options: TestsImpactOptions): Promise<TestPlan>;
91
+ export function testsTargets(options: TestsTargetsOptions): Promise<TestsTargetsReport>;
82
92
  export function testsWhy(options: TestsWhyOptions): Promise<Record<string, WhyStep[]>>;
83
93
  export function testsComment(options: TestsPlanDocumentOptions): Promise<string>;
84
94
  export function testsGraph(options: TestsPlanDocumentOptions): Promise<TestGraph>;
@@ -95,6 +105,7 @@ export function serverRoutes(options?: ProjectOptions): Promise<ServerRoutesRepo
95
105
  export function serverRouteList(options?: ProjectOptions): Promise<unknown[]>;
96
106
  export function serverRouteEdges(options?: ProjectOptions): Promise<GraphEdge[]>;
97
107
  export function serverRouteRelated(options: ProjectOptions): Promise<GraphEdge[]>;
108
+ export function serverContracts(options?: ProjectOptions): Promise<ServerContractsReport>;
98
109
  export function reactAnalyze(options?: ProjectOptions): Promise<ReactComponentFacts[]>;
99
110
  export function reactCheck(options?: ProjectOptions): Promise<ReactViolation[]>;
100
111
  export function reactUsages(
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  const native = require("./bin/no-mistakes.node");
4
+ const planning = require("./planning");
4
5
 
5
6
  async function callJson(fn, options) {
6
7
  return JSON.parse(await fn(JSON.stringify(options || {})));
@@ -26,6 +27,10 @@ async function symbols(options) {
26
27
  return callJson(native.symbolsJson, options);
27
28
  }
28
29
 
30
+ async function importUsages(options) {
31
+ return callJson(native.importUsagesJson, options);
32
+ }
33
+
29
34
  async function importers(options) {
30
35
  return callJson(native.importersJson, options);
31
36
  }
@@ -54,30 +59,6 @@ async function check(options) {
54
59
  return callJson(native.checkJson, options);
55
60
  }
56
61
 
57
- async function testsPlan(options) {
58
- return callJson(native.testsPlanJson, options);
59
- }
60
-
61
- async function testsImpact(options) {
62
- return callJson(native.testsImpactJson, options);
63
- }
64
-
65
- async function testsWhy(options) {
66
- return callJson(native.testsWhyJson, options);
67
- }
68
-
69
- async function testsComment(options) {
70
- return native.testsCommentMarkdown(JSON.stringify(options || {}));
71
- }
72
-
73
- async function testsGraph(options) {
74
- return callJson(native.testsGraphJson, options);
75
- }
76
-
77
- async function testsGraphMermaid(options) {
78
- return native.testsGraphMermaid(JSON.stringify(options || {}));
79
- }
80
-
81
62
  async function playwrightCheck(options) {
82
63
  return callJson(native.playwrightCheckJson, options);
83
64
  }
@@ -94,38 +75,6 @@ async function playwrightTests(options) {
94
75
  return callJson(native.playwrightTestsJson, options);
95
76
  }
96
77
 
97
- async function queues(options) {
98
- return callJson(native.queuesJson, options);
99
- }
100
-
101
- async function queueEdges(options) {
102
- return callJson(native.queueEdgesJson, options);
103
- }
104
-
105
- async function queueRelated(options) {
106
- return callJson(native.queueRelatedJson, options);
107
- }
108
-
109
- async function queueCheck(options) {
110
- return callJson(native.queueCheckJson, options);
111
- }
112
-
113
- async function serverRoutes(options) {
114
- return callJson(native.serverRoutesJson, options);
115
- }
116
-
117
- async function serverRouteList(options) {
118
- return callJson(native.serverRouteListJson, options);
119
- }
120
-
121
- async function serverRouteEdges(options) {
122
- return callJson(native.serverRouteEdgesJson, options);
123
- }
124
-
125
- async function serverRouteRelated(options) {
126
- return callJson(native.serverRouteRelatedJson, options);
127
- }
128
-
129
78
  async function reactAnalyze(options) {
130
79
  return callJson(native.reactAnalyzeJson, options);
131
80
  }
@@ -208,6 +157,7 @@ module.exports = {
208
157
  exportsOf,
209
158
  fetches,
210
159
  impactedChecks,
160
+ importUsages,
211
161
  importers,
212
162
  infraOutputs,
213
163
  infraResourceRefs,
@@ -217,10 +167,6 @@ module.exports = {
217
167
  playwrightEdges,
218
168
  playwrightRelated,
219
169
  playwrightTests,
220
- queues,
221
- queueCheck,
222
- queueEdges,
223
- queueRelated,
224
170
  reactAnalyze,
225
171
  reactCheck,
226
172
  reactUsages,
@@ -228,18 +174,9 @@ module.exports = {
228
174
  related,
229
175
  resolveCheck,
230
176
  rscCallers,
231
- serverRouteEdges,
232
- serverRouteList,
233
- serverRouteRelated,
234
- serverRoutes,
235
177
  swiftImporters,
236
178
  swiftTestTargets,
237
179
  symbols,
238
- testsComment,
239
- testsGraph,
240
- testsGraphMermaid,
241
- testsImpact,
242
- testsPlan,
243
- testsWhy,
244
180
  version,
181
+ ...planning,
245
182
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "no-mistakes",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "Static codebase analysis tools for TS/JS dependencies, dependents, and symbols",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -15,6 +15,7 @@
15
15
  "bin/",
16
16
  "*.d.ts",
17
17
  "index.js",
18
+ "planning.js",
18
19
  "scripts/install.js",
19
20
  "scripts/install/",
20
21
  "README.md",
package/planning.js ADDED
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ const native = require("./bin/no-mistakes.node");
4
+
5
+ async function callJson(fn, options) {
6
+ return JSON.parse(await fn(JSON.stringify(options || {})));
7
+ }
8
+
9
+ async function testsTargets(options) {
10
+ return callJson(native.testsTargetsJson, options);
11
+ }
12
+
13
+ async function testsPlan(options) {
14
+ return callJson(native.testsPlanJson, options);
15
+ }
16
+
17
+ async function testsImpact(options) {
18
+ return callJson(native.testsImpactJson, options);
19
+ }
20
+
21
+ async function testsWhy(options) {
22
+ return callJson(native.testsWhyJson, options);
23
+ }
24
+
25
+ async function testsComment(options) {
26
+ return native.testsCommentMarkdown(JSON.stringify(options || {}));
27
+ }
28
+
29
+ async function testsGraph(options) {
30
+ return callJson(native.testsGraphJson, options);
31
+ }
32
+
33
+ async function testsGraphMermaid(options) {
34
+ return native.testsGraphMermaid(JSON.stringify(options || {}));
35
+ }
36
+
37
+ async function queues(options) {
38
+ return callJson(native.queuesJson, options);
39
+ }
40
+
41
+ async function queueEdges(options) {
42
+ return callJson(native.queueEdgesJson, options);
43
+ }
44
+
45
+ async function queueRelated(options) {
46
+ return callJson(native.queueRelatedJson, options);
47
+ }
48
+
49
+ async function queueCheck(options) {
50
+ return callJson(native.queueCheckJson, options);
51
+ }
52
+
53
+ async function serverRoutes(options) {
54
+ return callJson(native.serverRoutesJson, options);
55
+ }
56
+
57
+ async function serverRouteList(options) {
58
+ return callJson(native.serverRouteListJson, options);
59
+ }
60
+
61
+ async function serverRouteEdges(options) {
62
+ return callJson(native.serverRouteEdgesJson, options);
63
+ }
64
+
65
+ async function serverRouteRelated(options) {
66
+ return callJson(native.serverRouteRelatedJson, options);
67
+ }
68
+
69
+ async function serverContracts(options) {
70
+ return callJson(native.serverContractsJson, options);
71
+ }
72
+
73
+ async function flow(options) {
74
+ return callJson(native.flowJson, options);
75
+ }
76
+
77
+ module.exports = {
78
+ flow,
79
+ queueCheck,
80
+ queueEdges,
81
+ queueRelated,
82
+ queues,
83
+ serverContracts,
84
+ serverRouteEdges,
85
+ serverRouteList,
86
+ serverRouteRelated,
87
+ serverRoutes,
88
+ testsComment,
89
+ testsGraph,
90
+ testsGraphMermaid,
91
+ testsImpact,
92
+ testsPlan,
93
+ testsTargets,
94
+ testsWhy,
95
+ };
@@ -78,6 +78,13 @@ function request(
78
78
  return;
79
79
  }
80
80
 
81
+ try {
82
+ validateUrl(redirectedUrl.toString());
83
+ } catch (error) {
84
+ reject(error);
85
+ return;
86
+ }
87
+
81
88
  request(
82
89
  redirectedUrl.toString(),
83
90
  handleResponse,
@@ -0,0 +1,29 @@
1
+ export interface ServerContractsReport {
2
+ routes: ServerRouteContract[];
3
+ clientRefs: ServerContractClientRef[];
4
+ mismatches: ServerContractMismatch[];
5
+ }
6
+
7
+ export interface ServerRouteContract {
8
+ file: string;
9
+ line: number;
10
+ method: string;
11
+ route: string;
12
+ queryParams: string[];
13
+ }
14
+
15
+ export interface ServerContractClientRef {
16
+ file: string;
17
+ line: number;
18
+ route: string;
19
+ queryParams: string[];
20
+ matchedRoute?: string | null;
21
+ }
22
+
23
+ export interface ServerContractMismatch {
24
+ file: string;
25
+ line: number;
26
+ route: string;
27
+ matchedRoute: string;
28
+ missingParams: string[];
29
+ }
package/test-types.d.ts CHANGED
@@ -31,6 +31,13 @@ export interface TestsImpactOptions {
31
31
  includeSymbols?: boolean;
32
32
  }
33
33
 
34
+ export interface TestsTargetsOptions {
35
+ framework: "vitest" | "playwright" | "swift";
36
+ root?: string;
37
+ config?: string;
38
+ files: string[];
39
+ }
40
+
34
41
  export interface TestPlan {
35
42
  selected_tests: SelectedTest[];
36
43
  groups?: TestPlanGroup[];
@@ -73,6 +80,23 @@ export interface TestPlanWarning {
73
80
  file: string;
74
81
  }
75
82
 
83
+ export interface TestsTargetsReport {
84
+ framework: "vitest" | "playwright" | "swift";
85
+ tests: TestTargetRow[];
86
+ warnings: TestTargetWarning[];
87
+ }
88
+
89
+ export interface TestTargetRow {
90
+ testFile: string;
91
+ targets: TestExecutionTarget[];
92
+ }
93
+
94
+ export interface TestTargetWarning {
95
+ type: string;
96
+ message: string;
97
+ file: string;
98
+ }
99
+
76
100
  export interface TestsWhyOptions {
77
101
  root?: string;
78
102
  config?: string;
@@ -1,3 +1,5 @@
1
+ import type { ImportUsagesOptions } from "./import-usage-types";
2
+ import type { FlowOptions } from "./flow-types";
1
3
  import type { PlaywrightOptions, PlaywrightRelatedOptions } from "./report-types";
2
4
 
3
5
  export type Relationship =
@@ -172,28 +174,26 @@ export interface ProjectOptions {
172
174
  }
173
175
 
174
176
  type BatchedProjectOptions = Omit<ProjectOptions, "root" | "tsconfig" | "config">;
177
+ type BatchedFlowOptions = Omit<FlowOptions, "root" | "tsconfig" | "config">;
175
178
  type BatchedQueueRelatedOptions = BatchedProjectOptions & { files: string[] };
176
179
  type BatchedServerRouteRelatedOptions = BatchedProjectOptions &
177
180
  ({ files: string[] } | { roots: string[] });
178
181
 
179
- export interface FetchesOptions {
180
- root?: string;
181
- config?: string;
182
- targets?: string[];
183
- }
184
-
185
182
  export type AnalyzeProjectReportRequest =
186
183
  | ({ type: "dependencies" | "dependents" | "related"; id?: string } & Omit<
187
184
  TraverseOptions,
188
185
  "root" | "tsconfig"
189
186
  >)
190
187
  | ({ type: "symbols"; id?: string } & (SymbolsListOptions | SymbolsSignatureImpactOptions))
188
+ | ({ type: "importUsages"; id?: string } & Omit<ImportUsagesOptions, "root">)
189
+ | ({ type: "flow"; id?: string } & BatchedFlowOptions)
191
190
  | ({ type: "queues" | "queueEdges" | "queueCheck"; id?: string } & BatchedProjectOptions)
192
191
  | ({ type: "queueRelated"; id?: string } & BatchedQueueRelatedOptions)
193
192
  | ({
194
193
  type: "serverRoutes" | "serverRouteList" | "serverRouteEdges";
195
194
  id?: string;
196
195
  } & BatchedProjectOptions)
196
+ | ({ type: "serverContracts"; id?: string } & BatchedProjectOptions)
197
197
  | ({ type: "serverRouteRelated"; id?: string } & BatchedServerRouteRelatedOptions)
198
198
  | ({ type: "reactAnalyze" | "reactCheck"; id?: string } & Pick<
199
199
  ProjectOptions,
package/types.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  export * from "./traversal-types";
2
+ export * from "./flow-types";
3
+ export * from "./import-usage-types";
2
4
  export * from "./test-types";
3
5
  export * from "./report-types";
6
+ export * from "./server-contract-types";
4
7
  export * from "./ci-types";
5
8
  export * from "./query-types";
6
9
  export * from "./named-query-types";