oxlint-react-compiler-experimental 0.0.7 → 0.1.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.
@@ -1,6 +1,6 @@
1
- import { _ as BUFFER_SIZE, b as __toESM, c as allOptions, d as diagnostics, f as replacePlaceholders, g as BUFFER_ALIGN, h as ACTIVE_SIZE, i as resetStateAfterError, l as setOptions, m as getNodeByRangeIndex, o as registerPlugin, p as getLineColumnFromOffset, r as lintFileImpl, s as registeredRules, t as buffers, u as PLACEHOLDER_REGEX, y as __commonJSMin } from "./lint.js";
1
+ import { _ as BLOCK_SIZE, b as __commonJSMin, c as allOptions, d as diagnostics, f as replacePlaceholders, g as BLOCK_ALIGN, h as ACTIVE_SIZE, i as resetStateAfterError, l as setOptions, m as getNodeByRangeIndex, o as registerPlugin, p as getLineColumnFromOffset, r as lintFileImpl, s as registeredRules, t as buffers, u as PLACEHOLDER_REGEX, v as BUFFER_SIZE, x as __toESM } from "./lint.js";
2
+ import { _ as ObjectValues, a as JSONStringify, d as ObjectEntries, m as ObjectKeys, n as ArrayIsArray, p as ObjectHasOwn, t as ArrayFrom, u as ObjectDefineProperty } from "./globals.js";
2
3
  import { a as rawTransferSupported$1, i as parseRawSync, n as getBufferOffset, t as applyFixes } from "./bindings.js";
3
- import { _ as ObjectValues, d as ObjectDefineProperty, f as ObjectEntries, h as ObjectKeys, m as ObjectHasOwn, n as ArrayFrom, o as JSONStringify, r as ArrayIsArray } from "./utils.js";
4
4
  import assert, { AssertionError } from "node:assert";
5
5
  import { dirname, isAbsolute, join } from "node:path";
6
6
  import util from "node:util";
@@ -63,8 +63,8 @@ var import_json_stable_stringify_without_jsonify = /* @__PURE__ */ __toESM((/* @
63
63
  return keys;
64
64
  };
65
65
  })))(), 1);
66
- const ARRAY_BUFFER_SIZE = BUFFER_SIZE + BUFFER_ALIGN, textEncoder = new TextEncoder();
67
- let buffer = null, rawTransferIsSupported = null;
66
+ const ARRAY_BUFFER_SIZE = BLOCK_SIZE + BLOCK_ALIGN, textEncoder = new TextEncoder();
67
+ let buffer = null, blockBuffer = null, rawTransferIsSupported = null;
68
68
  /**
69
69
  * Parser source text into buffer.
70
70
  * @param path - Path of file to parse
@@ -79,7 +79,7 @@ function parse(path, sourceText, options) {
79
79
  if (maxSourceByteLen > 1073741824) throw Error("Source text is too long");
80
80
  let sourceStartPos = ACTIVE_SIZE - maxSourceByteLen, sourceBuffer = new Uint8Array(buffer.buffer, buffer.byteOffset + sourceStartPos, maxSourceByteLen), { read, written: sourceByteLen } = textEncoder.encodeInto(sourceText, sourceBuffer);
81
81
  if (read !== sourceText.length) throw Error("Failed to write source text into buffer");
82
- if (parseRawSync(path, buffer, sourceStartPos, sourceByteLen, options), buffer.uint32[536870900] === 0) throw Error("Parsing failed");
82
+ if (parseRawSync(path, blockBuffer, sourceStartPos, sourceByteLen, options), buffer.int32[536870890] === 0) throw Error("Parsing failed");
83
83
  }
84
84
  /**
85
85
  * Create a `Uint8Array` which is 2 GiB in size, with its start aligned on 4 GiB.
@@ -92,13 +92,19 @@ function parse(path, sourceText, options) {
92
92
  * It's always possible to obtain a 2 GiB slice aligned on 4 GiB within a 6 GiB buffer,
93
93
  * no matter how the 6 GiB buffer is aligned.
94
94
  *
95
+ * `buffer` itself, and `int32` and `float64` views of `buffer`, are `BUFFER_SIZE` bytes,
96
+ * which excludes `FixedSizeAllocatorMetadata` and `ChunkFooter`.
97
+ * This ensures this critical data cannot be accidentally overwritten on JS side.
98
+ * `blockBuffer` is `BLOCK_SIZE` bytes, which includes `FixedSizeAllocatorMetadata` and `ChunkFooter`.
99
+ * `blockBuffer` is what we pass to Rust, which needs to write them.
100
+ *
95
101
  * Note: On systems with virtual memory, this only consumes 6 GiB of *virtual* memory.
96
102
  * It does not consume physical memory until data is actually written to the `Uint8Array`.
97
103
  * Physical memory consumed corresponds to the quantity of data actually written.
98
104
  */
99
105
  function initBuffer() {
100
106
  let arrayBuffer = new ArrayBuffer(ARRAY_BUFFER_SIZE), offset = getBufferOffset(new Uint8Array(arrayBuffer));
101
- buffer = new Uint8Array(arrayBuffer, offset, BUFFER_SIZE), buffer.uint32 = new Uint32Array(arrayBuffer, offset, BUFFER_SIZE / 4), buffer.float64 = new Float64Array(arrayBuffer, offset, BUFFER_SIZE / 8), buffers.push(buffer);
107
+ buffer = new Uint8Array(arrayBuffer, offset, BUFFER_SIZE), buffer.int32 = new Int32Array(arrayBuffer, offset, BUFFER_SIZE / 4), buffer.float64 = new Float64Array(arrayBuffer, offset, BUFFER_SIZE / 8), blockBuffer = new Uint8Array(arrayBuffer, offset, BLOCK_SIZE), buffers.push(buffer);
102
108
  }
103
109
  /**
104
110
  * Returns `true` if raw transfer is supported.
@@ -353,14 +359,14 @@ function assertInvalidTestCasePasses(test, plugin, config) {
353
359
  typeof error == "string" || error instanceof RegExp ? (assertMessageMatches(diagnostic.message, error), assert(diagnostic.suggestions === null, `Error at index ${errorIndex} has suggestions. Please convert the test error into an object and specify \`suggestions\` property on it to test suggestions`)) : (assertInvalidTestCaseMessageIsCorrect(diagnostic, error, messages), assertInvalidTestCaseLocationIsCorrect(diagnostic, error, test), ObjectHasOwn(error, "suggestions") && (error.suggestions == null ? assert(diagnostic.suggestions === null, "Rule produced suggestions") : assertSuggestionsAreCorrect(diagnostic, error, messages, test)));
354
360
  }
355
361
  }
356
- let { code } = test, eslintCompat = test.eslintCompat === !0, fixedCode = runFixes(diagnostics, code, eslintCompat);
362
+ let { code } = test, fixedCode = runFixes(diagnostics, code);
357
363
  fixedCode === null && (fixedCode = code);
358
364
  let { recursive } = test, extraPassCount = typeof recursive == "number" ? recursive : recursive === !0 ? 10 : 0;
359
365
  if (extraPassCount > 0 && fixedCode !== code) for (let pass = 0; pass < extraPassCount; pass++) {
360
366
  let newFixedCode = runFixes(lint({
361
367
  ...test,
362
368
  code: fixedCode
363
- }, plugin), fixedCode, eslintCompat);
369
+ }, plugin), fixedCode);
364
370
  if (newFixedCode === null) break;
365
371
  fixedCode = newFixedCode;
366
372
  }
@@ -378,11 +384,11 @@ function assertInvalidTestCasePasses(test, plugin, config) {
378
384
  * @returns Fixed code, or `null` if no fixes to apply
379
385
  * @throws {Error} If error when applying fixes
380
386
  */
381
- function runFixes(diagnostics, code, eslintCompat) {
387
+ function runFixes(diagnostics, code) {
382
388
  let fixGroups = [];
383
389
  for (let diagnostic of diagnostics) diagnostic.fixes !== null && fixGroups.push(diagnostic.fixes);
384
390
  if (fixGroups.length === 0) return null;
385
- let fixedCode = applyFixes(code, JSONStringify(fixGroups), eslintCompat);
391
+ let fixedCode = applyFixes(code, JSONStringify(fixGroups));
386
392
  if (fixedCode === null) throw Error("Failed to apply fixes");
387
393
  return fixedCode;
388
394
  }
@@ -432,7 +438,7 @@ function assertMessageIdIsCorrect(reportedMessageId, reportedMessage, messageId,
432
438
  * @throws {AssertionError} If diagnostic's location does not match expected location
433
439
  */
434
440
  function assertInvalidTestCaseLocationIsCorrect(diagnostic, error, test) {
435
- let actualLocation = {}, expectedLocation = {}, columnOffset = test.eslintCompat === !0 ? 1 : 0;
441
+ let actualLocation = {}, expectedLocation = {}, columnOffset = +(test.eslintCompat === !0);
436
442
  ObjectHasOwn(error, "line") && (actualLocation.line = diagnostic.line, expectedLocation.line = error.line), ObjectHasOwn(error, "column") && (actualLocation.column = diagnostic.column + columnOffset, expectedLocation.column = error.column);
437
443
  let canVoidEndLocation = test.eslintCompat === !0 && diagnostic.endLine === diagnostic.line && diagnostic.endColumn === diagnostic.column;
438
444
  ObjectHasOwn(error, "endLine") && (error.endLine === void 0 && canVoidEndLocation ? actualLocation.endLine = void 0 : actualLocation.endLine = diagnostic.endLine, expectedLocation.endLine = error.endLine), ObjectHasOwn(error, "endColumn") && (error.endColumn === void 0 && canVoidEndLocation ? actualLocation.endColumn = void 0 : actualLocation.endColumn = diagnostic.endColumn + columnOffset, expectedLocation.endColumn = error.endColumn), ObjectKeys(expectedLocation).length > 0 && assert.deepStrictEqual(actualLocation, expectedLocation, "Actual error location does not match expected error location.");
@@ -448,11 +454,10 @@ function assertInvalidTestCaseLocationIsCorrect(diagnostic, error, test) {
448
454
  function assertSuggestionsAreCorrect(diagnostic, error, messages, test) {
449
455
  let actualSuggestions = diagnostic.suggestions ?? [], expectedSuggestions = error.suggestions;
450
456
  assert.strictEqual(actualSuggestions.length, expectedSuggestions.length, `Error should have ${expectedSuggestions.length} suggestion${expectedSuggestions.length > 1 ? "s" : ""}. Instead found ${actualSuggestions.length} suggestion${actualSuggestions.length > 1 ? "s" : ""}.`);
451
- let eslintCompat = test.eslintCompat === !0;
452
457
  for (let i = 0; i < expectedSuggestions.length; i++) {
453
458
  let actual = actualSuggestions[i], expected = expectedSuggestions[i], prefix = `Suggestion at index ${i}`;
454
459
  assertSuggestionMessageIsCorrect(actual, expected, messages, prefix), assert(ObjectHasOwn(expected, "output"), `${prefix}: \`output\` property is required`);
455
- let suggestedCode = applyFixes(test.code, JSONStringify([actual.fixes]), eslintCompat);
460
+ let suggestedCode = applyFixes(test.code, JSONStringify([actual.fixes]));
456
461
  assert(suggestedCode !== null, `${prefix}: Failed to apply suggestion fix`), assert.strictEqual(suggestedCode, expected.output, `${prefix}: Expected the applied suggestion fix to match the test suggestion output`), assert.notStrictEqual(expected.output, test.code, `${prefix}: The output of a suggestion should differ from the original source code`);
457
462
  }
458
463
  }
package/dist/utils.js CHANGED
@@ -1,15 +1,3 @@
1
- //#region src-js/utils/globals.ts
2
- /**
3
- * Properties of global objects exported as variables.
4
- *
5
- * TSDown will replace e.g. `Object.keys` with import of `ObjectKeys` from this file.
6
- *
7
- * If you use any globals in code in `src-js` directory, you should add them to this file.
8
- *
9
- * See TSDown config file for more details.
10
- */
11
- const { prototype: ObjectPrototype, hasOwn: ObjectHasOwn, keys: ObjectKeys, values: ObjectValues, freeze: ObjectFreeze, preventExtensions: ObjectPreventExtensions, defineProperty: ObjectDefineProperty, defineProperties: ObjectDefineProperties, create: ObjectCreate, assign: ObjectAssign, getPrototypeOf: ObjectGetPrototypeOf, setPrototypeOf: ObjectSetPrototypeOf, entries: ObjectEntries } = Object, { prototype: ArrayPrototype, isArray: ArrayIsArray, from: ArrayFrom } = Array, { min: MathMin, max: MathMax, floor: MathFloor } = Math, { parse: JSONParse, stringify: JSONStringify } = JSON, { ownKeys: ReflectOwnKeys } = Reflect, { iterator: SymbolIterator } = Symbol, { fromCodePoint: StringFromCodePoint } = String, { now: DateNow } = Date;
12
- //#endregion
13
1
  //#region src-js/utils/utils.ts
14
2
  /**
15
3
  * Get error message from an error.
@@ -41,4 +29,4 @@ function getErrorMessage(err) {
41
29
  return "Unknown error";
42
30
  }
43
31
  //#endregion
44
- export { ObjectValues as _, JSONParse as a, MathMin as c, ObjectDefineProperty as d, ObjectEntries as f, ObjectPreventExtensions as g, ObjectKeys as h, DateNow as i, ObjectAssign as l, ObjectHasOwn as m, ArrayFrom as n, JSONStringify as o, ObjectFreeze as p, ArrayIsArray as r, MathMax as s, getErrorMessage as t, ObjectCreate as u, StringFromCodePoint as v, SymbolIterator as y };
32
+ export { getErrorMessage as t };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "oxlint-react-compiler-experimental",
3
- "version": "0.0.7",
4
- "description": "Experimental oxlint with React Compiler rules (darwin-arm64 only)",
3
+ "version": "0.1.1",
4
+ "description": "Experimental oxlint build with React Compiler rules. Multi-platform: darwin-arm64, linux-arm64, linux-x64, win32-arm64, win32-x64.",
5
5
  "keywords": [
6
6
  "eslint",
7
7
  "javascript",
@@ -39,11 +39,22 @@
39
39
  "binaryName": "oxlint",
40
40
  "packageName": "@oxlint/binding",
41
41
  "targets": [
42
- "aarch64-apple-darwin"
42
+ "aarch64-apple-darwin",
43
+ "aarch64-unknown-linux-gnu",
44
+ "x86_64-unknown-linux-gnu",
45
+ "aarch64-pc-windows-msvc",
46
+ "x86_64-pc-windows-msvc"
43
47
  ]
44
48
  },
45
- "os": ["darwin"],
46
- "cpu": ["arm64"],
49
+ "os": [
50
+ "darwin",
51
+ "linux",
52
+ "win32"
53
+ ],
54
+ "cpu": [
55
+ "arm64",
56
+ "x64"
57
+ ],
47
58
  "engines": {
48
59
  "node": "^20.19.0 || >=22.12.0"
49
60
  },
package/dist/config.js DELETED
@@ -1,16 +0,0 @@
1
- //#region src-js/package/config.ts
2
- const DEFINE_CONFIG_REGISTRY = /* @__PURE__ */ new WeakSet();
3
- /**
4
- * Define an Oxlint configuration with type inference.
5
- *
6
- * @param config - Oxlint configuration
7
- * @returns Config unchanged
8
- */
9
- function defineConfig(config) {
10
- return DEFINE_CONFIG_REGISTRY.add(config), config;
11
- }
12
- function isDefineConfig(config) {
13
- return typeof config == "object" && !!config && DEFINE_CONFIG_REGISTRY.has(config);
14
- }
15
- //#endregion
16
- export { isDefineConfig as n, defineConfig as t };