@antelopejs/tooling-configs 0.5.1 → 0.5.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/oxc/lint.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { i as findGitRoot } from "../ceilings-B7KayYIG.mjs";
2
2
  import { t as readCarriedCeilings } from "../renames-L2owF5GD.mjs";
3
- import { t as PRESET_CONFIGS } from "../templates-lJBZFskp.mjs";
3
+ import { t as PRESET_CONFIGS } from "../templates-BiXgdsRN.mjs";
4
4
  import { t as TYPE_AWARE_RULES } from "../type-aware-rules-DMuN6sHb.mjs";
5
5
  import { n as TEST_FILE_GLOBS, t as ASSERTION_FUNCTION_NAMES } from "../shared-WC0z3y9F.mjs";
6
6
  import { n as IGNORE_PATTERNS, r as SYNCED_AGENT_PATTERNS } from "../shared-igPpEDpS.mjs";
@@ -20,8 +20,13 @@ function ruleId(code) {
20
20
  const [, plugin, rule] = match;
21
21
  return `${plugin === "typescript-eslint" ? "typescript" : plugin}/${rule}`;
22
22
  }
23
+ const NO_FILES = "No files found to lint.";
24
+ /** Whether oxlint matched no file, in which case it prints a notice before its report and exits 1. */
25
+ function foundNoFiles(stdout) {
26
+ return stdout.startsWith(NO_FILES) && stdout.includes("{");
27
+ }
23
28
  function parseReport(text) {
24
- const report = JSON.parse(text);
29
+ const report = JSON.parse(foundNoFiles(text) ? text.slice(text.indexOf("{")) : text);
25
30
  if (!Array.isArray(report?.diagnostics)) throw new Error("oxlint did not return a JSON diagnostics array.");
26
31
  return report.diagnostics;
27
32
  }
@@ -65,7 +70,7 @@ function runOxlint(root, config, files, flags) {
65
70
  if (result.error) throw result.error;
66
71
  if (result.status !== 0 && result.status !== 1) throw new Error(`oxlint failed (${result.status ?? result.signal}): ${result.stderr || result.stdout}`);
67
72
  const diagnostics = parseReport(result.stdout);
68
- if (result.status !== 0 && diagnostics.length === 0) throw new Error(`oxlint failed without diagnostics: ${result.stderr || result.stdout}`);
73
+ if (result.status !== 0 && diagnostics.length === 0 && !foundNoFiles(result.stdout)) throw new Error(`oxlint failed without diagnostics: ${result.stderr || result.stdout}`);
69
74
  return diagnostics;
70
75
  } finally {
71
76
  if (temporary) rmSync(temporary, {
@@ -40,12 +40,16 @@ function toolingVersions() {
40
40
  const lefthook = manifest.devDependencies?.lefthook;
41
41
  const knip = manifest.devDependencies?.knip;
42
42
  const tsgolint = manifest.devDependencies?.["oxlint-tsgolint"];
43
- if (!lefthook || !knip || !tsgolint || !manifest.version) throw new Error("tooling-configs must declare its version and lefthook, knip and oxlint-tsgolint devDependencies.");
43
+ const oxlint = manifest.devDependencies?.oxlint;
44
+ const oxfmt = manifest.devDependencies?.oxfmt;
45
+ if (!lefthook || !knip || !tsgolint || !oxlint || !oxfmt || !manifest.version) throw new Error("tooling-configs must declare its version and lefthook, knip, oxlint, oxfmt and oxlint-tsgolint devDependencies.");
44
46
  const tested = manifest.devDependencies ?? {};
45
47
  return {
46
48
  lefthook,
47
49
  knip,
48
50
  tsgolint,
51
+ oxlint,
52
+ oxfmt,
49
53
  capture: CAPTURE_PEERS.map((name) => {
50
54
  const range = tested[name];
51
55
  if (!range) throw new Error(`tooling-configs must declare ${name} as a devDependency.`);
@@ -155,6 +159,28 @@ function addedDevDependencies(manifest, versions, options) {
155
159
  if (options.typeAware) tools.push(["oxlint-tsgolint", versions.tsgolint]);
156
160
  return [...tools.filter(([name]) => !declared[name]), ...options.captures ? versions.capture.filter(([name, tested]) => !withinTested(declared[name], tested)) : []];
157
161
  }
162
+ /** The pack, oxlint, oxlint-tsgolint and oxfmt with the ranges `--init` declares for a repository that has none of them. Sync needs the first three installed to load its preset and run the type-aware baseline before it writes any devDependency. */
163
+ function bootstrapDependencies(manifest, versions) {
164
+ const declared = {
165
+ ...manifest.dependencies,
166
+ ...manifest.devDependencies
167
+ };
168
+ return [
169
+ ["@antelopejs/tooling-configs", `^${versions.pack}`],
170
+ ["oxlint", versions.oxlint],
171
+ ["oxlint-tsgolint", versions.tsgolint],
172
+ ["oxfmt", versions.oxfmt]
173
+ ].filter(([name]) => !declared[name]);
174
+ }
175
+ /** `current` with `added` in its sorted devDependencies, formatted as the rest of the sync writers do. */
176
+ function withDevDependencies(current, added) {
177
+ const manifest = parseManifest(current);
178
+ manifest.devDependencies = sortedEntries({
179
+ ...manifest.devDependencies,
180
+ ...Object.fromEntries(added)
181
+ });
182
+ return serializeManifest(manifest, current);
183
+ }
158
184
  function managedPackage(current, versions, options = {}) {
159
185
  if (current === void 0) throw new Error("package.json is missing.");
160
186
  const manifest = parseManifest(current);
@@ -224,4 +250,4 @@ function serializeManifest(manifest, current) {
224
250
  return `${JSON.stringify(manifest, null, indent).replaceAll("\n", newline)}${newline}`;
225
251
  }
226
252
  //#endregion
227
- export { parseManifest as a, toolingVersions as c, packageManager as i, execCommand as n, repositoryTools as o, managedPackage as r, templatePackage as s, addedDevDependencies as t };
253
+ export { packageManager as a, templatePackage as c, managedPackage as i, toolingVersions as l, bootstrapDependencies as n, parseManifest as o, execCommand as r, repositoryTools as s, addedDevDependencies as t, withDevDependencies as u };
@@ -1,4 +1,4 @@
1
- import { a as parseManifest } from "./package-Dn7VTFUW.mjs";
1
+ import { o as parseManifest } from "./package-DxxcxOzp.mjs";
2
2
  import { l as resolveRevision, u as trackedManifests } from "./files-DJ0TeaTU.mjs";
3
3
  import { o as revisionSuppressions, r as countSuppressions } from "./suppressions-BroaaGJ_.mjs";
4
4
  import { copyFileSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, symlinkSync } from "node:fs";
@@ -1,8 +1,8 @@
1
1
  import { a as formatCeilings, c as parseCeilings, n as MAX_FILE_BYTES, o as isPackRelease, s as isRetired, t as CEILINGS_FILE } from "./ceilings-B7KayYIG.mjs";
2
2
  import { n as renamedPaths, t as readCarriedCeilings } from "./renames-L2owF5GD.mjs";
3
- import { c as toolingVersions } from "./package-Dn7VTFUW.mjs";
3
+ import { l as toolingVersions } from "./package-DxxcxOzp.mjs";
4
4
  import { n as authoredSizes, o as isAgentFile, r as changedFiles, t as LINT_CONFIG } from "./files-DJ0TeaTU.mjs";
5
- import { t as lintDiagnostics } from "./oxlint-DIV-lLSS.mjs";
5
+ import { t as lintDiagnostics } from "./oxlint-BbpTFFmf.mjs";
6
6
  import "./suppression-budget-Dvb_IqBo.mjs";
7
7
  import { n as sizeFailure } from "./size-DBatLT-F.mjs";
8
8
  import { copyFileSync, existsSync, mkdirSync, mkdtempSync, rmSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";