rev-dep 2.9.1 → 2.11.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 (2) hide show
  1. package/Readme.md +77 -31
  2. package/package.json +4 -4
package/Readme.md CHANGED
@@ -215,20 +215,20 @@ The configuration file (`rev-dep.config.json(c)` or `.rev-dep.config.json(c)`) a
215
215
 
216
216
  ```jsonc
217
217
  {
218
- "configVersion": "1.5",
219
- "$schema": "https://github.com/jayu/rev-dep/blob/master/config-schema/1.5.schema.json?raw=true",
218
+ "configVersion": "1.6",
219
+ "$schema": "https://github.com/jayu/rev-dep/blob/master/config-schema/1.6.schema.json?raw=true",
220
220
  "rules": [
221
221
  {
222
222
  "path": ".",
223
+ "prodEntryPoints": ["src/main.tsx", "src/pages/**/*.tsx"],
224
+ "devEntryPoints": ["scripts/**", "**/*.test.*"],
223
225
  "unusedExportsDetection": {
224
226
  "enabled": true,
225
- "autofix": true,
226
- "validEntryPoints": ["src/index.ts" ]
227
+ "autofix": true
227
228
  },
228
229
  "orphanFilesDetection": {
229
230
  "enabled": true,
230
- "autofix": true,
231
- "validEntryPoints": ["src/index.ts"]
231
+ "autofix": true
232
232
  },
233
233
  "unusedNodeModulesDetection": {
234
234
  "enabled": true
@@ -238,7 +238,6 @@ The configuration file (`rev-dep.config.json(c)` or `.rev-dep.config.json(c)`) a
238
238
  },
239
239
  "devDepsUsageOnProdDetection": {
240
240
  "enabled": true,
241
- "prodEntryPoints": ["src/main.tsx", "src/pages/**/*.tsx"],
242
241
  "ignoreTypeImports": true
243
242
  }
244
243
  }
@@ -252,14 +251,16 @@ Here's a comprehensive example showing all available properties:
252
251
 
253
252
  ```jsonc
254
253
  {
255
- "configVersion": "1.5",
256
- "$schema": "https://github.com/jayu/rev-dep/blob/master/config-schema/1.5.schema.json?raw=true", // enables json autocompletion
254
+ "configVersion": "1.6",
255
+ "$schema": "https://github.com/jayu/rev-dep/blob/master/config-schema/1.6.schema.json?raw=true", // enables json autocompletion
257
256
  "conditionNames": ["import", "default"],
258
257
  "ignoreFiles": ["**/*.test.*"],
259
258
  "rules": [
260
259
  {
261
260
  "path": ".",
262
261
  "followMonorepoPackages": true,
262
+ "prodEntryPoints": ["src/main.tsx", "src/pages/**/*.tsx", "src/server.ts"],
263
+ "devEntryPoints": ["scripts/**", "**/*.test.*"],
263
264
  "moduleBoundaries": [
264
265
  {
265
266
  "name": "ui-components",
@@ -298,7 +299,6 @@ Here's a comprehensive example showing all available properties:
298
299
  },
299
300
  "orphanFilesDetection": {
300
301
  "enabled": true,
301
- "validEntryPoints": ["src/index.ts", "src/app.ts"],
302
302
  "ignoreTypeImports": true,
303
303
  "graphExclude": ["**/*.test.*", "**/stories/**/*"],
304
304
  "autofix": true
@@ -320,27 +320,32 @@ Here's a comprehensive example showing all available properties:
320
320
  },
321
321
  "unusedExportsDetection": {
322
322
  "enabled": true,
323
- "validEntryPoints": ["src/index.ts"],
323
+ "autofix": true,
324
324
  "ignoreTypeExports": true,
325
325
  "graphExclude": ["**/*.stories.tsx"],
326
- "autofix": true
326
+ "ignore": {
327
+ "src/types.ts": "B*",
328
+ "**/generated/**/*.ts": "*"
329
+ },
330
+ "ignoreFiles": ["**/*.generated.ts"],
331
+ "ignoreExports": ["default", "unused*"],
327
332
  },
328
333
  "unresolvedImportsDetection": {
329
334
  "enabled": true,
330
335
  "ignore": {
331
- "src/index.ts": "legacy-unresolved-module"
336
+ "src/index.ts": "legacy-*"
332
337
  },
333
338
  "ignoreFiles": ["**/*.generated.ts"],
334
- "ignoreImports": ["@internal/dev-only"]
339
+ "ignoreImports": ["@internal/*"]
335
340
  },
336
341
  "devDepsUsageOnProdDetection": {
337
342
  "enabled": true,
338
- "prodEntryPoints": ["src/main.tsx", "src/pages/**/*.tsx", "src/server.ts"],
339
343
  "ignoreTypeImports": true
340
344
  },
341
345
  "restrictedImportsDetection": {
342
346
  "enabled": true,
343
347
  "entryPoints": ["src/server.ts", "src/server/**/*.ts"],
348
+ "graphExclude": ["some-file-coupling-other-files.ts"],
344
349
  "denyFiles": ["**/*.tsx"],
345
350
  "denyModules": ["react", "react-*"],
346
351
  "ignoreMatches": ["src/server/allowed-view.tsx", "react-awsome-lib"],
@@ -357,6 +362,7 @@ Here's a comprehensive example showing all available properties:
357
362
  - **`configVersion`** (required): Configuration version string
358
363
  - **`$schema`** (optional): JSON schema reference for validation
359
364
  - **`conditionNames`** (optional): Array of condition names for exports resolution
365
+ - **`customAssetExtensions`** (optional): Additional asset extensions treated as resolvable imports (e.g. `["glb", "mp3"]`). Default list covers common extensions for fonts, images, config files.
360
366
  - **`ignoreFiles`** (optional): Global file patterns to ignore across all rules. Git ignored files are skipped by default.
361
367
  - **`rules`** (required): Array of rule objects
362
368
 
@@ -364,16 +370,18 @@ Here's a comprehensive example showing all available properties:
364
370
  Each rule can contain the following properties:
365
371
 
366
372
  - **`path`** (required): Target directory path for this rule (either `.` or path starting with sub directory name)
367
- - **`followMonorepoPackages`** (optional): Enable monorepo package resolution (default: true)
373
+ - **`followMonorepoPackages`** (optional): Control monorepo package resolution. `true` follows all workspace packages (default), `false` disables it, array follows only selected package names.
374
+ - **`prodEntryPoints`** (optional): Rule-level production entry point patterns for detector defaults
375
+ - **`devEntryPoints`** (optional): Rule-level development entry point patterns for detector defaults
368
376
  - **`moduleBoundaries`** (optional): Array of module boundary rules
369
- - **`circularImportsDetection`** (optional): Circular import detection configuration
370
- - **`orphanFilesDetection`** (optional): Orphan files detection configuration
371
- - **`unusedNodeModulesDetection`** (optional): Unused node modules detection configuration
372
- - **`missingNodeModulesDetection`** (optional): Missing node modules detection configuration
373
- - **`unusedExportsDetection`** (optional): Unused exports detection configuration
374
- - **`unresolvedImportsDetection`** (optional): Unresolved imports detection configuration
375
- - **`devDepsUsageOnProdDetection`** (optional): Restricted dev dependencies usage detection configuration
376
- - **`restrictedImportsDetection`** (optional): Restrict importing denied files/modules from selected entry points
377
+ - **`circularImportsDetection`** (optional): Circular import detection configuration (single object or array of objects)
378
+ - **`orphanFilesDetection`** (optional): Orphan files detection configuration (single object or array of objects)
379
+ - **`unusedNodeModulesDetection`** (optional): Unused node modules detection configuration (single object or array of objects)
380
+ - **`missingNodeModulesDetection`** (optional): Missing node modules detection configuration (single object or array of objects)
381
+ - **`unusedExportsDetection`** (optional): Unused exports detection configuration (single object or array of objects)
382
+ - **`unresolvedImportsDetection`** (optional): Unresolved imports detection configuration (single object or array of objects)
383
+ - **`devDepsUsageOnProdDetection`** (optional): Restricted dev dependencies usage detection configuration (single object or array of objects)
384
+ - **`restrictedImportsDetection`** (optional): Restrict importing denied files/modules from selected entry points (single object or array of objects)
377
385
  - **`importConventions`** (optional): Array of import convention rules
378
386
 
379
387
  #### Module Boundary Properties
@@ -392,13 +400,17 @@ Each rule can contain the following properties:
392
400
 
393
401
  #### Detection Options Properties
394
402
 
403
+ Each detection property can be configured as:
404
+ - a single object (one detector instance), or
405
+ - an array of objects (multiple detector instances evaluated within the same rule).
406
+
395
407
  **CircularImportsDetection:**
396
408
  - **`enabled`** (required): Enable/disable circular import detection
397
409
  - **`ignoreTypeImports`** (optional): Exclude type-only imports when building graph (default: false)
398
410
 
399
411
  **OrphanFilesDetection:**
400
412
  - **`enabled`** (required): Enable/disable orphan files detection
401
- - **`validEntryPoints`** (optional): Array of valid entry point patterns (eg. ["src/index.ts", "src/main.ts"])
413
+ - **`validEntryPoints`** (optional): Array of valid entry point patterns. If omitted, defaults to `prodEntryPoints + devEntryPoints` from rule level.
402
414
  - **`ignoreTypeImports`** (optional): Exclude type-only imports when building graph (default: false)
403
415
  - **`graphExclude`** (optional): File patterns to exclude from graph analysis
404
416
  - **`autofix`** (optional): Delete detected orphan files automatically when running `rev-dep config run --fix` (default: false)
@@ -420,24 +432,29 @@ Each rule can contain the following properties:
420
432
 
421
433
  **UnusedExportsDetection:**
422
434
  - **`enabled`** (required): Enable/disable unused exports detection
423
- - **`validEntryPoints`** (optional): Glob patterns for files whose exports are never reported as unused (eg. ["index.ts", "src/public-api.ts"])
435
+ - **`validEntryPoints`** (optional): Glob patterns for files whose exports are never reported as unused. If omitted, defaults to `prodEntryPoints + devEntryPoints` from rule level.
424
436
  - **`ignoreTypeExports`** (optional): Skip `export type` / `export interface` from analysis (default: false)
425
437
  - **`graphExclude`** (optional): File patterns to exclude from unused exports analysis
438
+ - **`ignore`** (optional): Map of file path globs (relative to rule path directory) to export name/specifier glob(s) to suppress; each value can be a string or array of strings
439
+ - **`ignoreFiles`** (optional): File path globs; all unused exports from matching files are suppressed
440
+ - **`ignoreExports`** (optional): Export names/specifiers (or globs) to suppress globally (supports `"default"`)
441
+ - **`autofix`** (optional): Automatically apply fixable unused exports changes when running `rev-dep config run --fix` (default: false)
426
442
 
427
443
  **UnresolvedImportsDetection:**
428
444
  - **`enabled`** (required): Enable/disable unresolved imports detection
429
- - **`ignore`** (optional): Map of file path (relative to rule path directory) to exact import request to suppress
445
+ - **`ignore`** (optional): Map of file path globs (relative to rule path directory) to import request glob(s) to suppress; each value can be a string or array of strings
430
446
  - **`ignoreFiles`** (optional): File path globs; all unresolved imports from matching files are suppressed
431
- - **`ignoreImports`** (optional): Import requests to suppress globally in unresolved results
447
+ - **`ignoreImports`** (optional): Import requests (or globs) to suppress globally in unresolved results
432
448
 
433
- **DevDepsUsageOnProd:**
449
+ **DevDepsUsageOnProdDetection:**
434
450
  - **`enabled`** (required): Enable/disable restricted dev dependencies usage detection
435
- - **`prodEntryPoints`** (optional): Production entry point patterns to trace dependencies from (eg. ["src/pages/**/*.tsx", "src/main.tsx"])
451
+ - **`prodEntryPoints`** (optional): Production entry point patterns to trace dependencies from. If omitted, defaults to rule-level `prodEntryPoints`.
436
452
  - **`ignoreTypeImports`** (optional): Exclude type-only imports from graph traversal and module matching (default: false)
437
453
 
438
454
  **RestrictedImportsDetection:**
439
455
  - **`enabled`** (required): Enable/disable restricted imports detection
440
- - **`entryPoints`** (required when enabled): Entry point patterns used to build reachable dependency graph
456
+ - **`entryPoints`** (required when enabled): Entry point patterns used to build reachable dependency graph (rule-level entry points are not applied here)
457
+ - **`graphExclude`** (optional): File patterns to exclude from restricted imports graph analysis
441
458
  - **`denyFiles`** (optional): Denied file path patterns (eg. ["**/*.tsx"])
442
459
  - **`denyModules`** (optional): Denied module patterns (eg. ["react", "react-*"])
443
460
  - **`ignoreMatches`** (optional): File/module patterns to suppress from restricted import results
@@ -946,6 +963,35 @@ rev-dep list-cwd-files --include='*.ts' --exclude='*.test.ts'
946
963
  ```
947
964
 
948
965
 
966
+ ### rev-dep unresolved
967
+
968
+ List unresolved imports in the project
969
+
970
+ #### Synopsis
971
+
972
+ Detect and list imports that could not be resolved during imports resolution. Groups imports by file.
973
+
974
+ ```
975
+ rev-dep unresolved [flags]
976
+ ```
977
+
978
+ #### Options
979
+
980
+ ```
981
+ --condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
982
+ --custom-asset-extensions strings Additional asset extensions treated as resolvable (e.g. glb,mp3)
983
+ -c, --cwd string Working directory for the command (default "$PWD")
984
+ --follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
985
+ -h, --help help for unresolved
986
+ --ignore stringToString Map of file path (relative to cwd) to exact import request to ignore (e.g. --ignore src/index.ts=some-module) (default [])
987
+ --ignore-files strings File path glob patterns to ignore in unresolved output
988
+ --ignore-imports strings Import requests to ignore globally in unresolved output
989
+ --package-json string Path to package.json (default: ./package.json)
990
+ --tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
991
+ -v, --verbose Show warnings and verbose output
992
+ ```
993
+
994
+
949
995
  ### rev-dep node-modules
950
996
 
951
997
  Analyze and manage Node.js dependencies
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rev-dep",
3
- "version": "2.9.1",
3
+ "version": "2.11.0",
4
4
  "description": "Trace imports, detect unused code, clean dependencies — all with a super-fast CLI",
5
5
  "bin": "bin.js",
6
6
  "files": [
@@ -17,9 +17,9 @@
17
17
  "node": ">=18"
18
18
  },
19
19
  "optionalDependencies": {
20
- "@rev-dep/darwin-arm64": "2.9.1",
21
- "@rev-dep/linux-x64": "2.9.1",
22
- "@rev-dep/win32-x64": "2.9.1"
20
+ "@rev-dep/darwin-arm64": "2.11.0",
21
+ "@rev-dep/linux-x64": "2.11.0",
22
+ "@rev-dep/win32-x64": "2.11.0"
23
23
  },
24
24
  "keywords": [
25
25
  "dependency-analysis",