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/index.js CHANGED
@@ -13,14 +13,7 @@ import { execSync } from 'child_process';
13
13
 
14
14
  // src/version.ts
15
15
  var PACKAGE_VERSION = "1.0.0";
16
- var DEFAULT_INCLUDE = [
17
- "**/*.js",
18
- "**/*.jsx",
19
- "**/*.ts",
20
- "**/*.tsx",
21
- "**/*.mjs",
22
- "**/*.cjs"
23
- ];
16
+ var DEFAULT_INCLUDE = ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx", "**/*.mjs", "**/*.cjs"];
24
17
  var DEFAULT_EXCLUDE = [
25
18
  "**/node_modules/**",
26
19
  "**/dist/**",
@@ -36,9 +29,9 @@ var DEFAULT_EXCLUDE = [
36
29
  var DEFAULT_IGNORE_PATTERNS = [];
37
30
  var DEFAULT_CATEGORIES = {
38
31
  "ai-slop": true,
39
- "security": true,
40
- "reliability": true,
41
- "maintainability": true,
32
+ security: true,
33
+ reliability: true,
34
+ maintainability: true,
42
35
  "production-readiness": true
43
36
  };
44
37
  var DEFAULT_MAX_ISSUES = {};
@@ -217,11 +210,7 @@ function parseSource(filePath, source) {
217
210
  }
218
211
  }
219
212
  const message = err instanceof Error ? err.message : "Unknown parse error";
220
- throw new ParseError(
221
- `Failed to parse ${filePath}: ${message}`,
222
- filePath,
223
- err
224
- );
213
+ throw new ParseError(`Failed to parse ${filePath}: ${message}`, filePath, err);
225
214
  }
226
215
  }
227
216
  function extractSnippet(source, line, contextLines = 2) {
@@ -820,11 +809,7 @@ var rule7 = {
820
809
  var dead_code_default = rule7;
821
810
 
822
811
  // src/rules/security/unsafe-eval.ts
823
- var DANGEROUS_EVAL_APIS = /* @__PURE__ */ new Set([
824
- "eval",
825
- "Function",
826
- "execScript"
827
- ]);
812
+ var DANGEROUS_EVAL_APIS = /* @__PURE__ */ new Set(["eval", "Function", "execScript"]);
828
813
  var rule8 = {
829
814
  meta: {
830
815
  id: "security/unsafe-eval",
@@ -1887,11 +1872,7 @@ var DEBUG_METHODS = /* @__PURE__ */ new Set([
1887
1872
  "console.trace",
1888
1873
  "console.table"
1889
1874
  ]);
1890
- var ALLOWED_CONSOLE = /* @__PURE__ */ new Set([
1891
- "console.error",
1892
- "console.warn",
1893
- "console.info"
1894
- ]);
1875
+ var ALLOWED_CONSOLE = /* @__PURE__ */ new Set(["console.error", "console.warn", "console.info"]);
1895
1876
  var rule21 = {
1896
1877
  meta: {
1897
1878
  id: "production-readiness/no-console-log",
@@ -2051,7 +2032,11 @@ var rule22 = {
2051
2032
  }
2052
2033
  }
2053
2034
  function getLocation2(node, filePath) {
2054
- return { file: filePath, line: node.loc?.start.line ?? 1, column: node.loc?.start.column ?? 0 };
2035
+ return {
2036
+ file: filePath,
2037
+ line: node.loc?.start.line ?? 1,
2038
+ column: node.loc?.start.column ?? 0
2039
+ };
2055
2040
  }
2056
2041
  }
2057
2042
  };
@@ -2143,10 +2128,7 @@ function computeScore(issues, config) {
2143
2128
  low: 1,
2144
2129
  info: 0
2145
2130
  };
2146
- const totalDeduction = catIssues.reduce(
2147
- (sum, i) => sum + (deductions[i.severity] ?? 0),
2148
- 0
2149
- );
2131
+ const totalDeduction = catIssues.reduce((sum, i) => sum + (deductions[i.severity] ?? 0), 0);
2150
2132
  const raw = Math.max(0, 100 - totalDeduction);
2151
2133
  return {
2152
2134
  category: cat,
@@ -2187,7 +2169,12 @@ async function scan(options) {
2187
2169
  continue;
2188
2170
  }
2189
2171
  if (source.length > 2e6) {
2190
- fileResults.push({ file: filePath, issues: [], skipped: true, skipReason: "file too large" });
2172
+ fileResults.push({
2173
+ file: filePath,
2174
+ issues: [],
2175
+ skipped: true,
2176
+ skipReason: "file too large"
2177
+ });
2191
2178
  continue;
2192
2179
  }
2193
2180
  parsed = parseSource(filePath, source);
@@ -2252,9 +2239,7 @@ function renderIssue(issue, root, verbose) {
2252
2239
  const lines = [];
2253
2240
  const relPath2 = formatRelativePath(root, issue.location.file);
2254
2241
  const loc = `${relPath2}:${issue.location.line}:${issue.location.column}`;
2255
- lines.push(
2256
- ` ${formatSeverity(issue.severity)} ${BOLD}${issue.message}${RESET}`
2257
- );
2242
+ lines.push(` ${formatSeverity(issue.severity)} ${BOLD}${issue.message}${RESET}`);
2258
2243
  lines.push(` ${DIM}${loc}${RESET} ${GRAY}[${issue.ruleId}]${RESET}`);
2259
2244
  if (verbose) {
2260
2245
  lines.push("");
@@ -2341,7 +2326,9 @@ function generateTextReport(result) {
2341
2326
  if (lowCount > 0) lines.push(` ${DIM}${lowCount} low${RESET}`);
2342
2327
  lines.push("");
2343
2328
  if (score.productionReady) {
2344
- lines.push(` ${GREEN}PRODUCTION READY${RESET} Score above threshold (${config.failThreshold})`);
2329
+ lines.push(
2330
+ ` ${GREEN}PRODUCTION READY${RESET} Score above threshold (${config.failThreshold})`
2331
+ );
2345
2332
  } else {
2346
2333
  lines.push(
2347
2334
  ` ${RED}NOT PRODUCTION READY${RESET} Score ${score.overall} below threshold (${config.failThreshold})`
@@ -2438,9 +2425,7 @@ function generateMarkdownReport(result) {
2438
2425
  lines.push("|----------|-------|--------|");
2439
2426
  for (const cat of score.categories) {
2440
2427
  const emoji = cat.score >= 90 ? "\u2705" : cat.score >= 70 ? "\u26A0\uFE0F" : "\u274C";
2441
- lines.push(
2442
- `| ${cat.category} | ${emoji} ${cat.score}/100 | ${cat.issueCount} |`
2443
- );
2428
+ lines.push(`| ${cat.category} | ${emoji} ${cat.score}/100 | ${cat.issueCount} |`);
2444
2429
  }
2445
2430
  lines.push("");
2446
2431
  lines.push(`**Overall Score:** ${score.overall}/100   **Grade:** ${score.grade}`);
@@ -2887,9 +2872,9 @@ async function runScan(directory, options) {
2887
2872
  failThreshold: options.failThreshold ? parseInt(options.failThreshold, 10) : baseConfig.failThreshold,
2888
2873
  categories: {
2889
2874
  "ai-slop": options.aiSlop === false ? false : baseConfig.categories["ai-slop"] ?? true,
2890
- "security": options.security === false ? false : baseConfig.categories["security"] ?? true,
2891
- "reliability": options.reliability === false ? false : baseConfig.categories["reliability"] ?? true,
2892
- "maintainability": options.maintainability === false ? false : baseConfig.categories["maintainability"] ?? true,
2875
+ security: options.security === false ? false : baseConfig.categories["security"] ?? true,
2876
+ reliability: options.reliability === false ? false : baseConfig.categories["reliability"] ?? true,
2877
+ maintainability: options.maintainability === false ? false : baseConfig.categories["maintainability"] ?? true,
2893
2878
  "production-readiness": options.productionReadiness === false ? false : baseConfig.categories["production-readiness"] ?? true
2894
2879
  }
2895
2880
  };
@@ -2969,9 +2954,7 @@ async function runCheck(directory, options) {
2969
2954
  } else {
2970
2955
  const reasons = [];
2971
2956
  if (!scorePassed) {
2972
- reasons.push(
2973
- `score ${result.score.overall} below threshold ${config.failThreshold}`
2974
- );
2957
+ reasons.push(`score ${result.score.overall} below threshold ${config.failThreshold}`);
2975
2958
  }
2976
2959
  if (criticalExceeded) {
2977
2960
  reasons.push(
@@ -2992,10 +2975,8 @@ async function runWatch(directory, options) {
2992
2975
  const cwd = directory ? path3.resolve(directory) : process.cwd();
2993
2976
  const config = await loadConfig(cwd, options.config);
2994
2977
  if (options.verbose) config.verbose = true;
2995
- console.log(
2996
- `
2997
- ${BOLD}clean-slop watch${RESET} ${DIM}Watching ${cwd}${RESET}`
2998
- );
2978
+ console.log(`
2979
+ ${BOLD}clean-slop watch${RESET} ${DIM}Watching ${cwd}${RESET}`);
2999
2980
  console.log(`${DIM}Press Ctrl+C to stop.${RESET}
3000
2981
  `);
3001
2982
  let debounceTimer = null;
@@ -3030,19 +3011,16 @@ ${BOLD}clean-slop watch${RESET} ${DIM}Watching ${cwd}${RESET}`
3030
3011
  running = false;
3031
3012
  }
3032
3013
  await runScanCycle();
3033
- const watcher = fs3.watch(
3034
- cwd,
3035
- { recursive: true },
3036
- (event, filename) => {
3037
- if (!filename) return;
3038
- if (!/\.(js|jsx|ts|tsx|mjs|cjs)$/.test(filename)) return;
3039
- if (filename.includes("node_modules") || filename.includes("dist") || filename.includes(".next")) return;
3040
- if (debounceTimer) clearTimeout(debounceTimer);
3041
- debounceTimer = setTimeout(() => {
3042
- void runScanCycle(path3.join(cwd, filename));
3043
- }, DEBOUNCE_MS);
3044
- }
3045
- );
3014
+ const watcher = fs3.watch(cwd, { recursive: true }, (event, filename) => {
3015
+ if (!filename) return;
3016
+ if (!/\.(js|jsx|ts|tsx|mjs|cjs)$/.test(filename)) return;
3017
+ if (filename.includes("node_modules") || filename.includes("dist") || filename.includes(".next"))
3018
+ return;
3019
+ if (debounceTimer) clearTimeout(debounceTimer);
3020
+ debounceTimer = setTimeout(() => {
3021
+ void runScanCycle(path3.join(cwd, filename));
3022
+ }, DEBOUNCE_MS);
3023
+ });
3046
3024
  process.on("SIGINT", () => {
3047
3025
  watcher.close();
3048
3026
  console.log(`