no-mistakes 0.20.0 → 0.21.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
@@ -48,6 +48,12 @@ const {
48
48
  files: ["src/utils.mts"],
49
49
  include: "both",
50
50
  });
51
+ const signatureImpact = await symbols({
52
+ root: process.cwd(),
53
+ files: ["src/utils.mts"],
54
+ mode: "signature-impact",
55
+ symbol: "parseDate",
56
+ });
51
57
  const plan = await testsPlan({
52
58
  root: process.cwd(),
53
59
  framework: "vitest",
package/index.d.ts CHANGED
@@ -15,8 +15,11 @@ import type {
15
15
  ReactUsagesReport,
16
16
  ReactViolation,
17
17
  ServerRoutesReport,
18
+ SignatureImpactResult,
19
+ SymbolsListOptions,
18
20
  SymbolsOptions,
19
21
  SymbolsResult,
22
+ SymbolsSignatureImpactOptions,
20
23
  TestGraph,
21
24
  TestPlan,
22
25
  TestsImpactOptions,
@@ -33,7 +36,9 @@ export function dependencies(options: TraverseOptions): Promise<DependencyResult
33
36
  export function dependents(options: TraverseOptions): Promise<DependencyResult>;
34
37
  export function related(options: TraverseOptions): Promise<DependencyResult>;
35
38
  export function analyzeProject(options: AnalyzeProjectOptions): Promise<AnalyzeProjectResult>;
36
- export function symbols(options: SymbolsOptions): Promise<SymbolsResult>;
39
+ export function symbols(options: SymbolsSignatureImpactOptions): Promise<SignatureImpactResult>;
40
+ export function symbols(options: SymbolsListOptions): Promise<SymbolsResult>;
41
+ export function symbols(options: SymbolsOptions): Promise<SymbolsResult | SignatureImpactResult>;
37
42
  export function fetches(options?: FetchesOptions): Promise<unknown>;
38
43
  export function check(options?: ProjectOptions): Promise<CheckReport>;
39
44
  export function testsPlan(options: TestsPlanOptions): Promise<TestPlan>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "no-mistakes",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Static codebase analysis tools for TS/JS dependencies, dependents, and symbols",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -60,8 +60,26 @@ function request(
60
60
  reject(new Error(`Redirect missing Location header while downloading ${url}`));
61
61
  return;
62
62
  }
63
+
64
+ let redirectedUrl;
65
+ try {
66
+ redirectedUrl = new URL(response.headers.location, url);
67
+ } catch {
68
+ reject(
69
+ new Error(
70
+ `Invalid redirect Location header while downloading ${url}: ${response.headers.location}`,
71
+ ),
72
+ );
73
+ return;
74
+ }
75
+
76
+ if (redirectedUrl.protocol !== "http:" && redirectedUrl.protocol !== "https:") {
77
+ reject(new Error(`Unsupported redirect protocol: ${redirectedUrl.protocol}`));
78
+ return;
79
+ }
80
+
63
81
  request(
64
- new URL(response.headers.location, url).toString(),
82
+ redirectedUrl.toString(),
65
83
  handleResponse,
66
84
  redirects + 1,
67
85
  clients,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- const { createHash } = require("node:crypto");
3
+ const { createHash, randomBytes } = require("node:crypto");
4
4
  const { closeSync, createReadStream, existsSync, openSync, readSync } = require("node:fs");
5
5
  const { chmod, mkdir, rename, rm } = require("node:fs/promises");
6
6
  const { join } = require("node:path");
@@ -60,7 +60,7 @@ async function install(binName, repository, options = {}) {
60
60
  const validateReleaseDownloadUrl = (url) =>
61
61
  validateReleaseBaseUrl(url, repository, { enforcePath: false });
62
62
 
63
- const temp = `${destination}.tmp-${process.pid}`;
63
+ const temp = `${destination}.tmp-${randomBytes(8).toString("hex")}`;
64
64
 
65
65
  await mkdir(vendorDir, { recursive: true });
66
66
 
@@ -68,10 +68,23 @@ export interface SymbolsOptions {
68
68
  files: string[];
69
69
  root?: string;
70
70
  tsconfig?: string;
71
+ config?: string;
72
+ mode?: "list" | "signature-impact";
73
+ symbol?: string;
71
74
  kinds?: ExportKind[];
72
75
  include?: "exports" | "imports" | "both";
73
76
  }
74
77
 
78
+ export type SymbolsListOptions = Omit<SymbolsOptions, "mode" | "symbol"> & {
79
+ mode?: "list";
80
+ symbol?: string;
81
+ };
82
+
83
+ export type SymbolsSignatureImpactOptions = SymbolsOptions & {
84
+ mode: "signature-impact";
85
+ symbol: string;
86
+ };
87
+
75
88
  export interface SymbolExport {
76
89
  name: string;
77
90
  kind: string;
@@ -103,6 +116,42 @@ export interface SymbolsResult {
103
116
  files: SymbolFile[];
104
117
  }
105
118
 
119
+ export interface SignatureImpactLocation {
120
+ file: string;
121
+ symbol: string;
122
+ line: number;
123
+ kind: string;
124
+ }
125
+
126
+ export interface SignatureImpactCaller {
127
+ file: string;
128
+ symbol?: string;
129
+ depth: number;
130
+ via: string[];
131
+ }
132
+
133
+ export interface SignatureImpactTest {
134
+ file: string;
135
+ depth: number;
136
+ via: string[];
137
+ }
138
+
139
+ export interface SignatureImpactWarning {
140
+ type: string;
141
+ message: string;
142
+ }
143
+
144
+ export interface SignatureImpactResult {
145
+ roots: string[];
146
+ symbol: string;
147
+ definition: SignatureImpactLocation;
148
+ exports: SignatureImpactLocation[];
149
+ productionCallers: SignatureImpactCaller[];
150
+ testCallers: SignatureImpactCaller[];
151
+ suggestedTests: SignatureImpactTest[];
152
+ warnings: SignatureImpactWarning[];
153
+ }
154
+
106
155
  export interface ProjectOptions {
107
156
  root?: string;
108
157
  tsconfig?: string;
@@ -136,7 +185,7 @@ export type AnalyzeProjectReportRequest =
136
185
  TraverseOptions,
137
186
  "root" | "tsconfig"
138
187
  >)
139
- | ({ type: "symbols"; id?: string } & SymbolsOptions)
188
+ | ({ type: "symbols"; id?: string } & (SymbolsListOptions | SymbolsSignatureImpactOptions))
140
189
  | ({ type: "queues" | "queueEdges" | "queueCheck"; id?: string } & BatchedProjectOptions)
141
190
  | ({ type: "queueRelated"; id?: string } & BatchedQueueRelatedOptions)
142
191
  | ({