@geonosis/lint-parity 0.5.0 → 1.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.
@@ -1,4 +1,27 @@
1
1
  #!/usr/bin/env node
2
2
  // Committed, so `pnpm install` can link the bin on a fresh clone — before `pnpm build` has
3
3
  // produced dist/. A bin that only exists after a build is a bin that is missing when you need it.
4
- import '../dist/parity-cli.js'
4
+ //
5
+ // In the repo, `src/` sits beside `dist/`, and a dist older than src answered for a fix it did not
6
+ // carry once (#62). The published package ships no src, so there the check is skipped.
7
+ import { existsSync, readdirSync, statSync } from 'node:fs'
8
+ import { dirname, join } from 'node:path'
9
+ import { fileURLToPath } from 'node:url'
10
+
11
+ const here = dirname(fileURLToPath(import.meta.url))
12
+ const newest = (dir) =>
13
+ existsSync(dir)
14
+ ? readdirSync(dir, { withFileTypes: true }).reduce((most, entry) => {
15
+ const at = join(dir, entry.name)
16
+ return Math.max(most, entry.isDirectory() ? newest(at) : statSync(at).mtimeMs)
17
+ }, 0)
18
+ : 0
19
+ const src = join(here, '..', 'src')
20
+ if (existsSync(src) && newest(src) > newest(join(here, '..', 'dist'))) {
21
+ process.stderr.write(
22
+ 'geonosis-lint-parity: dist is older than src — run pnpm build before trusting this bin.\n',
23
+ )
24
+ process.exit(2)
25
+ }
26
+
27
+ await import('../dist/parity-cli.js')
@@ -1,13 +1,31 @@
1
1
  // src/parity.ts
2
2
  import { spawnSync } from "child_process";
3
- import { cpSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "fs";
3
+ import {
4
+ cpSync,
5
+ existsSync,
6
+ mkdirSync,
7
+ mkdtempSync,
8
+ readFileSync,
9
+ rmSync,
10
+ writeFileSync
11
+ } from "fs";
4
12
  import { tmpdir } from "os";
5
- import { join } from "path";
13
+ import { dirname, join, resolve } from "path";
6
14
  var ANSI = /\[[0-9;]*m/g;
7
15
  var SUMMARY_COUNT = /^(\d+) problems?$/m;
8
16
  var RULE_IN_LINE = /\[(?:Error|Warning)\/([^\]]+)\]$/;
9
17
  var UNIX_FINDING = /^\S[^\n]*:\d+:\d+: .*\[(?:Error|Warning)\/[^\]\n]+\]$/;
10
18
  var FINDING_PLACE = /^(\S[^\n]*?:\d+:\d+): .*\[(?:Error|Warning)\/([^\]\n]+)\]$/;
19
+ var resolveOxlint = (from) => {
20
+ let dir = from;
21
+ for (; ; ) {
22
+ const bin = resolve(dir, "node_modules/.bin/oxlint");
23
+ if (existsSync(bin)) return bin;
24
+ const parent = dirname(dir);
25
+ if (parent === dir) return "oxlint";
26
+ dir = parent;
27
+ }
28
+ };
11
29
  var ParityError = class extends Error {
12
30
  constructor(message) {
13
31
  super(message);
@@ -397,6 +415,7 @@ var parityOf = ({
397
415
  };
398
416
 
399
417
  export {
418
+ resolveOxlint,
400
419
  ParityError,
401
420
  normaliseFindings,
402
421
  readRun,
package/dist/index.d.ts CHANGED
@@ -1,3 +1,10 @@
1
+ /**
2
+ * The consumer's own oxlint, walking up from a directory, not one `npx` might fetch: a run under a
3
+ * different binary from the one the repo gates with compares two things nobody ships. Exported
4
+ * because every tool that spawns oxlint has to answer this, and a second copy of the answer is a
5
+ * second answer.
6
+ */
7
+ declare const resolveOxlint: (from: string) => string;
1
8
  /** A run that could not be read. Never a number — 0 findings against 0 findings is a PASS. */
2
9
  declare class ParityError extends Error {
3
10
  constructor(message: string);
@@ -168,4 +175,4 @@ declare const parityOf: ({ configA, configB, cwd, out, oxlint, paths, }: {
168
175
  paths: string[];
169
176
  }) => Parity;
170
177
 
171
- export { type CorpusClaim, type CorpusManifest, type CorpusReport, MANIFEST_FILE, type MessageChange, type Parity, type ParityArgs, ParityError, type RuleReach, type RuleTally, compareFindings, corpusOf, formatCorpus, formatSummary, manifestOf, normaliseFindings, parityOf, parseParityArgs, readManifest, readRun, ruleIdOf, rulesNamedBy };
178
+ export { type CorpusClaim, type CorpusManifest, type CorpusReport, MANIFEST_FILE, type MessageChange, type Parity, type ParityArgs, ParityError, type RuleReach, type RuleTally, compareFindings, corpusOf, formatCorpus, formatSummary, manifestOf, normaliseFindings, parityOf, parseParityArgs, readManifest, readRun, resolveOxlint, ruleIdOf, rulesNamedBy };
package/dist/index.js CHANGED
@@ -11,9 +11,10 @@ import {
11
11
  parseParityArgs,
12
12
  readManifest,
13
13
  readRun,
14
+ resolveOxlint,
14
15
  ruleIdOf,
15
16
  rulesNamedBy
16
- } from "./chunk-YPSGSLHS.js";
17
+ } from "./chunk-3PCNMLVE.js";
17
18
  export {
18
19
  MANIFEST_FILE,
19
20
  ParityError,
@@ -27,6 +28,7 @@ export {
27
28
  parseParityArgs,
28
29
  readManifest,
29
30
  readRun,
31
+ resolveOxlint,
30
32
  ruleIdOf,
31
33
  rulesNamedBy
32
34
  };
@@ -3,12 +3,13 @@ import {
3
3
  formatCorpus,
4
4
  formatSummary,
5
5
  parityOf,
6
- parseParityArgs
7
- } from "./chunk-YPSGSLHS.js";
6
+ parseParityArgs,
7
+ resolveOxlint
8
+ } from "./chunk-3PCNMLVE.js";
8
9
 
9
10
  // src/parity-cli.ts
10
- import { existsSync, mkdirSync, writeFileSync } from "fs";
11
- import { dirname, join, resolve } from "path";
11
+ import { mkdirSync, writeFileSync } from "fs";
12
+ import { join, resolve } from "path";
12
13
  var USAGE = `geonosis-lint-parity --a <config-a.json> --b <config-b.json> [--oxlint <path>] [--out <dir>] -- <paths\u2026>
13
14
  geonosis-lint-parity --corpus <dir> --a <config-a.json> --b <config-b.json> [--out <dir>]
14
15
  [--expect-changed <rule,rule,\u2026>]
@@ -34,16 +35,6 @@ oxlint resolves a jsPlugins specifier relative to the CONFIG FILE's directory, n
34
35
  directory. Write both configs INSIDE the workspace being linted, or name the plugin by absolute
35
36
  path \u2014 a config in a temp dir cannot find a plugin installed in the workspace, and the run is
36
37
  refused rather than counted as zero findings.`;
37
- var resolveOxlint = (from) => {
38
- let dir = from;
39
- for (; ; ) {
40
- const bin = resolve(dir, "node_modules/.bin/oxlint");
41
- if (existsSync(bin)) return bin;
42
- const parent = dirname(dir);
43
- if (parent === dir) return "oxlint";
44
- dir = parent;
45
- }
46
- };
47
38
  var main = () => {
48
39
  const argv = process.argv.slice(2);
49
40
  if (argv.includes("--help") || argv.includes("-h") || argv.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@geonosis/lint-parity",
3
- "version": "0.5.0",
3
+ "version": "1.1.0",
4
+ "types": "./dist/index.d.ts",
4
5
  "description": "Findings parity and rule reach over any two oxlint configs — the diff a fork is deleted on.",
5
6
  "keywords": [
6
7
  "oxlint",
@@ -24,7 +25,10 @@
24
25
  "geonosis-lint-parity": "bin/geonosis-lint-parity.mjs"
25
26
  },
26
27
  "exports": {
27
- ".": "./dist/index.js"
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "default": "./dist/index.js"
31
+ }
28
32
  },
29
33
  "files": [
30
34
  "bin",