distyll 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 (243) hide show
  1. package/CONTRIBUTING.md +159 -0
  2. package/POSTMORTEM.json +60 -0
  3. package/README.md +218 -0
  4. package/SETUP.md +79 -0
  5. package/action.yml +37 -0
  6. package/dist/cache.d.ts +26 -0
  7. package/dist/cache.d.ts.map +1 -0
  8. package/dist/cache.js +115 -0
  9. package/dist/cache.js.map +1 -0
  10. package/dist/cli.d.ts +3 -0
  11. package/dist/cli.d.ts.map +1 -0
  12. package/dist/cli.js +153 -0
  13. package/dist/cli.js.map +1 -0
  14. package/dist/commands/ci.d.ts +7 -0
  15. package/dist/commands/ci.d.ts.map +1 -0
  16. package/dist/commands/ci.js +101 -0
  17. package/dist/commands/ci.js.map +1 -0
  18. package/dist/commands/diff.d.ts +10 -0
  19. package/dist/commands/diff.d.ts.map +1 -0
  20. package/dist/commands/diff.js +95 -0
  21. package/dist/commands/diff.js.map +1 -0
  22. package/dist/commands/fingerprint.d.ts +2 -0
  23. package/dist/commands/fingerprint.d.ts.map +1 -0
  24. package/dist/commands/fingerprint.js +77 -0
  25. package/dist/commands/fingerprint.js.map +1 -0
  26. package/dist/commands/hook.d.ts +3 -0
  27. package/dist/commands/hook.d.ts.map +1 -0
  28. package/dist/commands/hook.js +110 -0
  29. package/dist/commands/hook.js.map +1 -0
  30. package/dist/commands/init.d.ts +2 -0
  31. package/dist/commands/init.d.ts.map +1 -0
  32. package/dist/commands/init.js +75 -0
  33. package/dist/commands/init.js.map +1 -0
  34. package/dist/config.d.ts +7 -0
  35. package/dist/config.d.ts.map +1 -0
  36. package/dist/config.js +100 -0
  37. package/dist/config.js.map +1 -0
  38. package/dist/errors.d.ts +30 -0
  39. package/dist/errors.d.ts.map +1 -0
  40. package/dist/errors.js +133 -0
  41. package/dist/errors.js.map +1 -0
  42. package/dist/fingerprint/analyzer.d.ts +3 -0
  43. package/dist/fingerprint/analyzer.d.ts.map +1 -0
  44. package/dist/fingerprint/analyzer.js +230 -0
  45. package/dist/fingerprint/analyzer.js.map +1 -0
  46. package/dist/fingerprint/comparator.d.ts +4 -0
  47. package/dist/fingerprint/comparator.d.ts.map +1 -0
  48. package/dist/fingerprint/comparator.js +78 -0
  49. package/dist/fingerprint/comparator.js.map +1 -0
  50. package/dist/fingerprint/profile.d.ts +5 -0
  51. package/dist/fingerprint/profile.d.ts.map +1 -0
  52. package/dist/fingerprint/profile.js +68 -0
  53. package/dist/fingerprint/profile.js.map +1 -0
  54. package/dist/fixes/index.d.ts +12 -0
  55. package/dist/fixes/index.d.ts.map +1 -0
  56. package/dist/fixes/index.js +42 -0
  57. package/dist/fixes/index.js.map +1 -0
  58. package/dist/fixes/single-use-wrapper.d.ts +8 -0
  59. package/dist/fixes/single-use-wrapper.d.ts.map +1 -0
  60. package/dist/fixes/single-use-wrapper.js +54 -0
  61. package/dist/fixes/single-use-wrapper.js.map +1 -0
  62. package/dist/fixes/unnecessary-try-catch.d.ts +8 -0
  63. package/dist/fixes/unnecessary-try-catch.d.ts.map +1 -0
  64. package/dist/fixes/unnecessary-try-catch.js +37 -0
  65. package/dist/fixes/unnecessary-try-catch.js.map +1 -0
  66. package/dist/fixes/unused-imports.d.ts +7 -0
  67. package/dist/fixes/unused-imports.d.ts.map +1 -0
  68. package/dist/fixes/unused-imports.js +41 -0
  69. package/dist/fixes/unused-imports.js.map +1 -0
  70. package/dist/fixes/verbose-comments.d.ts +7 -0
  71. package/dist/fixes/verbose-comments.d.ts.map +1 -0
  72. package/dist/fixes/verbose-comments.js +29 -0
  73. package/dist/fixes/verbose-comments.js.map +1 -0
  74. package/dist/formatter.d.ts +4 -0
  75. package/dist/formatter.d.ts.map +1 -0
  76. package/dist/formatter.js +72 -0
  77. package/dist/formatter.js.map +1 -0
  78. package/dist/git.d.ts +22 -0
  79. package/dist/git.d.ts.map +1 -0
  80. package/dist/git.js +130 -0
  81. package/dist/git.js.map +1 -0
  82. package/dist/index.d.ts +16 -0
  83. package/dist/index.d.ts.map +1 -0
  84. package/dist/index.js +40 -0
  85. package/dist/index.js.map +1 -0
  86. package/dist/languages/index.d.ts +8 -0
  87. package/dist/languages/index.d.ts.map +1 -0
  88. package/dist/languages/index.js +50 -0
  89. package/dist/languages/index.js.map +1 -0
  90. package/dist/languages/javascript.d.ts +6 -0
  91. package/dist/languages/javascript.d.ts.map +1 -0
  92. package/dist/languages/javascript.js +39 -0
  93. package/dist/languages/javascript.js.map +1 -0
  94. package/dist/languages/python.d.ts +6 -0
  95. package/dist/languages/python.d.ts.map +1 -0
  96. package/dist/languages/python.js +50 -0
  97. package/dist/languages/python.js.map +1 -0
  98. package/dist/parser.d.ts +8 -0
  99. package/dist/parser.d.ts.map +1 -0
  100. package/dist/parser.js +55 -0
  101. package/dist/parser.js.map +1 -0
  102. package/dist/reporters/github.d.ts +4 -0
  103. package/dist/reporters/github.d.ts.map +1 -0
  104. package/dist/reporters/github.js +70 -0
  105. package/dist/reporters/github.js.map +1 -0
  106. package/dist/reporters/terminal.d.ts +4 -0
  107. package/dist/reporters/terminal.d.ts.map +1 -0
  108. package/dist/reporters/terminal.js +59 -0
  109. package/dist/reporters/terminal.js.map +1 -0
  110. package/dist/rules/dead-code-paths.d.ts +3 -0
  111. package/dist/rules/dead-code-paths.d.ts.map +1 -0
  112. package/dist/rules/dead-code-paths.js +57 -0
  113. package/dist/rules/dead-code-paths.js.map +1 -0
  114. package/dist/rules/excessive-comments.d.ts +3 -0
  115. package/dist/rules/excessive-comments.d.ts.map +1 -0
  116. package/dist/rules/excessive-comments.js +86 -0
  117. package/dist/rules/excessive-comments.js.map +1 -0
  118. package/dist/rules/hallucinated-imports.d.ts +3 -0
  119. package/dist/rules/hallucinated-imports.d.ts.map +1 -0
  120. package/dist/rules/hallucinated-imports.js +228 -0
  121. package/dist/rules/hallucinated-imports.js.map +1 -0
  122. package/dist/rules/index.d.ts +4 -0
  123. package/dist/rules/index.d.ts.map +1 -0
  124. package/dist/rules/index.js +34 -0
  125. package/dist/rules/index.js.map +1 -0
  126. package/dist/rules/magic-values.d.ts +3 -0
  127. package/dist/rules/magic-values.d.ts.map +1 -0
  128. package/dist/rules/magic-values.js +168 -0
  129. package/dist/rules/magic-values.js.map +1 -0
  130. package/dist/rules/near-duplicate-functions.d.ts +3 -0
  131. package/dist/rules/near-duplicate-functions.d.ts.map +1 -0
  132. package/dist/rules/near-duplicate-functions.js +78 -0
  133. package/dist/rules/near-duplicate-functions.js.map +1 -0
  134. package/dist/rules/over-defensive-nulls.d.ts +3 -0
  135. package/dist/rules/over-defensive-nulls.d.ts.map +1 -0
  136. package/dist/rules/over-defensive-nulls.js +129 -0
  137. package/dist/rules/over-defensive-nulls.js.map +1 -0
  138. package/dist/rules/redundant-else-return.d.ts +3 -0
  139. package/dist/rules/redundant-else-return.d.ts.map +1 -0
  140. package/dist/rules/redundant-else-return.js +57 -0
  141. package/dist/rules/redundant-else-return.js.map +1 -0
  142. package/dist/rules/single-option-object.d.ts +3 -0
  143. package/dist/rules/single-option-object.d.ts.map +1 -0
  144. package/dist/rules/single-option-object.js +88 -0
  145. package/dist/rules/single-option-object.js.map +1 -0
  146. package/dist/rules/single-use-wrapper.d.ts +3 -0
  147. package/dist/rules/single-use-wrapper.d.ts.map +1 -0
  148. package/dist/rules/single-use-wrapper.js +172 -0
  149. package/dist/rules/single-use-wrapper.js.map +1 -0
  150. package/dist/rules/unnecessary-try-catch.d.ts +3 -0
  151. package/dist/rules/unnecessary-try-catch.d.ts.map +1 -0
  152. package/dist/rules/unnecessary-try-catch.js +116 -0
  153. package/dist/rules/unnecessary-try-catch.js.map +1 -0
  154. package/dist/rules/unused-imports.d.ts +3 -0
  155. package/dist/rules/unused-imports.d.ts.map +1 -0
  156. package/dist/rules/unused-imports.js +103 -0
  157. package/dist/rules/unused-imports.js.map +1 -0
  158. package/dist/rules/verbose-comments.d.ts +3 -0
  159. package/dist/rules/verbose-comments.d.ts.map +1 -0
  160. package/dist/rules/verbose-comments.js +100 -0
  161. package/dist/rules/verbose-comments.js.map +1 -0
  162. package/dist/scanner.d.ts +11 -0
  163. package/dist/scanner.d.ts.map +1 -0
  164. package/dist/scanner.js +196 -0
  165. package/dist/scanner.js.map +1 -0
  166. package/dist/scorer.d.ts +3 -0
  167. package/dist/scorer.d.ts.map +1 -0
  168. package/dist/scorer.js +23 -0
  169. package/dist/scorer.js.map +1 -0
  170. package/dist/types.d.ts +62 -0
  171. package/dist/types.d.ts.map +1 -0
  172. package/dist/types.js +3 -0
  173. package/dist/types.js.map +1 -0
  174. package/hn_post.md +13 -0
  175. package/marketing/COMPETITIVE_ANALYSIS.md +62 -0
  176. package/marketing/EMAIL_ANNOUNCEMENT.md +91 -0
  177. package/marketing/LANDING_PAGE_COPY.md +123 -0
  178. package/marketing/LAUNCH_POST.md +68 -0
  179. package/marketing/PRODUCT_HUNT.md +39 -0
  180. package/marketing/TWITTER_THREAD.md +70 -0
  181. package/package.json +44 -0
  182. package/producthunt.md +52 -0
  183. package/reddit_post.md +39 -0
  184. package/site/favicon.svg +10 -0
  185. package/site/index.html +281 -0
  186. package/site/script.js +82 -0
  187. package/site/style.css +516 -0
  188. package/src/cache.ts +114 -0
  189. package/src/cli.ts +169 -0
  190. package/src/commands/ci.ts +111 -0
  191. package/src/commands/diff.ts +108 -0
  192. package/src/commands/fingerprint.ts +47 -0
  193. package/src/commands/hook.ts +85 -0
  194. package/src/commands/init.ts +42 -0
  195. package/src/config.ts +75 -0
  196. package/src/errors.ts +105 -0
  197. package/src/fingerprint/analyzer.ts +214 -0
  198. package/src/fingerprint/comparator.ts +93 -0
  199. package/src/fingerprint/profile.ts +32 -0
  200. package/src/fixes/index.ts +58 -0
  201. package/src/fixes/single-use-wrapper.ts +60 -0
  202. package/src/fixes/unnecessary-try-catch.ts +43 -0
  203. package/src/fixes/unused-imports.ts +53 -0
  204. package/src/fixes/verbose-comments.ts +35 -0
  205. package/src/formatter.ts +79 -0
  206. package/src/git.ts +115 -0
  207. package/src/index.ts +15 -0
  208. package/src/languages/index.ts +50 -0
  209. package/src/languages/javascript.ts +36 -0
  210. package/src/languages/python.ts +47 -0
  211. package/src/parser.ts +52 -0
  212. package/src/reporters/github.ts +75 -0
  213. package/src/reporters/terminal.ts +67 -0
  214. package/src/rules/dead-code-paths.ts +62 -0
  215. package/src/rules/excessive-comments.ts +94 -0
  216. package/src/rules/hallucinated-imports.ts +195 -0
  217. package/src/rules/index.ts +32 -0
  218. package/src/rules/magic-values.ts +167 -0
  219. package/src/rules/near-duplicate-functions.ts +89 -0
  220. package/src/rules/over-defensive-nulls.ts +137 -0
  221. package/src/rules/redundant-else-return.ts +61 -0
  222. package/src/rules/single-option-object.ts +97 -0
  223. package/src/rules/single-use-wrapper.ts +184 -0
  224. package/src/rules/unnecessary-try-catch.ts +121 -0
  225. package/src/rules/unused-imports.ts +115 -0
  226. package/src/rules/verbose-comments.ts +105 -0
  227. package/src/scanner.ts +184 -0
  228. package/src/scorer.ts +26 -0
  229. package/src/types.ts +70 -0
  230. package/tests/commands/diff.test.ts +107 -0
  231. package/tests/config.test.ts +69 -0
  232. package/tests/e2e.test.ts +163 -0
  233. package/tests/edge-cases.test.ts +167 -0
  234. package/tests/fingerprint/analyzer.test.ts +131 -0
  235. package/tests/fixes/unnecessary-try-catch.test.ts +62 -0
  236. package/tests/git.test.ts +79 -0
  237. package/tests/rules/hallucinated-imports.test.ts +59 -0
  238. package/tests/rules/near-duplicate-functions.test.ts +90 -0
  239. package/tests/rules/unnecessary-try-catch.test.ts +81 -0
  240. package/tests/scanner.test.ts +88 -0
  241. package/tsconfig.json +20 -0
  242. package/twitter_thread.md +46 -0
  243. package/vitest.config.ts +7 -0
@@ -0,0 +1,230 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.analyzeCodebase = analyzeCodebase;
37
+ const parser_1 = require("../parser");
38
+ const scanner_1 = require("../scanner");
39
+ const fs = __importStar(require("fs"));
40
+ function countLines(text) {
41
+ if (text.length === 0)
42
+ return 0;
43
+ let count = 1;
44
+ for (let i = 0; i < text.length; i++) {
45
+ if (text[i] === '\n')
46
+ count++;
47
+ }
48
+ return count;
49
+ }
50
+ function getNestingDepth(node) {
51
+ let depth = 0;
52
+ let current = node.parent;
53
+ const blockTypes = new Set([
54
+ 'statement_block', 'block', 'if_statement', 'for_statement',
55
+ 'while_statement', 'for_in_statement', 'switch_statement',
56
+ 'try_statement', 'with_statement',
57
+ ]);
58
+ while (current) {
59
+ if (blockTypes.has(current.type))
60
+ depth++;
61
+ current = current.parent;
62
+ }
63
+ return depth;
64
+ }
65
+ const FUNCTION_TYPES = new Set([
66
+ 'function_declaration', 'method_definition', 'arrow_function',
67
+ 'function', 'function_definition',
68
+ ]);
69
+ const IMPORT_TYPES = new Set([
70
+ 'import_statement', 'import_declaration',
71
+ 'import_from_statement',
72
+ ]);
73
+ function classifyName(name) {
74
+ if (/^[A-Z][a-zA-Z0-9]*$/.test(name))
75
+ return 'PascalCase';
76
+ if (/^[a-z][a-zA-Z0-9]*$/.test(name) && /[A-Z]/.test(name))
77
+ return 'camelCase';
78
+ if (/^[a-z][a-z0-9_]*$/.test(name) && name.includes('_'))
79
+ return 'snake_case';
80
+ if (/^[a-z][a-z0-9]*$/.test(name))
81
+ return 'camelCase'; // single-word lowercase defaults to camelCase
82
+ return 'other';
83
+ }
84
+ function analyzeFileAST(tree, source) {
85
+ const metrics = {
86
+ functionLengths: [],
87
+ identifierNames: [],
88
+ commentLines: 0,
89
+ codeLines: 0,
90
+ nestingDepths: [],
91
+ tryCatchCount: 0,
92
+ importCount: 0,
93
+ loc: countLines(source),
94
+ };
95
+ (0, parser_1.walkTree)(tree.rootNode, (node) => {
96
+ // Function lengths
97
+ if (FUNCTION_TYPES.has(node.type)) {
98
+ const body = node.childForFieldName('body');
99
+ if (body) {
100
+ const fnLines = countLines(body.text);
101
+ metrics.functionLengths.push(fnLines);
102
+ metrics.nestingDepths.push(getNestingDepth(body));
103
+ }
104
+ }
105
+ // Identifier names (function declarations and variable declarations)
106
+ if (node.type === 'function_declaration' || node.type === 'function_definition') {
107
+ const nameNode = node.childForFieldName('name');
108
+ if (nameNode)
109
+ metrics.identifierNames.push(nameNode.text);
110
+ }
111
+ if (node.type === 'variable_declarator') {
112
+ const nameNode = node.childForFieldName('name');
113
+ if (nameNode && nameNode.type === 'identifier') {
114
+ metrics.identifierNames.push(nameNode.text);
115
+ }
116
+ }
117
+ // Comments
118
+ if (node.type === 'comment') {
119
+ metrics.commentLines += countLines(node.text);
120
+ }
121
+ // Try-catch
122
+ if (node.type === 'try_statement') {
123
+ metrics.tryCatchCount++;
124
+ }
125
+ // Imports
126
+ if (IMPORT_TYPES.has(node.type)) {
127
+ metrics.importCount++;
128
+ }
129
+ });
130
+ // Code lines = total lines minus comment lines (rough estimate)
131
+ metrics.codeLines = Math.max(1, metrics.loc - metrics.commentLines);
132
+ return metrics;
133
+ }
134
+ function median(values) {
135
+ if (values.length === 0)
136
+ return 0;
137
+ const sorted = [...values].sort((a, b) => a - b);
138
+ const mid = Math.floor(sorted.length / 2);
139
+ if (sorted.length % 2 === 0) {
140
+ return (sorted[mid - 1] + sorted[mid]) / 2;
141
+ }
142
+ return sorted[mid];
143
+ }
144
+ function average(values) {
145
+ if (values.length === 0)
146
+ return 0;
147
+ return values.reduce((a, b) => a + b, 0) / values.length;
148
+ }
149
+ async function analyzeCodebase(paths) {
150
+ const files = await (0, scanner_1.resolveFiles)(paths);
151
+ const allMetrics = [];
152
+ for (const filePath of files) {
153
+ const language = (0, parser_1.detectLanguage)(filePath);
154
+ if (!language)
155
+ continue;
156
+ let source;
157
+ try {
158
+ const buffer = fs.readFileSync(filePath);
159
+ if (buffer.length === 0)
160
+ continue;
161
+ // Skip binary files
162
+ const checkLength = Math.min(buffer.length, 1024);
163
+ let isBinary = false;
164
+ for (let i = 0; i < checkLength; i++) {
165
+ if (buffer[i] === 0) {
166
+ isBinary = true;
167
+ break;
168
+ }
169
+ }
170
+ if (isBinary)
171
+ continue;
172
+ source = buffer.toString('utf-8');
173
+ }
174
+ catch {
175
+ continue;
176
+ }
177
+ let tree;
178
+ try {
179
+ tree = (0, parser_1.parse)(source, language);
180
+ }
181
+ catch {
182
+ continue;
183
+ }
184
+ allMetrics.push(analyzeFileAST(tree, source));
185
+ }
186
+ return buildProfile(allMetrics, files.length);
187
+ }
188
+ function buildProfile(allMetrics, fileCount) {
189
+ const allFunctionLengths = allMetrics.flatMap((m) => m.functionLengths);
190
+ const allIdentifiers = allMetrics.flatMap((m) => m.identifierNames);
191
+ const allNestingDepths = allMetrics.flatMap((m) => m.nestingDepths);
192
+ const totalCommentLines = allMetrics.reduce((s, m) => s + m.commentLines, 0);
193
+ const totalCodeLines = allMetrics.reduce((s, m) => s + m.codeLines, 0);
194
+ const totalTryCatch = allMetrics.reduce((s, m) => s + m.tryCatchCount, 0);
195
+ const totalLoc = allMetrics.reduce((s, m) => s + m.loc, 0);
196
+ const totalImports = allMetrics.reduce((s, m) => s + m.importCount, 0);
197
+ const namingConventions = { camelCase: 0, snake_case: 0, PascalCase: 0, other: 0 };
198
+ for (const name of allIdentifiers) {
199
+ const category = classifyName(name);
200
+ namingConventions[category]++;
201
+ }
202
+ // Normalize naming conventions to percentages
203
+ const totalNames = Math.max(1, allIdentifiers.length);
204
+ namingConventions.camelCase = Math.round((namingConventions.camelCase / totalNames) * 100);
205
+ namingConventions.snake_case = Math.round((namingConventions.snake_case / totalNames) * 100);
206
+ namingConventions.PascalCase = Math.round((namingConventions.PascalCase / totalNames) * 100);
207
+ namingConventions.other = Math.round((namingConventions.other / totalNames) * 100);
208
+ return {
209
+ generatedAt: new Date().toISOString(),
210
+ fileCount,
211
+ totalLoc,
212
+ metrics: {
213
+ medianFunctionLength: Math.round(median(allFunctionLengths) * 10) / 10,
214
+ averageFunctionLength: Math.round(average(allFunctionLengths) * 10) / 10,
215
+ maxFunctionLength: allFunctionLengths.length > 0 ? Math.max(...allFunctionLengths) : 0,
216
+ namingConventions,
217
+ commentToCodeRatio: totalCodeLines > 0
218
+ ? Math.round((totalCommentLines / totalCodeLines) * 100) / 100
219
+ : 0,
220
+ averageNestingDepth: Math.round(average(allNestingDepths) * 10) / 10,
221
+ tryCatchDensity: totalLoc > 0
222
+ ? Math.round((totalTryCatch / (totalLoc / 100)) * 100) / 100
223
+ : 0,
224
+ averageImportsPerFile: fileCount > 0
225
+ ? Math.round((totalImports / fileCount) * 10) / 10
226
+ : 0,
227
+ },
228
+ };
229
+ }
230
+ //# sourceMappingURL=analyzer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyzer.js","sourceRoot":"","sources":["../../src/fingerprint/analyzer.ts"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,CAAC,GAAG,GAAG;gBAC5D,CAAC,CAAC,CAAC;YACL,qBAAqB,EAAE,SAAS,GAAG,CAAC;gBAClC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,GAAG,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE;gBAClD,CAAC,CAAC,CAAC;SACN;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type Parser from 'tree-sitter';
2
+ import type { Finding, StyleProfile } from '../types';
3
+ export declare function compareFileToProfile(filePath: string, source: string, tree: Parser.Tree, profile: StyleProfile): Finding[];
4
+ //# sourceMappingURL=comparator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comparator.d.ts","sourceRoot":"","sources":["../../src/fingerprint/comparator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAY,MAAM,UAAU,CAAC;AAiBhE,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,OAAO,EAAE,YAAY,GACpB,OAAO,EAAE,CAoEX"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.compareFileToProfile = compareFileToProfile;
4
+ const parser_1 = require("../parser");
5
+ const FUNCTION_TYPES = new Set([
6
+ 'function_declaration', 'method_definition', 'arrow_function',
7
+ 'function', 'function_definition',
8
+ ]);
9
+ function countLines(text) {
10
+ if (text.length === 0)
11
+ return 0;
12
+ let count = 1;
13
+ for (let i = 0; i < text.length; i++) {
14
+ if (text[i] === '\n')
15
+ count++;
16
+ }
17
+ return count;
18
+ }
19
+ function compareFileToProfile(filePath, source, tree, profile) {
20
+ const findings = [];
21
+ const { metrics } = profile;
22
+ // Check function lengths against profile
23
+ const maxAcceptable = Math.max(metrics.averageFunctionLength * 4, metrics.medianFunctionLength * 5, 30);
24
+ (0, parser_1.walkTree)(tree.rootNode, (node) => {
25
+ if (!FUNCTION_TYPES.has(node.type))
26
+ return;
27
+ const body = node.childForFieldName('body');
28
+ if (!body)
29
+ return;
30
+ const fnLines = countLines(body.text);
31
+ if (fnLines > maxAcceptable) {
32
+ const nameNode = node.childForFieldName('name');
33
+ let parentName;
34
+ if (!nameNode && node.parent?.type === 'variable_declarator') {
35
+ const pn = node.parent.childForFieldName('name');
36
+ if (pn)
37
+ parentName = pn.text;
38
+ }
39
+ const name = nameNode?.text ?? parentName ?? 'anonymous';
40
+ findings.push({
41
+ file: filePath,
42
+ line: node.startPosition.row + 1,
43
+ column: node.startPosition.column + 1,
44
+ endLine: node.endPosition.row + 1,
45
+ endColumn: node.endPosition.column + 1,
46
+ rule: 'style-function-length',
47
+ severity: 'warning',
48
+ message: `Function '${name}' is ${fnLines} lines — project median is ${metrics.medianFunctionLength}, average is ${metrics.averageFunctionLength}`,
49
+ });
50
+ }
51
+ });
52
+ // Check comment density against profile
53
+ let commentLines = 0;
54
+ let codeLines = 0;
55
+ (0, parser_1.walkTree)(tree.rootNode, (node) => {
56
+ if (node.type === 'comment') {
57
+ commentLines += countLines(node.text);
58
+ }
59
+ });
60
+ const totalLines = countLines(source);
61
+ codeLines = Math.max(1, totalLines - commentLines);
62
+ const fileRatio = commentLines / codeLines;
63
+ // Flag if comment density is 3x+ the project average (overly commented, likely AI slop)
64
+ if (metrics.commentToCodeRatio > 0 && fileRatio > metrics.commentToCodeRatio * 3 && commentLines > 5) {
65
+ findings.push({
66
+ file: filePath,
67
+ line: 1,
68
+ column: 1,
69
+ endLine: 1,
70
+ endColumn: 1,
71
+ rule: 'style-comment-density',
72
+ severity: 'info',
73
+ message: `Comment density (${Math.round(fileRatio * 100)}%) is much higher than project average (${Math.round(metrics.commentToCodeRatio * 100)}%)`,
74
+ });
75
+ }
76
+ return findings;
77
+ }
78
+ //# sourceMappingURL=comparator.js.map
@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AAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxC,CAAC;IACH,CAAC,CAAC,CAAC;IACH,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACtC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,UAAU,GAAG,YAAY,CAAC,CAAC;IACnD,MAAM,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC;IAE3C,wFAAwF;IACxF,IAAI,OAAO,CAAC,kBAAkB,GAAG,CAAC,IAAI,SAAS,GAAG,OAAO,CAAC,kBAAkB,GAAG,CAAC,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;QACrG,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC;YACP,MAAM,EAAE,CAAC;YACT,OAAO,EAAE,CAAC;YACV,SAAS,EAAE,CAAC;YACZ,IAAI,EAAE,uBAAuB;YAC7B,QAAQ,EAAE,MAAM;YAChB,OAAO,EAAE,oBAAoB,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,GAAG,CAAC,2CAA2C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,kBAAkB,GAAG,GAAG,CAAC,IAAI;SACpJ,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { StyleProfile } from '../types';
2
+ export declare function getProfilePath(baseDir: string): string;
3
+ export declare function saveProfile(profile: StyleProfile, baseDir: string): string;
4
+ export declare function loadProfile(baseDir: string): StyleProfile | null;
5
+ //# sourceMappingURL=profile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/fingerprint/profile.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAK7C,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAQ1E;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAUhE"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getProfilePath = getProfilePath;
37
+ exports.saveProfile = saveProfile;
38
+ exports.loadProfile = loadProfile;
39
+ const fs = __importStar(require("fs"));
40
+ const path = __importStar(require("path"));
41
+ const PROFILE_DIR = '.distyll';
42
+ const PROFILE_FILE = 'profile.json';
43
+ function getProfilePath(baseDir) {
44
+ return path.join(baseDir, PROFILE_DIR, PROFILE_FILE);
45
+ }
46
+ function saveProfile(profile, baseDir) {
47
+ const dir = path.join(baseDir, PROFILE_DIR);
48
+ if (!fs.existsSync(dir)) {
49
+ fs.mkdirSync(dir, { recursive: true });
50
+ }
51
+ const filePath = getProfilePath(baseDir);
52
+ fs.writeFileSync(filePath, JSON.stringify(profile, null, 2) + '\n', 'utf-8');
53
+ return filePath;
54
+ }
55
+ function loadProfile(baseDir) {
56
+ const filePath = getProfilePath(baseDir);
57
+ try {
58
+ const raw = fs.readFileSync(filePath, 'utf-8');
59
+ const parsed = JSON.parse(raw);
60
+ if (!parsed || !parsed.metrics)
61
+ return null;
62
+ return parsed;
63
+ }
64
+ catch {
65
+ return null;
66
+ }
67
+ }
68
+ //# sourceMappingURL=profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/fingerprint/profile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,wCAEC;AAED,kCAQC;AAED,kCAUC;AA/BD,uCAAyB;AACzB,2CAA6B;AAG7B,MAAM,WAAW,GAAG,UAAU,CAAC;AAC/B,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,SAAgB,cAAc,CAAC,OAAe;IAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;AACvD,CAAC;AAED,SAAgB,WAAW,CAAC,OAAqB,EAAE,OAAe;IAChE,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IAC5C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IACD,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACzC,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7E,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAgB,WAAW,CAAC,OAAe;IACzC,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACzC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC;QAC5C,OAAO,MAAsB,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type Parser from 'tree-sitter';
2
+ import type { Finding } from '../types';
3
+ /**
4
+ * Attempt to generate a fix suggestion for a finding.
5
+ * Returns the finding with the fix attached if successful.
6
+ */
7
+ export declare function attachFix(finding: Finding, tree: Parser.Tree, source: string): Finding;
8
+ /**
9
+ * Attach fix suggestions to all findings for a file.
10
+ */
11
+ export declare function attachFixes(findings: Finding[], tree: Parser.Tree, source: string): Finding[];
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fixes/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAiB,MAAM,UAAU,CAAC;AAqBvD;;;GAGG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAgBT;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,OAAO,EAAE,EACnB,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,EAAE,CAEX"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.attachFix = attachFix;
4
+ exports.attachFixes = attachFixes;
5
+ const unnecessary_try_catch_1 = require("./unnecessary-try-catch");
6
+ const single_use_wrapper_1 = require("./single-use-wrapper");
7
+ const verbose_comments_1 = require("./verbose-comments");
8
+ const unused_imports_1 = require("./unused-imports");
9
+ const fixGenerators = {
10
+ 'unnecessary-try-catch': unnecessary_try_catch_1.fixUnnecessaryTryCatch,
11
+ 'single-use-wrapper': single_use_wrapper_1.fixSingleUseWrapper,
12
+ 'verbose-comments': verbose_comments_1.fixVerboseComment,
13
+ 'unused-imports': (tree, source, line, context) => (0, unused_imports_1.fixUnusedImport)(tree, source, line, context ?? ''),
14
+ };
15
+ /**
16
+ * Attempt to generate a fix suggestion for a finding.
17
+ * Returns the finding with the fix attached if successful.
18
+ */
19
+ function attachFix(finding, tree, source) {
20
+ const generator = fixGenerators[finding.rule];
21
+ if (!generator)
22
+ return finding;
23
+ // Extract context from the finding message for unused-imports
24
+ let context;
25
+ if (finding.rule === 'unused-imports') {
26
+ const match = finding.message.match(/'([^']+)'/);
27
+ if (match)
28
+ context = match[1];
29
+ }
30
+ const fix = generator(tree, source, finding.line, context);
31
+ if (fix) {
32
+ return { ...finding, fix };
33
+ }
34
+ return finding;
35
+ }
36
+ /**
37
+ * Attach fix suggestions to all findings for a file.
38
+ */
39
+ function attachFixes(findings, tree, source) {
40
+ return findings.map((f) => attachFix(f, tree, source));
41
+ }
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fixes/index.ts"],"names":[],"m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,MAAM,CAAC,CAAC,CAAC;AACzD,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type Parser from 'tree-sitter';
2
+ import type { FixSuggestion } from '../types';
3
+ /**
4
+ * Generates a fix for single-use wrapper functions: suggests inlining
5
+ * by showing the delegated call directly.
6
+ */
7
+ export declare function fixSingleUseWrapper(tree: Parser.Tree, source: string, line: number): FixSuggestion | null;
8
+ //# sourceMappingURL=single-use-wrapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single-use-wrapper.d.ts","sourceRoot":"","sources":["../../src/fixes/single-use-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,aAAa,GAAG,IAAI,CA+CtB"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fixSingleUseWrapper = fixSingleUseWrapper;
4
+ const parser_1 = require("../parser");
5
+ /**
6
+ * Generates a fix for single-use wrapper functions: suggests inlining
7
+ * by showing the delegated call directly.
8
+ */
9
+ function fixSingleUseWrapper(tree, source, line) {
10
+ const functionNodes = (0, parser_1.findNodesMulti)(tree.rootNode, [
11
+ 'function_declaration',
12
+ 'arrow_function',
13
+ 'function',
14
+ ]);
15
+ for (const fn of functionNodes) {
16
+ if (fn.startPosition.row + 1 !== line)
17
+ continue;
18
+ const body = fn.childForFieldName('body');
19
+ if (!body)
20
+ return null;
21
+ // For arrow functions with expression body (no braces)
22
+ if (body.type === 'call_expression') {
23
+ return {
24
+ description: `Inline the delegated call: ${body.text}`,
25
+ replacement: body.text,
26
+ };
27
+ }
28
+ // For block body with single return/expression statement
29
+ const stmts = body.type === 'statement_block' ? body.namedChildren : [];
30
+ if (stmts.length !== 1)
31
+ return null;
32
+ const stmt = stmts[0];
33
+ if (stmt.type === 'return_statement') {
34
+ const returnValue = stmt.namedChildren[0];
35
+ if (returnValue) {
36
+ return {
37
+ description: `Inline the delegated call: ${returnValue.text}`,
38
+ replacement: returnValue.text,
39
+ };
40
+ }
41
+ }
42
+ if (stmt.type === 'expression_statement') {
43
+ const expr = stmt.namedChildren[0];
44
+ if (expr) {
45
+ return {
46
+ description: `Inline the delegated call: ${expr.text}`,
47
+ replacement: expr.text,
48
+ };
49
+ }
50
+ }
51
+ }
52
+ return null;
53
+ }
54
+ //# sourceMappingURL=single-use-wrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single-use-wrapper.js","sourceRoot":"","sources":["../../src/fixes/single-use-wrapper.ts"],"names":[],"mappings":";;AAQA,kDAmDC;AA1DD,sCAAqD;AAGrD;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,IAAiB,EACjB,MAAc,EACd,IAAY;IAEZ,MAAM,aAAa,GAAG,IAAA,uBAAc,EAAC,IAAI,CAAC,QAAQ,EAAE;QAClD,sBAAsB;QACtB,gBAAgB;QAChB,UAAU;KACX,CAAC,CAAC;IAEH,KAAK,MAAM,EAAE,IAAI,aAAa,EAAE,CAAC;QAC/B,IAAI,EAAE,CAAC,aAAa,CAAC,GAAG,GAAG,CAAC,KAAK,IAAI;YAAE,SAAS;QAEhD,MAAM,IAAI,GAAG,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QAEvB,uDAAuD;QACvD,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YACpC,OAAO;gBACL,WAAW,EAAE,8BAA8B,IAAI,CAAC,IAAI,EAAE;gBACtD,WAAW,EAAE,IAAI,CAAC,IAAI;aACvB,CAAC;QACJ,CAAC;QAED,yDAAyD;QACzD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,KAAK,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;QACxE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAEpC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,IAAI,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;YACrC,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;YAC1C,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAO;oBACL,WAAW,EAAE,8BAA8B,WAAW,CAAC,IAAI,EAAE;oBAC7D,WAAW,EAAE,WAAW,CAAC,IAAI;iBAC9B,CAAC;YACJ,CAAC;QACH,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,sBAAsB,EAAE,CAAC;YACzC,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;YACnC,IAAI,IAAI,EAAE,CAAC;gBACT,OAAO;oBACL,WAAW,EAAE,8BAA8B,IAAI,CAAC,IAAI,EAAE;oBACtD,WAAW,EAAE,IAAI,CAAC,IAAI;iBACvB,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type Parser from 'tree-sitter';
2
+ import type { FixSuggestion } from '../types';
3
+ /**
4
+ * Generates a fix for unnecessary try-catch: extracts the try body
5
+ * and removes the try-catch wrapper.
6
+ */
7
+ export declare function fixUnnecessaryTryCatch(tree: Parser.Tree, source: string, line: number): FixSuggestion | null;
8
+ //# sourceMappingURL=unnecessary-try-catch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unnecessary-try-catch.d.ts","sourceRoot":"","sources":["../../src/fixes/unnecessary-try-catch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,aAAa,GAAG,IAAI,CA8BtB"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fixUnnecessaryTryCatch = fixUnnecessaryTryCatch;
4
+ const parser_1 = require("../parser");
5
+ /**
6
+ * Generates a fix for unnecessary try-catch: extracts the try body
7
+ * and removes the try-catch wrapper.
8
+ */
9
+ function fixUnnecessaryTryCatch(tree, source, line) {
10
+ const tryStatements = (0, parser_1.findNodes)(tree.rootNode, 'try_statement');
11
+ for (const tryNode of tryStatements) {
12
+ // Match by line (1-indexed)
13
+ if (tryNode.startPosition.row + 1 !== line)
14
+ continue;
15
+ const body = tryNode.childForFieldName('body');
16
+ if (!body)
17
+ return null;
18
+ // Extract the body statements (strip the outer braces)
19
+ const bodyText = body.text;
20
+ // Remove leading { and trailing }
21
+ const inner = bodyText.replace(/^\s*\{/, '').replace(/\}\s*$/, '');
22
+ // Dedent one level
23
+ const lines = inner.split('\n');
24
+ const dedented = lines
25
+ .map((l) => l.replace(/^ /, ''))
26
+ .join('\n')
27
+ .trim();
28
+ if (!dedented)
29
+ return null;
30
+ return {
31
+ description: 'Remove try-catch wrapper and keep the body',
32
+ replacement: dedented,
33
+ };
34
+ }
35
+ return null;
36
+ }
37
+ //# sourceMappingURL=unnecessary-try-catch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unnecessary-try-catch.js","sourceRoot":"","sources":["../../src/fixes/unnecessary-try-catch.ts"],"names":[],"mappings":";;AAQA,wDAkCC;AAzCD,sCAAsC;AAGtC;;;GAGG;AACH,SAAgB,sBAAsB,CACpC,IAAiB,EACjB,MAAc,EACd,IAAY;IAEZ,MAAM,aAAa,GAAG,IAAA,kBAAS,EAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IAEhE,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE,CAAC;QACpC,4BAA4B;QAC5B,IAAI,OAAO,CAAC,aAAa,CAAC,GAAG,GAAG,CAAC,KAAK,IAAI;YAAE,SAAS;QAErD,MAAM,IAAI,GAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC/C,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QAEvB,uDAAuD;QACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;QAC3B,kCAAkC;QAClC,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACnE,mBAAmB;QACnB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChC,MAAM,QAAQ,GAAG,KAAK;aACnB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;aAChC,IAAI,CAAC,IAAI,CAAC;aACV,IAAI,EAAE,CAAC;QAEV,IAAI,CAAC,QAAQ;YAAE,OAAO,IAAI,CAAC;QAE3B,OAAO;YACL,WAAW,EAAE,4CAA4C;YACzD,WAAW,EAAE,QAAQ;SACtB,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type Parser from 'tree-sitter';
2
+ import type { FixSuggestion } from '../types';
3
+ /**
4
+ * Generates a fix for unused imports: suggests removing the import line.
5
+ */
6
+ export declare function fixUnusedImport(tree: Parser.Tree, source: string, line: number, importName: string): FixSuggestion | null;
7
+ //# sourceMappingURL=unused-imports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unused-imports.d.ts","sourceRoot":"","sources":["../../src/fixes/unused-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;GAEG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GACjB,aAAa,GAAG,IAAI,CAwCtB"}