depvitals 0.2.0 → 0.4.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 +95 -30
- package/dist/cli/entry.js +8 -21
- package/dist/cli/entry.js.map +1 -1
- package/dist/cli/parseCliArgs.d.ts +5 -2
- package/dist/cli/parseCliArgs.d.ts.map +1 -1
- package/dist/cli/parseCliArgs.js +51 -36
- package/dist/cli/parseCliArgs.js.map +1 -1
- package/dist/cli/runCli.d.ts +4 -5
- package/dist/cli/runCli.d.ts.map +1 -1
- package/dist/cli/runCli.js +41 -46
- package/dist/cli/runCli.js.map +1 -1
- package/dist/config/ignoreDependencies.d.ts +9 -0
- package/dist/config/ignoreDependencies.d.ts.map +1 -0
- package/dist/config/ignoreDependencies.js +22 -0
- package/dist/config/ignoreDependencies.js.map +1 -0
- package/dist/config/ignorePaths.d.ts +13 -0
- package/dist/config/ignorePaths.d.ts.map +1 -0
- package/dist/config/ignorePaths.js +47 -0
- package/dist/config/ignorePaths.js.map +1 -0
- package/dist/config/projectConfigError.d.ts +7 -0
- package/dist/config/projectConfigError.d.ts.map +1 -0
- package/dist/config/projectConfigError.js +10 -0
- package/dist/config/projectConfigError.js.map +1 -0
- package/dist/config/readProjectConfig.d.ts +28 -0
- package/dist/config/readProjectConfig.d.ts.map +1 -0
- package/dist/config/readProjectConfig.js +120 -0
- package/dist/config/readProjectConfig.js.map +1 -0
- package/dist/core/analyzeProject.d.ts +40 -1
- package/dist/core/analyzeProject.d.ts.map +1 -1
- package/dist/core/analyzeProject.js +189 -45
- package/dist/core/analyzeProject.js.map +1 -1
- package/dist/core/evidence.d.ts +67 -0
- package/dist/core/evidence.d.ts.map +1 -0
- package/dist/core/evidence.js +115 -0
- package/dist/core/evidence.js.map +1 -0
- package/dist/core/scanContext.d.ts +20 -0
- package/dist/core/scanContext.d.ts.map +1 -0
- package/dist/core/scanContext.js +43 -0
- package/dist/core/scanContext.js.map +1 -0
- package/dist/detectors/eslintManifestConfig.d.ts +18 -0
- package/dist/detectors/eslintManifestConfig.d.ts.map +1 -1
- package/dist/detectors/eslintManifestConfig.js +62 -80
- package/dist/detectors/eslintManifestConfig.js.map +1 -1
- package/dist/detectors/eslintRcJsonConfig.d.ts +8 -2
- package/dist/detectors/eslintRcJsonConfig.d.ts.map +1 -1
- package/dist/detectors/eslintRcJsonConfig.js +27 -12
- package/dist/detectors/eslintRcJsonConfig.js.map +1 -1
- package/dist/detectors/jestManifestConfig.d.ts +15 -3
- package/dist/detectors/jestManifestConfig.d.ts.map +1 -1
- package/dist/detectors/jestManifestConfig.js +63 -83
- package/dist/detectors/jestManifestConfig.js.map +1 -1
- package/dist/reporters/jsonReporter.d.ts +39 -0
- package/dist/reporters/jsonReporter.d.ts.map +1 -0
- package/dist/reporters/jsonReporter.js +91 -0
- package/dist/reporters/jsonReporter.js.map +1 -0
- package/dist/reporters/terminalReporter.d.ts +15 -4
- package/dist/reporters/terminalReporter.d.ts.map +1 -1
- package/dist/reporters/terminalReporter.js +64 -4
- package/dist/reporters/terminalReporter.js.map +1 -1
- package/dist/scanner/moduleSpecifiers.d.ts +12 -2
- package/dist/scanner/moduleSpecifiers.d.ts.map +1 -1
- package/dist/scanner/moduleSpecifiers.js +1154 -183
- package/dist/scanner/moduleSpecifiers.js.map +1 -1
- package/dist/scanner/packageSpecifier.d.ts +26 -2
- package/dist/scanner/packageSpecifier.d.ts.map +1 -1
- package/dist/scanner/packageSpecifier.js +70 -2
- package/dist/scanner/packageSpecifier.js.map +1 -1
- package/dist/scanner/projectManifest.d.ts +28 -3
- package/dist/scanner/projectManifest.d.ts.map +1 -1
- package/dist/scanner/projectManifest.js +58 -13
- package/dist/scanner/projectManifest.js.map +1 -1
- package/dist/scanner/scriptUsage.d.ts +15 -1
- package/dist/scanner/scriptUsage.d.ts.map +1 -1
- package/dist/scanner/scriptUsage.js +284 -69
- package/dist/scanner/scriptUsage.js.map +1 -1
- package/dist/scanner/sourceFiles.d.ts +21 -2
- package/dist/scanner/sourceFiles.d.ts.map +1 -1
- package/dist/scanner/sourceFiles.js +19 -6
- package/dist/scanner/sourceFiles.js.map +1 -1
- package/package.json +4 -2
- package/schemas/README.md +47 -0
- package/schemas/examples/README.md +27 -0
- package/schemas/examples/explain-excluded.json +53 -0
- package/schemas/examples/explain-missing.json +65 -0
- package/schemas/examples/explain-node-preload.json +70 -0
- package/schemas/examples/explain-unknown.json +53 -0
- package/schemas/examples/scan-clean.json +40 -0
- package/schemas/examples/scan-findings.json +80 -0
- package/schemas/report-v1.schema.json +376 -0
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
* interpreted or executed. The precedence is computed once by {@link readLegacyEslintPrecedence},
|
|
32
32
|
* shared by both legacy readers, so the two sources obey exactly one set of rules.
|
|
33
33
|
*/
|
|
34
|
+
import { type ConfigEvidence } from '../core/evidence.js';
|
|
34
35
|
/**
|
|
35
36
|
* The legacy ESLint precedence state for one project root, computed once by both readers so the two
|
|
36
37
|
* legacy sources obey exactly one set of rules.
|
|
@@ -62,6 +63,8 @@ export type LegacyEslintPrecedence = {
|
|
|
62
63
|
* @param projectRoot - Project directory to inspect; resolved to an absolute path.
|
|
63
64
|
*/
|
|
64
65
|
export declare function readLegacyEslintPrecedence(projectRoot: string): Promise<LegacyEslintPrecedence>;
|
|
66
|
+
/** Pure precedence over validated root entry names, shared by one CLI scan. */
|
|
67
|
+
export declare function legacyEslintPrecedenceFromEntries(entries: readonly string[]): LegacyEslintPrecedence;
|
|
65
68
|
/**
|
|
66
69
|
* Match the allowlisted subset of one legacy `eslintConfig` value against the declared packages.
|
|
67
70
|
*
|
|
@@ -75,6 +78,19 @@ export declare function readLegacyEslintPrecedence(projectRoot: string): Promise
|
|
|
75
78
|
* @param declaredPackageNames - Declared dependency names, the only names this may return.
|
|
76
79
|
*/
|
|
77
80
|
export declare function findEslintConfigUsage(eslintConfig: unknown, declaredPackageNames: ReadonlySet<string>): ReadonlySet<string>;
|
|
81
|
+
/** Internal package owner and the exact recognized configuration occurrence. */
|
|
82
|
+
export type EslintConfigOccurrence = {
|
|
83
|
+
readonly packageName: string;
|
|
84
|
+
readonly evidence: ConfigEvidence;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Pure collector shared by the manifest/rc readers and the later validated-context handoff.
|
|
88
|
+
* Location comes from the reader, not a string search. Array indices are retained before filtering.
|
|
89
|
+
*/
|
|
90
|
+
export declare function collectEslintConfigUsage(eslintConfig: unknown, declaredPackageNames: ReadonlySet<string>, location?: {
|
|
91
|
+
readonly file: string;
|
|
92
|
+
readonly pointerTokens: readonly string[];
|
|
93
|
+
}): readonly EslintConfigOccurrence[];
|
|
78
94
|
/**
|
|
79
95
|
* Collect the legacy `package.json#eslintConfig` hints for the project rooted at `projectRoot`.
|
|
80
96
|
*
|
|
@@ -95,6 +111,8 @@ export declare function findEslintConfigUsage(eslintConfig: unknown, declaredPac
|
|
|
95
111
|
* @param projectRoot - Project directory to inspect; resolved to an absolute path.
|
|
96
112
|
*/
|
|
97
113
|
export declare function findEslintManifestUsage(projectRoot: string): Promise<ReadonlySet<string>>;
|
|
114
|
+
/** Collect active manifest facts using the same mandatory gates and reads as the legacy wrapper. */
|
|
115
|
+
export declare function collectEslintManifestUsage(projectRoot: string): Promise<readonly EslintConfigOccurrence[]>;
|
|
98
116
|
/**
|
|
99
117
|
* Whether the project rooted at `projectRoot` contains a modern flat-config entrypoint (see
|
|
100
118
|
* {@link FLAT_CONFIG_ENTRY_NAMES}).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslintManifestConfig.d.ts","sourceRoot":"","sources":["../../src/detectors/eslintManifestConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;
|
|
1
|
+
{"version":3,"file":"eslintManifestConfig.d.ts","sourceRoot":"","sources":["../../src/detectors/eslintManifestConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAg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AE,MAAM,GAClB,OAAO,CAAC,SAAS,sBAAsB,EAAE,CAAC,CA2B5C;AAaD;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAU9E"}
|
|
@@ -31,9 +31,11 @@
|
|
|
31
31
|
* interpreted or executed. The precedence is computed once by {@link readLegacyEslintPrecedence},
|
|
32
32
|
* shared by both legacy readers, so the two sources obey exactly one set of rules.
|
|
33
33
|
*/
|
|
34
|
-
import {
|
|
34
|
+
import { readdir } from 'node:fs/promises';
|
|
35
35
|
import { resolve } from 'node:path';
|
|
36
|
-
import {
|
|
36
|
+
import { compareEvidence, compareStrings, jsonPointer, } from '../core/evidence.js';
|
|
37
|
+
import { loadProjectManifest, ProjectManifestError, readManifestText, } from '../scanner/projectManifest.js';
|
|
38
|
+
import { assertReadableRoot, SourceFilesError } from '../scanner/sourceFiles.js';
|
|
37
39
|
/**
|
|
38
40
|
* The legacy `extends` values recognized by this release and the package each one refers to.
|
|
39
41
|
*
|
|
@@ -131,6 +133,7 @@ export async function readLegacyEslintPrecedence(projectRoot) {
|
|
|
131
133
|
const root = resolve(projectRoot);
|
|
132
134
|
let entries;
|
|
133
135
|
try {
|
|
136
|
+
await assertReadableRoot(root);
|
|
134
137
|
entries = await readdir(root);
|
|
135
138
|
}
|
|
136
139
|
catch {
|
|
@@ -140,6 +143,10 @@ export async function readLegacyEslintPrecedence(projectRoot) {
|
|
|
140
143
|
legacyRcJsonEntryName: undefined,
|
|
141
144
|
};
|
|
142
145
|
}
|
|
146
|
+
return legacyEslintPrecedenceFromEntries(entries);
|
|
147
|
+
}
|
|
148
|
+
/** Pure precedence over validated root entry names, shared by one CLI scan. */
|
|
149
|
+
export function legacyEslintPrecedenceFromEntries(entries) {
|
|
143
150
|
const has = (names) => entries.some((entry) => names.has(entry.toLowerCase()));
|
|
144
151
|
// The legacy `.eslintrc.json` name is matched case-insensitively (Windows/macOS resolve the
|
|
145
152
|
// same file under a different casing), so remember the actual entry that was found. The JSON
|
|
@@ -168,21 +175,50 @@ export async function readLegacyEslintPrecedence(projectRoot) {
|
|
|
168
175
|
* @param declaredPackageNames - Declared dependency names, the only names this may return.
|
|
169
176
|
*/
|
|
170
177
|
export function findEslintConfigUsage(eslintConfig, declaredPackageNames) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
return new Set(collectEslintConfigUsage(eslintConfig, declaredPackageNames).map(({ packageName }) => packageName));
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Pure collector shared by the manifest/rc readers and the later validated-context handoff.
|
|
182
|
+
* Location comes from the reader, not a string search. Array indices are retained before filtering.
|
|
183
|
+
*/
|
|
184
|
+
export function collectEslintConfigUsage(eslintConfig, declaredPackageNames, location = {
|
|
185
|
+
file: 'package.json',
|
|
186
|
+
pointerTokens: ['eslintConfig'],
|
|
187
|
+
}) {
|
|
188
|
+
if (!isPlainRecord(eslintConfig))
|
|
189
|
+
return [];
|
|
190
|
+
const occurrences = [];
|
|
191
|
+
const collectField = (field, table) => {
|
|
192
|
+
const add = (value, index) => {
|
|
193
|
+
if (typeof value !== 'string')
|
|
194
|
+
return;
|
|
195
|
+
const packageName = table.get(value);
|
|
196
|
+
if (packageName !== undefined && declaredPackageNames.has(packageName)) {
|
|
197
|
+
occurrences.push({
|
|
198
|
+
packageName,
|
|
199
|
+
evidence: {
|
|
200
|
+
kind: 'config',
|
|
201
|
+
file: location.file,
|
|
202
|
+
pointer: jsonPointer(...location.pointerTokens, field, ...(index === undefined ? [] : [String(index)])),
|
|
203
|
+
value,
|
|
204
|
+
detector: 'eslint',
|
|
205
|
+
},
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
const value = eslintConfig[field];
|
|
210
|
+
if (field === 'extends' && typeof value === 'string') {
|
|
211
|
+
add(value);
|
|
182
212
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
213
|
+
else if (Array.isArray(value)) {
|
|
214
|
+
for (const [index, item] of value.entries())
|
|
215
|
+
add(item, index);
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
collectField('extends', EXTENDS_PACKAGE_NAMES);
|
|
219
|
+
collectField('plugins', PLUGIN_PACKAGE_NAMES);
|
|
220
|
+
// A field/index identifies exactly one item; repeated values at other indices stay distinct.
|
|
221
|
+
return occurrences.sort((a, b) => compareStrings(a.packageName, b.packageName) || compareEvidence(a.evidence, b.evidence));
|
|
186
222
|
}
|
|
187
223
|
/**
|
|
188
224
|
* Collect the legacy `package.json#eslintConfig` hints for the project rooted at `projectRoot`.
|
|
@@ -204,10 +240,14 @@ export function findEslintConfigUsage(eslintConfig, declaredPackageNames) {
|
|
|
204
240
|
* @param projectRoot - Project directory to inspect; resolved to an absolute path.
|
|
205
241
|
*/
|
|
206
242
|
export async function findEslintManifestUsage(projectRoot) {
|
|
243
|
+
return new Set((await collectEslintManifestUsage(projectRoot)).map(({ packageName }) => packageName));
|
|
244
|
+
}
|
|
245
|
+
/** Collect active manifest facts using the same mandatory gates and reads as the legacy wrapper. */
|
|
246
|
+
export async function collectEslintManifestUsage(projectRoot) {
|
|
207
247
|
const root = resolve(projectRoot);
|
|
208
248
|
const precedence = await readLegacyEslintPrecedence(root);
|
|
209
249
|
if (precedence.hardBarrier || precedence.legacyRcByName) {
|
|
210
|
-
return
|
|
250
|
+
return [];
|
|
211
251
|
}
|
|
212
252
|
let packageJsonPath;
|
|
213
253
|
let declaredPackageNames;
|
|
@@ -217,12 +257,12 @@ export async function findEslintManifestUsage(projectRoot) {
|
|
|
217
257
|
declaredPackageNames = manifest.declaredDependencyNames;
|
|
218
258
|
}
|
|
219
259
|
catch (error) {
|
|
220
|
-
if (error instanceof ProjectManifestError) {
|
|
221
|
-
return
|
|
260
|
+
if (error instanceof ProjectManifestError || error instanceof SourceFilesError) {
|
|
261
|
+
return [];
|
|
222
262
|
}
|
|
223
263
|
throw error;
|
|
224
264
|
}
|
|
225
|
-
return
|
|
265
|
+
return collectEslintConfigUsage(await readEslintConfigValue(packageJsonPath), declaredPackageNames);
|
|
226
266
|
}
|
|
227
267
|
/**
|
|
228
268
|
* Whether the on-disk directory entries contain a modern flat-config entrypoint (see
|
|
@@ -249,6 +289,7 @@ function hasFlatConfigEntryEntries(entries) {
|
|
|
249
289
|
export async function hasFlatConfigEntry(projectRoot) {
|
|
250
290
|
let entries;
|
|
251
291
|
try {
|
|
292
|
+
await assertReadableRoot(resolve(projectRoot));
|
|
252
293
|
entries = await readdir(resolve(projectRoot));
|
|
253
294
|
}
|
|
254
295
|
catch {
|
|
@@ -266,7 +307,7 @@ export async function hasFlatConfigEntry(projectRoot) {
|
|
|
266
307
|
async function readEslintConfigValue(packageJsonPath) {
|
|
267
308
|
let text;
|
|
268
309
|
try {
|
|
269
|
-
text = await
|
|
310
|
+
text = await readManifestText(packageJsonPath);
|
|
270
311
|
}
|
|
271
312
|
catch {
|
|
272
313
|
return undefined;
|
|
@@ -280,69 +321,10 @@ async function readEslintConfigValue(packageJsonPath) {
|
|
|
280
321
|
}
|
|
281
322
|
return isPlainRecord(parsed) ? parsed['eslintConfig'] : undefined;
|
|
282
323
|
}
|
|
283
|
-
/**
|
|
284
|
-
* The string values of `extends`, which ESLint accepts as one string or as an array.
|
|
285
|
-
*
|
|
286
|
-
* Non-string array entries contribute nothing on their own, so a malformed array still yields no
|
|
287
|
-
* evidence for the malformed entries. Any other shape (number, object, `null`, ...) contributes
|
|
288
|
-
* nothing at all.
|
|
289
|
-
*/
|
|
290
|
-
function extendsValues(value) {
|
|
291
|
-
if (typeof value === 'string') {
|
|
292
|
-
return [value];
|
|
293
|
-
}
|
|
294
|
-
return stringItems(value);
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* The string values of `plugins`, which ESLint accepts only as an array.
|
|
298
|
-
*
|
|
299
|
-
* A bare string such as `"react"` is not a valid `plugins` value and is deliberately not accepted,
|
|
300
|
-
* so a typo-shaped value never becomes evidence.
|
|
301
|
-
*/
|
|
302
|
-
function pluginsValues(value) {
|
|
303
|
-
return stringItems(value);
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* The string entries of an array value; a non-array value contributes nothing.
|
|
307
|
-
*/
|
|
308
|
-
function stringItems(value) {
|
|
309
|
-
if (!Array.isArray(value)) {
|
|
310
|
-
return [];
|
|
311
|
-
}
|
|
312
|
-
return value.filter((entry) => typeof entry === 'string');
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* Look every value up in one fixed allowlist table.
|
|
316
|
-
*
|
|
317
|
-
* Lookup is exact-string only: no prefix, suffix, substring or case-insensitive matching, so
|
|
318
|
-
* `prettier/react`, `eslint-config-unknown` and `React` never match an entry.
|
|
319
|
-
*/
|
|
320
|
-
function matchTable(values, table) {
|
|
321
|
-
const matched = [];
|
|
322
|
-
for (const value of values) {
|
|
323
|
-
const mapped = table.get(value);
|
|
324
|
-
if (mapped !== undefined) {
|
|
325
|
-
matched.push(mapped);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
return matched;
|
|
329
|
-
}
|
|
330
324
|
/**
|
|
331
325
|
* A JSON object (not an array, not `null`) whose keys are strings.
|
|
332
326
|
*/
|
|
333
327
|
function isPlainRecord(value) {
|
|
334
328
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
335
329
|
}
|
|
336
|
-
/**
|
|
337
|
-
* Locale-independent lexicographic ordering, so the same configuration always yields the same order.
|
|
338
|
-
*/
|
|
339
|
-
function compareNames(a, b) {
|
|
340
|
-
if (a < b) {
|
|
341
|
-
return -1;
|
|
342
|
-
}
|
|
343
|
-
if (a > b) {
|
|
344
|
-
return 1;
|
|
345
|
-
}
|
|
346
|
-
return 0;
|
|
347
|
-
}
|
|
348
330
|
//# sourceMappingURL=eslintManifestConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslintManifestConfig.js","sourceRoot":"","sources":["../../src/detectors/eslintManifestConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"eslintManifestConfig.js","sourceRoot":"","sources":["../../src/detectors/eslintManifestConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EACL,eAAe,EACf,cAAc,EACd,WAAW,GAEZ,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAEjF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,qBAAqB,GAAgC,IAAI,GAAG,CAAC;IACjE,CAAC,UAAU,EAAE,wBAAwB,CAAC;IACtC,CAAC,QAAQ,EAAE,sBAAsB,CAAC;IAClC,CAAC,0BAA0B,EAAE,qBAAqB,CAAC;IACnD,CAAC,wBAAwB,EAAE,wBAAwB,CAAC;IACpD,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;CACjD,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,MAAM,oBAAoB,GAAgC,IAAI,GAAG,CAAC;IAChE,CAAC,OAAO,EAAE,qBAAqB,CAAC;IAChC,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;CAC/C,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAAC;IAC3D,kBAAkB;IAClB,mBAAmB;IACnB,mBAAmB;IACnB,kBAAk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CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,yBAAyB,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,qBAAqB,CAAC,eAAuB;IAC1D,IAAI,IAAY,CAAC;IAEjB,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,gBAAgB,CAAC,eAAe,CAAC,CAAC;IACjD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,MAAe,CAAC;IAEpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACpE,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This module adds exactly one static data source to the ESLint rules proven in Step 57: the single
|
|
5
5
|
* file `<projectRoot>/.eslintrc.json`. Its parsed JSON document is handed to the same pure matcher
|
|
6
|
-
* ({@link
|
|
6
|
+
* ({@link collectEslintConfigUsage}) that reads `package.json#eslintConfig`, so the fixed allowlists,
|
|
7
7
|
* the exact-string lookup and the "declared packages only" rule are reused instead of duplicated.
|
|
8
8
|
* The result is a set of configuration-only package names for the Step 56 analyzer seam, so a
|
|
9
9
|
* recognized name can only suppress an `unused` finding and can never create a `missing` one.
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* document, so it is removed before parsing;
|
|
22
22
|
* - traverse parent directories, nested packages or workspaces looking for further config files, or
|
|
23
23
|
* resolve `extends` references to other configuration files;
|
|
24
|
-
* - read anything besides the `extends`/`plugins` subset that {@link
|
|
24
|
+
* - read anything besides the `extends`/`plugins` subset that {@link collectEslintConfigUsage} accepts;
|
|
25
25
|
* every other ESLint field (`env`, `globals`, `rules`, `parserOptions`, `overrides`, ...) is
|
|
26
26
|
* ignored, and no unknown value produces evidence;
|
|
27
27
|
* - report anything about a package the manifest does not declare, or mutate the analyzed project.
|
|
@@ -46,6 +46,8 @@
|
|
|
46
46
|
* helper both legacy readers share; the barrier is presence-based and never reads the displaced
|
|
47
47
|
* source for evidence, so two contradictory legacy sources are never unioned.
|
|
48
48
|
*/
|
|
49
|
+
import { type ProjectManifest } from '../scanner/projectManifest.js';
|
|
50
|
+
import { type EslintConfigOccurrence, type LegacyEslintPrecedence } from './eslintManifestConfig.js';
|
|
49
51
|
/**
|
|
50
52
|
* Why a present `.eslintrc.json` could not be used as a configuration data source.
|
|
51
53
|
*
|
|
@@ -82,4 +84,8 @@ export declare class EslintRcJsonError extends Error {
|
|
|
82
84
|
* parsed as JSON. Absent, skipped and unusable-but-parsable files return the empty set.
|
|
83
85
|
*/
|
|
84
86
|
export declare function findEslintRcJsonUsage(projectRoot: string): Promise<ReadonlySet<string>>;
|
|
87
|
+
/** Retain the active rc entry's actual casing and pointers without additional filesystem reads. */
|
|
88
|
+
export declare function collectEslintRcJsonUsage(projectRoot: string): Promise<readonly EslintConfigOccurrence[]>;
|
|
89
|
+
/** Read the active rc using the same validated inventory and precedence as the other channels. */
|
|
90
|
+
export declare function collectEslintRcJsonUsageForManifest(manifest: ProjectManifest, precedence: LegacyEslintPrecedence): Promise<readonly EslintConfigOccurrence[]>;
|
|
85
91
|
//# sourceMappingURL=eslintRcJsonConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslintRcJsonConfig.d.ts","sourceRoot":"","sources":["../../src/detectors/eslintRcJsonConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;
|
|
1
|
+
{"version":3,"file":"eslintRcJsonConfig.d.ts","sourceRoot":"","sources":["../../src/detectors/eslintRcJsonConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAKH,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC5B,MAAM,2BAA2B,CAAC;AAUnC;;;;;;;;;GASG;AACH,MAAM,MAAM,qBAAqB,GAAG,YAAY,GAAG,cAAc,CAAC;AAElE;;;;;;;GAOG;AACH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;gBAEzB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,EAAE,KAAK,CAAC,EAAE,OAAO;CAK1E;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAI7F;AAED,mGAAmG;AACnG,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,SAAS,sBAAsB,EAAE,CAAC,CA0B5C;AAED,kGAAkG;AAClG,wBAAsB,mCAAmC,CACvD,QAAQ,EAAE,eAAe,EACzB,UAAU,EAAE,sBAAsB,GACjC,OAAO,CAAC,SAAS,sBAAsB,EAAE,CAAC,CAmC5C"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* This module adds exactly one static data source to the ESLint rules proven in Step 57: the single
|
|
5
5
|
* file `<projectRoot>/.eslintrc.json`. Its parsed JSON document is handed to the same pure matcher
|
|
6
|
-
* ({@link
|
|
6
|
+
* ({@link collectEslintConfigUsage}) that reads `package.json#eslintConfig`, so the fixed allowlists,
|
|
7
7
|
* the exact-string lookup and the "declared packages only" rule are reused instead of duplicated.
|
|
8
8
|
* The result is a set of configuration-only package names for the Step 56 analyzer seam, so a
|
|
9
9
|
* recognized name can only suppress an `unused` finding and can never create a `missing` one.
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* document, so it is removed before parsing;
|
|
22
22
|
* - traverse parent directories, nested packages or workspaces looking for further config files, or
|
|
23
23
|
* resolve `extends` references to other configuration files;
|
|
24
|
-
* - read anything besides the `extends`/`plugins` subset that {@link
|
|
24
|
+
* - read anything besides the `extends`/`plugins` subset that {@link collectEslintConfigUsage} accepts;
|
|
25
25
|
* every other ESLint field (`env`, `globals`, `rules`, `parserOptions`, `overrides`, ...) is
|
|
26
26
|
* ignored, and no unknown value produces evidence;
|
|
27
27
|
* - report anything about a package the manifest does not declare, or mutate the analyzed project.
|
|
@@ -48,8 +48,9 @@
|
|
|
48
48
|
*/
|
|
49
49
|
import { lstat, readFile } from 'node:fs/promises';
|
|
50
50
|
import { join, resolve } from 'node:path';
|
|
51
|
-
import { loadProjectManifest, ProjectManifestError } from '../scanner/projectManifest.js';
|
|
52
|
-
import {
|
|
51
|
+
import { loadProjectManifest, ProjectManifestError, } from '../scanner/projectManifest.js';
|
|
52
|
+
import { SourceFilesError } from '../scanner/sourceFiles.js';
|
|
53
|
+
import { collectEslintConfigUsage, readLegacyEslintPrecedence, } from './eslintManifestConfig.js';
|
|
53
54
|
/**
|
|
54
55
|
* The one file name this reader looks for, relative to the resolved project root.
|
|
55
56
|
*
|
|
@@ -86,27 +87,38 @@ export class EslintRcJsonError extends Error {
|
|
|
86
87
|
* parsed as JSON. Absent, skipped and unusable-but-parsable files return the empty set.
|
|
87
88
|
*/
|
|
88
89
|
export async function findEslintRcJsonUsage(projectRoot) {
|
|
90
|
+
return new Set((await collectEslintRcJsonUsage(projectRoot)).map(({ packageName }) => packageName));
|
|
91
|
+
}
|
|
92
|
+
/** Retain the active rc entry's actual casing and pointers without additional filesystem reads. */
|
|
93
|
+
export async function collectEslintRcJsonUsage(projectRoot) {
|
|
89
94
|
const root = resolve(projectRoot);
|
|
90
95
|
// A hard barrier disables every legacy hint, external file included. Precedence is computed once
|
|
91
96
|
// by a helper both legacy readers share, so this file always wins over `package.json#eslintConfig`
|
|
92
97
|
// and the two legacy sources are never combined into one hint set.
|
|
93
98
|
const precedence = await readLegacyEslintPrecedence(root);
|
|
94
99
|
if (precedence.hardBarrier) {
|
|
95
|
-
return
|
|
100
|
+
return [];
|
|
96
101
|
}
|
|
97
|
-
let
|
|
102
|
+
let manifest;
|
|
98
103
|
try {
|
|
99
|
-
|
|
100
|
-
declaredPackageNames = manifest.declaredDependencyNames;
|
|
104
|
+
manifest = await loadProjectManifest(root);
|
|
101
105
|
}
|
|
102
106
|
catch (error) {
|
|
103
|
-
if (error instanceof ProjectManifestError) {
|
|
107
|
+
if (error instanceof ProjectManifestError || error instanceof SourceFilesError) {
|
|
104
108
|
// Manifest failures stay with the manifest loader and the analyzer, which report them as they
|
|
105
109
|
// always have; this detector never duplicates that diagnosis.
|
|
106
|
-
return
|
|
110
|
+
return [];
|
|
107
111
|
}
|
|
108
112
|
throw error;
|
|
109
113
|
}
|
|
114
|
+
return collectEslintRcJsonUsageForManifest(manifest, precedence);
|
|
115
|
+
}
|
|
116
|
+
/** Read the active rc using the same validated inventory and precedence as the other channels. */
|
|
117
|
+
export async function collectEslintRcJsonUsageForManifest(manifest, precedence) {
|
|
118
|
+
if (precedence.hardBarrier)
|
|
119
|
+
return [];
|
|
120
|
+
const root = manifest.root;
|
|
121
|
+
const declaredPackageNames = manifest.declaredDependencyNames;
|
|
110
122
|
// Reuse the on-disk entry name when the legacy `.eslintrc.json` was found under a different
|
|
111
123
|
// casing, so the reader opens the file that actually exists instead of assuming the canonical
|
|
112
124
|
// lowercase spelling.
|
|
@@ -114,7 +126,7 @@ export async function findEslintRcJsonUsage(projectRoot) {
|
|
|
114
126
|
const eslintRcPath = join(root, eslintRcFilename);
|
|
115
127
|
const text = await readEslintRcText(eslintRcPath);
|
|
116
128
|
if (text === undefined) {
|
|
117
|
-
return
|
|
129
|
+
return [];
|
|
118
130
|
}
|
|
119
131
|
let parsed;
|
|
120
132
|
try {
|
|
@@ -126,7 +138,10 @@ export async function findEslintRcJsonUsage(projectRoot) {
|
|
|
126
138
|
}
|
|
127
139
|
// The whole document is the legacy config object, so the proven matcher is reused verbatim. A
|
|
128
140
|
// top-level value that is not an object simply matches nothing, and nothing undeclared is added.
|
|
129
|
-
return
|
|
141
|
+
return collectEslintConfigUsage(parsed, declaredPackageNames, {
|
|
142
|
+
file: eslintRcFilename,
|
|
143
|
+
pointerTokens: [],
|
|
144
|
+
});
|
|
130
145
|
}
|
|
131
146
|
/**
|
|
132
147
|
* Read `.eslintrc.json` as text, returning `undefined` when there is no usable file.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslintRcJsonConfig.js","sourceRoot":"","sources":["../../src/detectors/eslintRcJsonConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,
|
|
1
|
+
{"version":3,"file":"eslintRcJsonConfig.js","sourceRoot":"","sources":["../../src/detectors/eslintRcJsonConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EACL,mBAAmB,EACnB,oBA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;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC;AAC9E,CAAC"}
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
* - execute Jest, `import()`/`require()` its configuration loader, or evaluate any target code;
|
|
12
12
|
* - implement the Jest configuration schema. Only `preset`, `testEnvironment` and `transform` are
|
|
13
13
|
* read, and only through the fixed allowlists below;
|
|
14
|
-
* -
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* - use `transform` map keys as package evidence. Keys are retained only in JSON pointers; they
|
|
15
|
+
* select the transformer field and never name a package, even when a key literally reads
|
|
16
|
+
* `"ts-jest"`. No regular expression is evaluated here;
|
|
17
17
|
* - expand Jest shorthands. In particular `testEnvironment: "jsdom"` is *not* credited to
|
|
18
18
|
* `jest-environment-jsdom`: whether that shorthand is a package reference at all depends on the
|
|
19
19
|
* Jest major version in use, which DepVitals does not read, so it stays outside the supported
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
* use. Ignoring is deliberate — an unusable `jest` block is not an error, and diagnosing one here would
|
|
37
37
|
* duplicate the manifest loader.
|
|
38
38
|
*/
|
|
39
|
+
import { type ConfigEvidence } from '../core/evidence.js';
|
|
39
40
|
/**
|
|
40
41
|
* Match the allowlisted subset of one `jest` configuration against the declared packages.
|
|
41
42
|
*
|
|
@@ -49,6 +50,13 @@
|
|
|
49
50
|
* @param declaredPackageNames - Declared dependency names, the only names this may return.
|
|
50
51
|
*/
|
|
51
52
|
export declare function findJestConfigUsage(jestConfig: unknown, declaredPackageNames: ReadonlySet<string>): ReadonlySet<string>;
|
|
53
|
+
/** Internal package owner plus one exact recognized Jest configuration value. */
|
|
54
|
+
export type JestConfigOccurrence = {
|
|
55
|
+
readonly packageName: string;
|
|
56
|
+
readonly evidence: ConfigEvidence;
|
|
57
|
+
};
|
|
58
|
+
/** Pure collector for standalone readers and the later shared validated-context handoff. */
|
|
59
|
+
export declare function collectJestConfigUsage(jestConfig: unknown, declaredPackageNames: ReadonlySet<string>): readonly JestConfigOccurrence[];
|
|
52
60
|
/**
|
|
53
61
|
* Collect the `package.json#jest` hints for the project rooted at `projectRoot`.
|
|
54
62
|
*
|
|
@@ -64,6 +72,8 @@ export declare function findJestConfigUsage(jestConfig: unknown, declaredPackage
|
|
|
64
72
|
* @param projectRoot - Project directory to inspect; resolved to an absolute path.
|
|
65
73
|
*/
|
|
66
74
|
export declare function findJestManifestUsage(projectRoot: string): Promise<ReadonlySet<string>>;
|
|
75
|
+
/** Retain manifest facts through the existing barrier, validation and text-read path. */
|
|
76
|
+
export declare function collectJestManifestUsage(projectRoot: string): Promise<readonly JestConfigOccurrence[]>;
|
|
67
77
|
/**
|
|
68
78
|
* Whether a root Jest configuration file name exists in the project root.
|
|
69
79
|
*
|
|
@@ -73,4 +83,6 @@ export declare function findJestManifestUsage(projectRoot: string): Promise<Read
|
|
|
73
83
|
* macOS) cannot hide a root Jest config from this guard.
|
|
74
84
|
*/
|
|
75
85
|
export declare function hasRootJestConfigEntry(root: string): Promise<boolean>;
|
|
86
|
+
/** Pure barrier decision for a shared per-scan root listing. */
|
|
87
|
+
export declare function hasRootJestConfigEntries(entries: readonly string[]): boolean;
|
|
76
88
|
//# sourceMappingURL=jestManifestConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jestManifestConfig.d.ts","sourceRoot":"","sources":["../../src/detectors/jestManifestConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;
|
|
1
|
+
{"version":3,"file":"jestManifestConfig.d.ts","sourceRoot":"","sources":["../../src/detectors/jestManifestConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAKH,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,qBAAqB,CAAC;AAqE7B;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,OAAO,EACnB,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAAC,GACxC,WAAW,CAAC,MAAM,CAAC,CAIrB;AAED,iFAAiF;AACjF,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;CACnC,CAAC;AAEF,4FAA4F;AAC5F,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,OAAO,EACnB,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAAC,GACxC,SAAS,oBAAoB,EAAE,CA6CjC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAI7F;AAED,yFAAyF;AACzF,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC,CAuB1C;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAW3E;AAED,gEAAgE;AAChE,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAE5E"}
|