@geonosis/lint-parity 2.0.0 → 2.2.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,6 +1,6 @@
1
1
  // src/envelope.ts
2
2
  import { mkdirSync, readFileSync, writeFileSync } from "fs";
3
- import { dirname, join } from "path";
3
+ import { dirname, join, resolve } from "path";
4
4
  import { fileURLToPath } from "url";
5
5
  var ENVELOPES_DIR = ".geonosis/envelopes";
6
6
  var envelopePath = (root, tool) => join(root, ENVELOPES_DIR, `${tool}.json`);
@@ -12,6 +12,14 @@ var UnbalancedEnvelope = class extends Error {
12
12
  };
13
13
  var isCount = (value) => Number.isSafeInteger(value) && value >= 0;
14
14
  var unbalancedMessage = (envelope, next) => `${envelope.tool}: considered ${envelope.considered} but accounts for ${envelope.read + envelope.refused.length + envelope.excused.length} \u2014 ${envelope.read} read + ${envelope.refused.length} refused + ${envelope.excused.length} excused. A run that has lost count of its own inputs cannot say what it measured, so no verdict was rendered and no envelope was written. Next: ${next}`;
15
+ var FORBIDDEN_ROOT = "GEONOSIS_ENVELOPES_FORBIDDEN_ROOT";
16
+ var refuseForbiddenRoot = (root) => {
17
+ const forbidden = process.env[FORBIDDEN_ROOT];
18
+ if (forbidden === void 0 || resolve(forbidden) !== resolve(root)) return;
19
+ throw new UnbalancedEnvelope(
20
+ `${root} is off limits to envelope writers in this process (${FORBIDDEN_ROOT}) \u2014 a run that writes one into a shared root races every other run reading it, and leaves a file the next one takes for real. Point this at a scratch root of its own: tooling/scratch-dir.ts.`
21
+ );
22
+ };
15
23
  var writeEnvelope = ({
16
24
  envelope,
17
25
  next,
@@ -35,6 +43,7 @@ var writeEnvelope = ({
35
43
  if (envelope.considered !== envelope.read + envelope.refused.length + envelope.excused.length) {
36
44
  throw new UnbalancedEnvelope(unbalancedMessage(envelope, next));
37
45
  }
46
+ refuseForbiddenRoot(root);
38
47
  const at = envelopePath(root, envelope.tool);
39
48
  mkdirSync(dirname(at), { recursive: true });
40
49
  writeFileSync(at, `${JSON.stringify(envelope, void 0, 2)}
@@ -94,7 +103,7 @@ import {
94
103
  writeFileSync as writeFileSync2
95
104
  } from "fs";
96
105
  import { tmpdir } from "os";
97
- import { dirname as dirname2, join as join2, resolve } from "path";
106
+ import { dirname as dirname2, join as join2, resolve as resolve2 } from "path";
98
107
  var ANSI = /\[[0-9;]*m/g;
99
108
  var SUMMARY_COUNT = /^(\d+) problems?$/m;
100
109
  var RULE_IN_LINE = /\[(?:Error|Warning)\/([^\]]+)\]$/;
@@ -103,7 +112,7 @@ var FINDING_PLACE = /^(\S[^\n]*?:\d+:\d+): .*\[(?:Error|Warning)\/([^\]\n]+)\]$/
103
112
  var resolveOxlint = (from) => {
104
113
  let dir = from;
105
114
  for (; ; ) {
106
- const bin = resolve(dir, "node_modules/.bin/oxlint");
115
+ const bin = resolve2(dir, "node_modules/.bin/oxlint");
107
116
  if (existsSync(bin)) return bin;
108
117
  const parent = dirname2(dir);
109
118
  if (parent === dir) return "oxlint";
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  resolveOxlint,
17
17
  ruleIdOf,
18
18
  rulesNamedBy
19
- } from "./chunk-D7OGKQ2C.js";
19
+ } from "./chunk-JNTU55OA.js";
20
20
  export {
21
21
  MANIFEST_FILE,
22
22
  ParityError,
@@ -9,7 +9,7 @@ import {
9
9
  parseParityArgs,
10
10
  resolveOxlint,
11
11
  writeEnvelope
12
- } from "./chunk-D7OGKQ2C.js";
12
+ } from "./chunk-JNTU55OA.js";
13
13
 
14
14
  // src/parity-cli.ts
15
15
  import { mkdirSync, writeFileSync } from "fs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geonosis/lint-parity",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "types": "./dist/index.d.ts",
5
5
  "description": "Findings parity and rule reach over any two oxlint configs — the diff a fork is deleted on.",
6
6
  "keywords": [
@@ -44,7 +44,7 @@
44
44
  "access": "public"
45
45
  },
46
46
  "devDependencies": {
47
- "@geonosis/ratchet": "2.0.0"
47
+ "@geonosis/ratchet": "2.2.0"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "tsup",