clean-slop 2.0.0 → 2.0.2
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/dist/cli/bin.js +40 -62
- package/dist/cli/bin.js.map +1 -1
- package/dist/cli/index.js +40 -62
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +24 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +24 -39
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -12,14 +12,7 @@ import { parse } from '@typescript-eslint/typescript-estree';
|
|
|
12
12
|
var PACKAGE_VERSION = "1.0.0";
|
|
13
13
|
|
|
14
14
|
// src/config/loader.ts
|
|
15
|
-
var DEFAULT_INCLUDE = [
|
|
16
|
-
"**/*.js",
|
|
17
|
-
"**/*.jsx",
|
|
18
|
-
"**/*.ts",
|
|
19
|
-
"**/*.tsx",
|
|
20
|
-
"**/*.mjs",
|
|
21
|
-
"**/*.cjs"
|
|
22
|
-
];
|
|
15
|
+
var DEFAULT_INCLUDE = ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx", "**/*.mjs", "**/*.cjs"];
|
|
23
16
|
var DEFAULT_EXCLUDE = [
|
|
24
17
|
"**/node_modules/**",
|
|
25
18
|
"**/dist/**",
|
|
@@ -35,9 +28,9 @@ var DEFAULT_EXCLUDE = [
|
|
|
35
28
|
var DEFAULT_IGNORE_PATTERNS = [];
|
|
36
29
|
var DEFAULT_CATEGORIES = {
|
|
37
30
|
"ai-slop": true,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
security: true,
|
|
32
|
+
reliability: true,
|
|
33
|
+
maintainability: true,
|
|
41
34
|
"production-readiness": true
|
|
42
35
|
};
|
|
43
36
|
var DEFAULT_MAX_ISSUES = {};
|
|
@@ -220,11 +213,7 @@ function parseSource(filePath, source) {
|
|
|
220
213
|
}
|
|
221
214
|
}
|
|
222
215
|
const message = err instanceof Error ? err.message : "Unknown parse error";
|
|
223
|
-
throw new ParseError(
|
|
224
|
-
`Failed to parse ${filePath}: ${message}`,
|
|
225
|
-
filePath,
|
|
226
|
-
err
|
|
227
|
-
);
|
|
216
|
+
throw new ParseError(`Failed to parse ${filePath}: ${message}`, filePath, err);
|
|
228
217
|
}
|
|
229
218
|
}
|
|
230
219
|
function extractSnippet(source, line, contextLines = 2) {
|
|
@@ -823,11 +812,7 @@ var rule7 = {
|
|
|
823
812
|
var dead_code_default = rule7;
|
|
824
813
|
|
|
825
814
|
// src/rules/security/unsafe-eval.ts
|
|
826
|
-
var DANGEROUS_EVAL_APIS = /* @__PURE__ */ new Set([
|
|
827
|
-
"eval",
|
|
828
|
-
"Function",
|
|
829
|
-
"execScript"
|
|
830
|
-
]);
|
|
815
|
+
var DANGEROUS_EVAL_APIS = /* @__PURE__ */ new Set(["eval", "Function", "execScript"]);
|
|
831
816
|
var rule8 = {
|
|
832
817
|
meta: {
|
|
833
818
|
id: "security/unsafe-eval",
|
|
@@ -1890,11 +1875,7 @@ var DEBUG_METHODS = /* @__PURE__ */ new Set([
|
|
|
1890
1875
|
"console.trace",
|
|
1891
1876
|
"console.table"
|
|
1892
1877
|
]);
|
|
1893
|
-
var ALLOWED_CONSOLE = /* @__PURE__ */ new Set([
|
|
1894
|
-
"console.error",
|
|
1895
|
-
"console.warn",
|
|
1896
|
-
"console.info"
|
|
1897
|
-
]);
|
|
1878
|
+
var ALLOWED_CONSOLE = /* @__PURE__ */ new Set(["console.error", "console.warn", "console.info"]);
|
|
1898
1879
|
var rule21 = {
|
|
1899
1880
|
meta: {
|
|
1900
1881
|
id: "production-readiness/no-console-log",
|
|
@@ -2054,7 +2035,11 @@ var rule22 = {
|
|
|
2054
2035
|
}
|
|
2055
2036
|
}
|
|
2056
2037
|
function getLocation2(node, filePath) {
|
|
2057
|
-
return {
|
|
2038
|
+
return {
|
|
2039
|
+
file: filePath,
|
|
2040
|
+
line: node.loc?.start.line ?? 1,
|
|
2041
|
+
column: node.loc?.start.column ?? 0
|
|
2042
|
+
};
|
|
2058
2043
|
}
|
|
2059
2044
|
}
|
|
2060
2045
|
};
|
|
@@ -2146,10 +2131,7 @@ function computeScore(issues, config) {
|
|
|
2146
2131
|
low: 1,
|
|
2147
2132
|
info: 0
|
|
2148
2133
|
};
|
|
2149
|
-
const totalDeduction = catIssues.reduce(
|
|
2150
|
-
(sum, i) => sum + (deductions[i.severity] ?? 0),
|
|
2151
|
-
0
|
|
2152
|
-
);
|
|
2134
|
+
const totalDeduction = catIssues.reduce((sum, i) => sum + (deductions[i.severity] ?? 0), 0);
|
|
2153
2135
|
const raw = Math.max(0, 100 - totalDeduction);
|
|
2154
2136
|
return {
|
|
2155
2137
|
category: cat,
|
|
@@ -2190,7 +2172,12 @@ async function scan(options) {
|
|
|
2190
2172
|
continue;
|
|
2191
2173
|
}
|
|
2192
2174
|
if (source.length > 2e6) {
|
|
2193
|
-
fileResults.push({
|
|
2175
|
+
fileResults.push({
|
|
2176
|
+
file: filePath,
|
|
2177
|
+
issues: [],
|
|
2178
|
+
skipped: true,
|
|
2179
|
+
skipReason: "file too large"
|
|
2180
|
+
});
|
|
2194
2181
|
continue;
|
|
2195
2182
|
}
|
|
2196
2183
|
parsed = parseSource(filePath, source);
|
|
@@ -2255,9 +2242,7 @@ function renderIssue(issue, root, verbose) {
|
|
|
2255
2242
|
const lines = [];
|
|
2256
2243
|
const relPath2 = formatRelativePath(root, issue.location.file);
|
|
2257
2244
|
const loc = `${relPath2}:${issue.location.line}:${issue.location.column}`;
|
|
2258
|
-
lines.push(
|
|
2259
|
-
` ${formatSeverity(issue.severity)} ${BOLD}${issue.message}${RESET}`
|
|
2260
|
-
);
|
|
2245
|
+
lines.push(` ${formatSeverity(issue.severity)} ${BOLD}${issue.message}${RESET}`);
|
|
2261
2246
|
lines.push(` ${DIM}${loc}${RESET} ${GRAY}[${issue.ruleId}]${RESET}`);
|
|
2262
2247
|
if (verbose) {
|
|
2263
2248
|
lines.push("");
|
|
@@ -2344,7 +2329,9 @@ function generateTextReport(result) {
|
|
|
2344
2329
|
if (lowCount > 0) lines.push(` ${DIM}${lowCount} low${RESET}`);
|
|
2345
2330
|
lines.push("");
|
|
2346
2331
|
if (score.productionReady) {
|
|
2347
|
-
lines.push(
|
|
2332
|
+
lines.push(
|
|
2333
|
+
` ${GREEN}PRODUCTION READY${RESET} Score above threshold (${config.failThreshold})`
|
|
2334
|
+
);
|
|
2348
2335
|
} else {
|
|
2349
2336
|
lines.push(
|
|
2350
2337
|
` ${RED}NOT PRODUCTION READY${RESET} Score ${score.overall} below threshold (${config.failThreshold})`
|
|
@@ -2441,9 +2428,7 @@ function generateMarkdownReport(result) {
|
|
|
2441
2428
|
lines.push("|----------|-------|--------|");
|
|
2442
2429
|
for (const cat of score.categories) {
|
|
2443
2430
|
const emoji = cat.score >= 90 ? "\u2705" : cat.score >= 70 ? "\u26A0\uFE0F" : "\u274C";
|
|
2444
|
-
lines.push(
|
|
2445
|
-
`| ${cat.category} | ${emoji} ${cat.score}/100 | ${cat.issueCount} |`
|
|
2446
|
-
);
|
|
2431
|
+
lines.push(`| ${cat.category} | ${emoji} ${cat.score}/100 | ${cat.issueCount} |`);
|
|
2447
2432
|
}
|
|
2448
2433
|
lines.push("");
|
|
2449
2434
|
lines.push(`**Overall Score:** ${score.overall}/100 **Grade:** ${score.grade}`);
|