aislop 0.3.0 → 0.3.1

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.js CHANGED
@@ -1937,12 +1937,14 @@ const parseBiomeJsonOutput = (output, rootDir) => {
1937
1937
  const rawPath = entry.location?.path;
1938
1938
  if (!rawPath) continue;
1939
1939
  const severity = entry.severity === "error" ? "error" : "warning";
1940
+ const rawMessage = entry.message ?? "";
1941
+ const message = !rawMessage || rawMessage.toLowerCase().includes("would have printed") ? "File is not formatted correctly" : rawMessage;
1940
1942
  diagnostics.push({
1941
1943
  filePath: path.isAbsolute(rawPath) ? path.relative(rootDir, rawPath) : rawPath,
1942
1944
  engine: "format",
1943
1945
  rule: "formatting",
1944
1946
  severity,
1945
- message: entry.message ?? "File is not formatted correctly",
1947
+ message,
1946
1948
  help: "Run `aislop fix` to auto-format",
1947
1949
  line: entry.location?.start?.line ?? 0,
1948
1950
  column: entry.location?.start?.column ?? 0,
@@ -2435,6 +2437,10 @@ const resolveOxlintBinary = () => {
2435
2437
  }
2436
2438
  };
2437
2439
  const parseRuleCode = (code) => {
2440
+ if (!code) return {
2441
+ plugin: "unknown",
2442
+ rule: "unknown"
2443
+ };
2438
2444
  const match = code.match(/^(.+)\((.+)\)$/);
2439
2445
  if (!match) return {
2440
2446
  plugin: "unknown",
@@ -2494,33 +2500,32 @@ const collectUnusedVarCandidates = (diagnostics) => diagnostics.filter((d) => d.
2494
2500
  const prefixIdentifierOnLine = (line, name, column, type) => {
2495
2501
  const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2496
2502
  if (type === "parameter") {
2503
+ const destructureMatch = line.match(/\{[^}]*\}/);
2504
+ if (destructureMatch) {
2505
+ const { 0: content, index: start } = destructureMatch;
2506
+ const propPattern = new RegExp(`(?<!:\\s*)\\b${escaped}\\b(?!\\s*:)`);
2507
+ if (propPattern.test(content)) {
2508
+ const updated = content.replace(propPattern, `${name}: _${name}`);
2509
+ if (updated !== content) return line.slice(0, start) + updated + line.slice(start + content.length);
2510
+ }
2511
+ }
2497
2512
  const paramPattern = new RegExp(`\\b${escaped}\\b`);
2498
- if (paramPattern.test(line)) return line.replace(paramPattern, `_${name}`);
2499
- return line;
2513
+ return paramPattern.test(line) ? line.replace(paramPattern, `_${name}`) : line;
2500
2514
  }
2501
2515
  const assignPattern = new RegExp(`(\\s*)(const|let|var)\\s+${escaped}\\s*=\\s*(.+)$`);
2502
2516
  const assignMatch = line.match(assignPattern);
2503
2517
  if (assignMatch) {
2504
- const indent = assignMatch[1];
2505
- const expression = assignMatch[3];
2518
+ const [, indent, , expression] = assignMatch;
2506
2519
  if (/await\s/.test(expression) || /\w+\s*\(/.test(expression)) return `${indent}${expression}`;
2507
2520
  return "";
2508
2521
  }
2509
2522
  const destructureMatch = line.match(/\{[^}]*\}/);
2510
2523
  if (destructureMatch) {
2511
- const destructureContent = destructureMatch[0];
2512
- const destructureStart = destructureMatch.index;
2513
- if (new RegExp(`\\b${escaped}\\b`).test(destructureContent)) {
2514
- let updated = destructureContent;
2515
- const propPattern = new RegExp(`\\b${escaped}\\b\\s*,?`);
2516
- updated = updated.replace(propPattern, (match) => {
2517
- if (match.endsWith(",")) return "";
2518
- return "";
2519
- });
2520
- updated = updated.replace(/,\s*\},/, "}");
2521
- updated = updated.replace(/\{,\s*/, "{");
2522
- updated = updated.replace(/\s*,\s*\}/, "}");
2523
- if (updated !== destructureContent) return line.slice(0, destructureStart) + updated + line.slice(destructureStart + destructureContent.length);
2524
+ const { 0: content, index: start } = destructureMatch;
2525
+ if (new RegExp(`\\b${escaped}\\b`).test(content)) {
2526
+ let updated = content.replace(new RegExp(`\\b${escaped}\\b\\s*,?`), "");
2527
+ updated = updated.replace(/,\s*\},/, "}").replace(/\{,\s*/, "{").replace(/\s*,\s*\}/, "}");
2528
+ if (updated !== content) return line.slice(0, start) + updated + line.slice(start + content.length);
2524
2529
  }
2525
2530
  }
2526
2531
  let bestStart = -1;
@@ -3371,7 +3376,7 @@ const logger = {
3371
3376
  * Application version — injected at build time by tsdown from package.json.
3372
3377
  * The fallback should always match the "version" field in package.json.
3373
3378
  */
3374
- const APP_VERSION = "0.3.0";
3379
+ const APP_VERSION = "0.3.1";
3375
3380
 
3376
3381
  //#endregion
3377
3382
  //#region src/output/layout.ts
@@ -3,7 +3,7 @@
3
3
  * Application version — injected at build time by tsdown from package.json.
4
4
  * The fallback should always match the "version" field in package.json.
5
5
  */
6
- const APP_VERSION = "0.3.0";
6
+ const APP_VERSION = "0.3.1";
7
7
 
8
8
  //#endregion
9
9
  //#region src/output/engine-info.ts
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { i as runSubprocess, n as runExpoDoctor, r as isToolInstalled } from "./expo-doctor-Cm5892Y8.js";
2
- import { n as getEngineLabel, r as APP_VERSION, t as ENGINE_INFO } from "./engine-info-CXT2Q_Jy.js";
2
+ import { n as getEngineLabel, r as APP_VERSION, t as ENGINE_INFO } from "./engine-info-D19chfzD.js";
3
3
  import { createRequire } from "node:module";
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
@@ -1587,12 +1587,14 @@ const parseBiomeJsonOutput = (output, rootDir) => {
1587
1587
  const rawPath = entry.location?.path;
1588
1588
  if (!rawPath) continue;
1589
1589
  const severity = entry.severity === "error" ? "error" : "warning";
1590
+ const rawMessage = entry.message ?? "";
1591
+ const message = !rawMessage || rawMessage.toLowerCase().includes("would have printed") ? "File is not formatted correctly" : rawMessage;
1590
1592
  diagnostics.push({
1591
1593
  filePath: path.isAbsolute(rawPath) ? path.relative(rootDir, rawPath) : rawPath,
1592
1594
  engine: "format",
1593
1595
  rule: "formatting",
1594
1596
  severity,
1595
- message: entry.message ?? "File is not formatted correctly",
1597
+ message,
1596
1598
  help: "Run `aislop fix` to auto-format",
1597
1599
  line: entry.location?.start?.line ?? 0,
1598
1600
  column: entry.location?.start?.column ?? 0,
@@ -1781,6 +1783,10 @@ const resolveOxlintBinary = () => {
1781
1783
  }
1782
1784
  };
1783
1785
  const parseRuleCode = (code) => {
1786
+ if (!code) return {
1787
+ plugin: "unknown",
1788
+ rule: "unknown"
1789
+ };
1784
1790
  const match = code.match(/^(.+)\((.+)\)$/);
1785
1791
  if (!match) return {
1786
1792
  plugin: "unknown",
@@ -1840,33 +1846,32 @@ const collectUnusedVarCandidates = (diagnostics) => diagnostics.filter((d) => d.
1840
1846
  const prefixIdentifierOnLine = (line, name, column, type) => {
1841
1847
  const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1842
1848
  if (type === "parameter") {
1849
+ const destructureMatch = line.match(/\{[^}]*\}/);
1850
+ if (destructureMatch) {
1851
+ const { 0: content, index: start } = destructureMatch;
1852
+ const propPattern = new RegExp(`(?<!:\\s*)\\b${escaped}\\b(?!\\s*:)`);
1853
+ if (propPattern.test(content)) {
1854
+ const updated = content.replace(propPattern, `${name}: _${name}`);
1855
+ if (updated !== content) return line.slice(0, start) + updated + line.slice(start + content.length);
1856
+ }
1857
+ }
1843
1858
  const paramPattern = new RegExp(`\\b${escaped}\\b`);
1844
- if (paramPattern.test(line)) return line.replace(paramPattern, `_${name}`);
1845
- return line;
1859
+ return paramPattern.test(line) ? line.replace(paramPattern, `_${name}`) : line;
1846
1860
  }
1847
1861
  const assignPattern = new RegExp(`(\\s*)(const|let|var)\\s+${escaped}\\s*=\\s*(.+)$`);
1848
1862
  const assignMatch = line.match(assignPattern);
1849
1863
  if (assignMatch) {
1850
- const indent = assignMatch[1];
1851
- const expression = assignMatch[3];
1864
+ const [, indent, , expression] = assignMatch;
1852
1865
  if (/await\s/.test(expression) || /\w+\s*\(/.test(expression)) return `${indent}${expression}`;
1853
1866
  return "";
1854
1867
  }
1855
1868
  const destructureMatch = line.match(/\{[^}]*\}/);
1856
1869
  if (destructureMatch) {
1857
- const destructureContent = destructureMatch[0];
1858
- const destructureStart = destructureMatch.index;
1859
- if (new RegExp(`\\b${escaped}\\b`).test(destructureContent)) {
1860
- let updated = destructureContent;
1861
- const propPattern = new RegExp(`\\b${escaped}\\b\\s*,?`);
1862
- updated = updated.replace(propPattern, (match) => {
1863
- if (match.endsWith(",")) return "";
1864
- return "";
1865
- });
1866
- updated = updated.replace(/,\s*\},/, "}");
1867
- updated = updated.replace(/\{,\s*/, "{");
1868
- updated = updated.replace(/\s*,\s*\}/, "}");
1869
- if (updated !== destructureContent) return line.slice(0, destructureStart) + updated + line.slice(destructureStart + destructureContent.length);
1870
+ const { 0: content, index: start } = destructureMatch;
1871
+ if (new RegExp(`\\b${escaped}\\b`).test(content)) {
1872
+ let updated = content.replace(new RegExp(`\\b${escaped}\\b\\s*,?`), "");
1873
+ updated = updated.replace(/,\s*\},/, "}").replace(/\{,\s*/, "{").replace(/\s*,\s*\}/, "}");
1874
+ if (updated !== content) return line.slice(0, start) + updated + line.slice(start + content.length);
1870
1875
  }
1871
1876
  }
1872
1877
  let bestStart = -1;
@@ -4536,7 +4541,7 @@ const scanCommand = async (directory, config, options) => {
4536
4541
  });
4537
4542
  }
4538
4543
  if (options.json) {
4539
- const { buildJsonOutput } = await import("./json-C52xnH_4.js");
4544
+ const { buildJsonOutput } = await import("./json-DD60WkDS.js");
4540
4545
  const jsonOut = buildJsonOutput(results, scoreResult, projectInfo.sourceFileCount, elapsedMs);
4541
4546
  console.log(JSON.stringify(jsonOut, null, 2));
4542
4547
  return { exitCode };
@@ -1,4 +1,4 @@
1
- import { r as APP_VERSION, t as ENGINE_INFO } from "./engine-info-CXT2Q_Jy.js";
1
+ import { r as APP_VERSION, t as ENGINE_INFO } from "./engine-info-D19chfzD.js";
2
2
 
3
3
  //#region src/output/json.ts
4
4
  const buildJsonOutput = (results, scoreResult, fileCount, elapsedMs) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aislop",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Stop AI slop from shipping. A unified code quality CLI that catches the lazy patterns AI coding tools leave behind.",
5
5
  "type": "module",
6
6
  "bin": {