@mathonsunday/dead-code-toolkit 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 (94) hide show
  1. package/README.md +356 -0
  2. package/dist/analyzer.d.ts +23 -0
  3. package/dist/analyzer.d.ts.map +1 -0
  4. package/dist/analyzer.js +173 -0
  5. package/dist/analyzer.js.map +1 -0
  6. package/dist/checkers/knipChecker.d.ts +11 -0
  7. package/dist/checkers/knipChecker.d.ts.map +1 -0
  8. package/dist/checkers/knipChecker.js +226 -0
  9. package/dist/checkers/knipChecker.js.map +1 -0
  10. package/dist/checkers/typescriptChecker.d.ts +10 -0
  11. package/dist/checkers/typescriptChecker.d.ts.map +1 -0
  12. package/dist/checkers/typescriptChecker.js +174 -0
  13. package/dist/checkers/typescriptChecker.js.map +1 -0
  14. package/dist/cli/index.d.ts +7 -0
  15. package/dist/cli/index.d.ts.map +1 -0
  16. package/dist/cli/index.js +204 -0
  17. package/dist/cli/index.js.map +1 -0
  18. package/dist/config/detectors.d.ts +29 -0
  19. package/dist/config/detectors.d.ts.map +1 -0
  20. package/dist/config/detectors.js +159 -0
  21. package/dist/config/detectors.js.map +1 -0
  22. package/dist/config/templates.d.ts +76 -0
  23. package/dist/config/templates.d.ts.map +1 -0
  24. package/dist/config/templates.js +191 -0
  25. package/dist/config/templates.js.map +1 -0
  26. package/dist/index.d.ts +13 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +17 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/reporters/jsonReporter.d.ts +68 -0
  31. package/dist/reporters/jsonReporter.d.ts.map +1 -0
  32. package/dist/reporters/jsonReporter.js +161 -0
  33. package/dist/reporters/jsonReporter.js.map +1 -0
  34. package/dist/setup/hookInstaller.d.ts +36 -0
  35. package/dist/setup/hookInstaller.d.ts.map +1 -0
  36. package/dist/setup/hookInstaller.js +196 -0
  37. package/dist/setup/hookInstaller.js.map +1 -0
  38. package/dist/setup/installer.d.ts +10 -0
  39. package/dist/setup/installer.d.ts.map +1 -0
  40. package/dist/setup/installer.js +156 -0
  41. package/dist/setup/installer.js.map +1 -0
  42. package/dist/setup/packageJsonUpdater.d.ts +54 -0
  43. package/dist/setup/packageJsonUpdater.d.ts.map +1 -0
  44. package/dist/setup/packageJsonUpdater.js +129 -0
  45. package/dist/setup/packageJsonUpdater.js.map +1 -0
  46. package/dist/src/analyzer.d.ts +23 -0
  47. package/dist/src/analyzer.d.ts.map +1 -0
  48. package/dist/src/analyzer.js +173 -0
  49. package/dist/src/analyzer.js.map +1 -0
  50. package/dist/src/checkers/knipChecker.d.ts +11 -0
  51. package/dist/src/checkers/knipChecker.d.ts.map +1 -0
  52. package/dist/src/checkers/knipChecker.js +226 -0
  53. package/dist/src/checkers/knipChecker.js.map +1 -0
  54. package/dist/src/checkers/typescriptChecker.d.ts +10 -0
  55. package/dist/src/checkers/typescriptChecker.d.ts.map +1 -0
  56. package/dist/src/checkers/typescriptChecker.js +174 -0
  57. package/dist/src/checkers/typescriptChecker.js.map +1 -0
  58. package/dist/src/config/detectors.d.ts +29 -0
  59. package/dist/src/config/detectors.d.ts.map +1 -0
  60. package/dist/src/config/detectors.js +159 -0
  61. package/dist/src/config/detectors.js.map +1 -0
  62. package/dist/src/config/templates.d.ts +76 -0
  63. package/dist/src/config/templates.d.ts.map +1 -0
  64. package/dist/src/config/templates.js +191 -0
  65. package/dist/src/config/templates.js.map +1 -0
  66. package/dist/src/index.d.ts +13 -0
  67. package/dist/src/index.d.ts.map +1 -0
  68. package/dist/src/index.js +17 -0
  69. package/dist/src/index.js.map +1 -0
  70. package/dist/src/reporters/jsonReporter.d.ts +68 -0
  71. package/dist/src/reporters/jsonReporter.d.ts.map +1 -0
  72. package/dist/src/reporters/jsonReporter.js +161 -0
  73. package/dist/src/reporters/jsonReporter.js.map +1 -0
  74. package/dist/src/setup/hookInstaller.d.ts +36 -0
  75. package/dist/src/setup/hookInstaller.d.ts.map +1 -0
  76. package/dist/src/setup/hookInstaller.js +196 -0
  77. package/dist/src/setup/hookInstaller.js.map +1 -0
  78. package/dist/src/setup/installer.d.ts +10 -0
  79. package/dist/src/setup/installer.d.ts.map +1 -0
  80. package/dist/src/setup/installer.js +156 -0
  81. package/dist/src/setup/installer.js.map +1 -0
  82. package/dist/src/setup/packageJsonUpdater.d.ts +54 -0
  83. package/dist/src/setup/packageJsonUpdater.d.ts.map +1 -0
  84. package/dist/src/setup/packageJsonUpdater.js +129 -0
  85. package/dist/src/setup/packageJsonUpdater.js.map +1 -0
  86. package/dist/src/types.d.ts +177 -0
  87. package/dist/src/types.d.ts.map +1 -0
  88. package/dist/src/types.js +5 -0
  89. package/dist/src/types.js.map +1 -0
  90. package/dist/types.d.ts +177 -0
  91. package/dist/types.d.ts.map +1 -0
  92. package/dist/types.js +5 -0
  93. package/dist/types.js.map +1 -0
  94. package/package.json +84 -0
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Core type definitions for dead code analysis toolkit
3
+ */
4
+ /**
5
+ * Configuration options for dead code analysis
6
+ */
7
+ export interface AnalysisOptions {
8
+ /** Absolute path to project root directory */
9
+ projectRoot: string;
10
+ /** Which checks to run. Default: all */
11
+ checks?: CheckType[];
12
+ /** Automatically fix issues where possible */
13
+ fix?: boolean;
14
+ /** Custom paths to configuration files */
15
+ configPaths?: Partial<Record<string, string>>;
16
+ /** Verbose logging output */
17
+ verbose?: boolean;
18
+ }
19
+ /**
20
+ * Available check types
21
+ */
22
+ export type CheckType = 'knip' | 'typescript' | 'eslint' | 'type-coverage' | 'exhaustiveness' | 'all';
23
+ /**
24
+ * Result of a single analysis check
25
+ */
26
+ export interface CheckResult {
27
+ type: CheckType;
28
+ status: 'success' | 'failure' | 'skipped';
29
+ findings: Finding[];
30
+ executionTime: number;
31
+ error?: string;
32
+ }
33
+ /**
34
+ * Individual finding - a piece of dead code or issue detected
35
+ */
36
+ export interface Finding {
37
+ /** Category of the finding */
38
+ category: 'unused-export' | 'unused-file' | 'unused-dependency' | 'type-error' | 'unused-var' | 'redundant-type' | 'union-issue' | 'unused-param';
39
+ /** Severity level */
40
+ severity: 'error' | 'warning' | 'info';
41
+ /** File path (relative to project root) */
42
+ file: string;
43
+ /** Line number (1-based, if applicable) */
44
+ line?: number;
45
+ /** Column number (1-based, if applicable) */
46
+ column?: number;
47
+ /** Human-readable message describing the issue */
48
+ message: string;
49
+ /** Whether this issue can be automatically fixed */
50
+ fixable: boolean;
51
+ /** Suggestion for how to fix the issue */
52
+ suggestion?: string;
53
+ /** Source tool that detected this */
54
+ source: CheckType;
55
+ /** Rule name or code from the tool */
56
+ rule?: string;
57
+ }
58
+ /**
59
+ * Summary statistics for analysis results
60
+ */
61
+ export interface AnalysisSummary {
62
+ /** Total number of issues found */
63
+ totalIssues: number;
64
+ /** Breakdown by category */
65
+ byCategory: Record<string, number>;
66
+ /** Number of issues that can be auto-fixed */
67
+ fixableCount: number;
68
+ /** Number of errors (highest severity) */
69
+ errorCount: number;
70
+ /** Number of warnings */
71
+ warningCount: number;
72
+ /** Number of info/low severity items */
73
+ infoCount: number;
74
+ }
75
+ /**
76
+ * Complete analysis result
77
+ */
78
+ export interface AnalysisResult {
79
+ /** Overall status of the analysis */
80
+ status: 'success' | 'partial' | 'failure';
81
+ /** Summary statistics */
82
+ summary: AnalysisSummary;
83
+ /** All findings from all checks */
84
+ findings: Finding[];
85
+ /** Results from individual checks */
86
+ checkResults: CheckResult[];
87
+ /** Total execution time in milliseconds */
88
+ executionTime: number;
89
+ /** Error message if status is 'failure' */
90
+ error?: string;
91
+ }
92
+ /**
93
+ * Result of applying fixes
94
+ */
95
+ export interface FixResult {
96
+ /** Overall status */
97
+ status: 'success' | 'partial' | 'failure';
98
+ /** Number of issues fixed */
99
+ fixedCount: number;
100
+ /** Number of issues that could not be fixed */
101
+ unfixedCount: number;
102
+ /** Files that were modified */
103
+ modifiedFiles: string[];
104
+ /** Details of what was fixed */
105
+ fixes: FixDetail[];
106
+ /** Any errors that occurred */
107
+ errors?: string[];
108
+ }
109
+ /**
110
+ * Details about a single fix that was applied
111
+ */
112
+ export interface FixDetail {
113
+ /** The finding that was fixed */
114
+ finding: Finding;
115
+ /** What was changed */
116
+ action: string;
117
+ /** Was it successful */
118
+ success: boolean;
119
+ /** Error message if unsuccessful */
120
+ error?: string;
121
+ }
122
+ /**
123
+ * Configuration options for setup
124
+ */
125
+ export interface SetupOptions {
126
+ /** Absolute path to project root */
127
+ projectRoot: string;
128
+ /** Install pre-commit hooks */
129
+ setupHooks?: boolean;
130
+ /** Install npm dependencies */
131
+ installDependencies?: boolean;
132
+ /** Override default configs */
133
+ configOverrides?: Partial<Record<string, unknown>>;
134
+ /** Show detailed output */
135
+ verbose?: boolean;
136
+ }
137
+ /**
138
+ * Result of setup process
139
+ */
140
+ export interface SetupResult {
141
+ /** Overall status */
142
+ status: 'success' | 'partial' | 'failure';
143
+ /** Files created during setup */
144
+ filesCreated: string[];
145
+ /** Scripts added to package.json */
146
+ scriptsAdded: string[];
147
+ /** Dependencies installed */
148
+ dependenciesInstalled: string[];
149
+ /** Next steps for user */
150
+ nextSteps: string[];
151
+ /** Any errors that occurred */
152
+ errors?: string[];
153
+ }
154
+ /**
155
+ * Detected project configuration
156
+ */
157
+ export interface ProjectConfig {
158
+ /** Root directory */
159
+ root: string;
160
+ /** Whether package.json exists */
161
+ hasPackageJson: boolean;
162
+ /** Whether TypeScript is configured */
163
+ hasTypeScript: boolean;
164
+ /** TypeScript config path if present */
165
+ tsconfigPath?: string;
166
+ /** Project type */
167
+ type: 'react' | 'node' | 'fullstack' | 'unknown';
168
+ /** Existing tool configs present */
169
+ existingConfigs: {
170
+ eslint?: string;
171
+ prettier?: string;
172
+ knip?: string;
173
+ husky?: string;
174
+ [key: string]: string | undefined;
175
+ };
176
+ }
177
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG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,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;KACnC,CAAC;CACH"}
package/dist/types.js ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Core type definitions for dead code analysis toolkit
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@mathonsunday/dead-code-toolkit",
3
+ "version": "0.1.0",
4
+ "description": "Comprehensive dead code detection and cleanup toolkit for TypeScript projects. Detects unused exports, files, dependencies, type errors, and more via Knip, TypeScript, ESLint, and custom analysis.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "bin": {
9
+ "dead-code-toolkit": "./dist/cli/index.js"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "templates"
14
+ ],
15
+ "exports": {
16
+ ".": {
17
+ "import": "./dist/index.js",
18
+ "types": "./dist/index.d.ts"
19
+ },
20
+ "./setup": {
21
+ "import": "./dist/setup/installer.js",
22
+ "types": "./dist/setup/installer.d.ts"
23
+ },
24
+ "./analyze": {
25
+ "import": "./dist/analyzer.js",
26
+ "types": "./dist/analyzer.d.ts"
27
+ }
28
+ },
29
+ "scripts": {
30
+ "build": "tsc",
31
+ "build:watch": "tsc --watch",
32
+ "test": "vitest",
33
+ "test:ui": "vitest --ui",
34
+ "lint": "eslint src",
35
+ "type-check": "tsc --noEmit",
36
+ "dev": "tsc --watch"
37
+ },
38
+ "keywords": [
39
+ "dead-code",
40
+ "dead-code-detection",
41
+ "unused-exports",
42
+ "unused-files",
43
+ "typescript",
44
+ "linting",
45
+ "code-quality",
46
+ "cli",
47
+ "knip",
48
+ "eslint"
49
+ ],
50
+ "author": "mathonsunday",
51
+ "license": "MIT",
52
+ "dependencies": {
53
+ "@types/node": "^24.10.1",
54
+ "commander": "^12.1.0",
55
+ "typescript": "~5.9.3"
56
+ },
57
+ "devDependencies": {
58
+ "@eslint/js": "^9.39.1",
59
+ "@types/node": "^24.10.1",
60
+ "eslint": "^9.39.1",
61
+ "typescript": "~5.9.3",
62
+ "typescript-eslint": "^8.46.4",
63
+ "vitest": "^4.0.17"
64
+ },
65
+ "peerDependencies": {
66
+ "knip": "^5.82.0 || ^6.0.0",
67
+ "eslint": "^9.0.0 || ^8.50.0"
68
+ },
69
+ "peerDependenciesOptional": {
70
+ "knip": "^5.82.0 || ^6.0.0",
71
+ "eslint": "^9.0.0 || ^8.50.0"
72
+ },
73
+ "engines": {
74
+ "node": ">=18.0.0"
75
+ },
76
+ "repository": {
77
+ "type": "git",
78
+ "url": "https://github.com/mathonsunday/dead-code-toolkit"
79
+ },
80
+ "bugs": {
81
+ "url": "https://github.com/mathonsunday/dead-code-toolkit/issues"
82
+ },
83
+ "homepage": "https://github.com/mathonsunday/dead-code-toolkit#readme"
84
+ }