oxlint 1.64.0 → 1.66.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.
package/dist/js_config.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { a as JSONStringify, n as ArrayIsArray, r as DateNow } from "./globals.js";
2
- import { t as getErrorMessage } from "./utils.js";
2
+ import { t as getErrorMessage$1 } from "./utils.js";
3
3
  import { extname } from "node:path";
4
- import { fileURLToPath } from "node:url";
5
- //#region src-js/utils/node_version.ts
4
+ import { fileURLToPath, pathToFileURL } from "node:url";
5
+ //#region ../shared/src-js/node_version.ts
6
6
  const TS_MODULE_EXTENSIONS = new Set([
7
7
  ".ts",
8
8
  ".mts",
@@ -25,10 +25,46 @@ function isUnknownFileExtensionError(err) {
25
25
  let message = err?.message;
26
26
  return typeof message == "string" && /unknown(?: or unsupported)? file extension/i.test(message);
27
27
  }
28
+ function getErrorMessage(err) {
29
+ return err instanceof Error ? err.message : String(err);
30
+ }
31
+ /**
32
+ * Returns a complete replacement string suitable for `Error.message` assignment
33
+ * (includes the original error message + appended hint), or `null` when the
34
+ * error is unrelated to TS module loading. Callers should overwrite, not append.
35
+ */
28
36
  function getUnsupportedTypeScriptModuleLoadHintForError(err, specifier, nodeVersion = process.version) {
29
37
  return !isTypeScriptModuleSpecifier(specifier) || !isUnknownFileExtensionError(err) ? null : `${getErrorMessage(err)}\n\nTypeScript config files require Node.js ^20.19.0 || >=22.18.0.\nDetected Node.js ${nodeVersion}.\nPlease upgrade Node.js or use a JSON config file instead.`;
30
38
  }
31
39
  //#endregion
40
+ //#region ../shared/src-js/js_config.ts
41
+ /**
42
+ * Import a JS/TS config file and return its `default` export.
43
+ *
44
+ * - Bypasses Node.js module cache (uses `?cache=<key>`) so changed files reload (used for LSP).
45
+ * - On `ERR_UNKNOWN_FILE_EXTENSION` for TS specifiers, overwrites `err.message` with a
46
+ * Node.js upgrade hint that already includes the original message.
47
+ *
48
+ * @param path - Absolute path to the JS/TS config file
49
+ * @param cacheKey - Cache-busting key.
50
+ * Callers decide whether to use a fresh value per call or share one across a batch.
51
+ * @throws When the file has no `default` export,
52
+ * or import fails (with rewritten message for unsupported TS module load).
53
+ */
54
+ async function importJsConfig(path, cacheKey) {
55
+ let fileUrl = pathToFileURL(path);
56
+ fileUrl.searchParams.set("cache", cacheKey.toString());
57
+ let module;
58
+ try {
59
+ module = await import(fileUrl.href);
60
+ } catch (err) {
61
+ let hint = getUnsupportedTypeScriptModuleLoadHintForError(err, path);
62
+ throw hint && err instanceof Error && (err.message = hint), err;
63
+ }
64
+ if (module.default === void 0) throw Error("Configuration file has no default export.");
65
+ return module.default;
66
+ }
67
+ //#endregion
32
68
  //#region src-js/js_config.ts
33
69
  const isObject = (v) => typeof v == "object" && !!v && !ArrayIsArray(v);
34
70
  function validateConfigExtends(root) {
@@ -60,19 +96,11 @@ ${refPath} points back to ${cycleStart}\nCycle: ${idx === -1 ? `${cycleStart} ->
60
96
  visit(root, "<root>");
61
97
  }
62
98
  /**
63
- * Import a JS/TS config file and return its default export.
64
- */
65
- async function importConfig(path, cacheKey) {
66
- let config = (await import(new URL(`file://${path}?cache=${cacheKey}`).href)).default;
67
- if (config === void 0) throw Error("Configuration file has no default export.");
68
- return config;
69
- }
70
- /**
71
99
  * Resolve a single config path to a `JsConfigResult`.
72
100
  * Standard mode: default export must be a plain object.
73
101
  */
74
102
  async function resolveJsConfig(path, cacheKey) {
75
- let config = await importConfig(path, cacheKey);
103
+ let config = await importJsConfig(path, cacheKey);
76
104
  if (!isObject(config)) throw Error("Configuration file must have a default export that is an object.");
77
105
  return validateConfigExtends(config), {
78
106
  path,
@@ -85,7 +113,7 @@ const VITE_OXLINT_CONFIG_FIELD = "lint";
85
113
  * Extracts the `.lint` field. Returns `null` config when missing (signals "skip").
86
114
  */
87
115
  async function resolveVitePlusConfig(path, cacheKey) {
88
- let config = await importConfig(path, cacheKey);
116
+ let config = await importJsConfig(path, cacheKey);
89
117
  if (!isObject(config)) return {
90
118
  path,
91
119
  config: null
@@ -109,18 +137,14 @@ async function loadConfigs(paths, resolver) {
109
137
  let cacheKey = DateNow(), results = await Promise.allSettled(paths.map((path) => resolver(path, cacheKey))), successes = [], errors = [];
110
138
  for (let i = 0; i < results.length; i++) {
111
139
  let result = results[i];
112
- if (result.status === "fulfilled") successes.push(result.value);
113
- else {
114
- let path = paths[i], unsupportedNodeHint = getUnsupportedTypeScriptModuleLoadHintForError(result.reason, path);
115
- errors.push({
116
- path,
117
- error: unsupportedNodeHint ?? getErrorMessage(result.reason)
118
- });
119
- }
140
+ result.status === "fulfilled" ? successes.push(result.value) : errors.push({
141
+ path: paths[i],
142
+ error: getErrorMessage$1(result.reason)
143
+ });
120
144
  }
121
145
  return errors.length > 0 ? JSONStringify({ Failures: errors }) : JSONStringify({ Success: successes });
122
146
  } catch (err) {
123
- return JSONStringify({ Error: getErrorMessage(err) });
147
+ return JSONStringify({ Error: getErrorMessage$1(err) });
124
148
  }
125
149
  }
126
150
  /**
package/dist/lint.js CHANGED
@@ -821,11 +821,11 @@ const NodeProto = ObjectCreate(ObjectPrototype, { loc: {
821
821
  },
822
822
  enumerable: !0
823
823
  } });
824
- function deserializeProgramOnly(buffer, sourceText, sourceStartPosInput, sourceByteLen) {
825
- return sourceStartPos$1 = sourceStartPosInput, deserializeWith(buffer, sourceText, sourceByteLen, deserializeProgram);
824
+ function deserializeProgramOnly(buffer, sourceText, sourceStartPos, sourceByteLen) {
825
+ return deserializeWith(buffer, sourceText, sourceStartPos, sourceByteLen, deserializeProgram);
826
826
  }
827
- function deserializeWith(buffer, sourceTextInput, sourceByteLen, deserialize) {
828
- if (uint8 = buffer, int32 = buffer.int32, float64 = buffer.float64, sourceText$1 = sourceTextInput, sourceText$1.length === sourceByteLen) firstNonAsciiPos = sourceStartPos$1 + sourceByteLen, sourceTextLatin = sourceText$1;
827
+ function deserializeWith(buffer, sourceTextInput, sourceStartPosInput, sourceByteLen, deserialize) {
828
+ if (uint8 = buffer, int32 = buffer.int32, float64 = buffer.float64, sourceText$1 = sourceTextInput, sourceStartPos$1 = sourceStartPosInput, sourceText$1.length === sourceByteLen) firstNonAsciiPos = sourceStartPos$1 + sourceByteLen, sourceTextLatin = sourceText$1;
829
829
  else {
830
830
  let i = sourceStartPos$1, sourceEndPos = sourceStartPos$1 + sourceByteLen;
831
831
  for (; i < sourceEndPos && uint8[i] < 128; i++);
@@ -14099,7 +14099,7 @@ function resetSettings() {
14099
14099
  }
14100
14100
  //#endregion
14101
14101
  //#region package.json
14102
- var version = "1.64.0";
14102
+ var version = "1.66.0";
14103
14103
  //#endregion
14104
14104
  //#region src-js/plugins/context.ts
14105
14105
  let filePath = null, cwd = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oxlint",
3
- "version": "1.64.0",
3
+ "version": "1.66.0",
4
4
  "description": "Linter for the JavaScript Oxidation Compiler",
5
5
  "keywords": [
6
6
  "eslint",
@@ -83,24 +83,24 @@
83
83
  },
84
84
  "preferUnplugged": true,
85
85
  "optionalDependencies": {
86
- "@oxlint/binding-darwin-arm64": "1.64.0",
87
- "@oxlint/binding-android-arm64": "1.64.0",
88
- "@oxlint/binding-win32-arm64-msvc": "1.64.0",
89
- "@oxlint/binding-linux-arm64-gnu": "1.64.0",
90
- "@oxlint/binding-linux-arm64-musl": "1.64.0",
91
- "@oxlint/binding-openharmony-arm64": "1.64.0",
92
- "@oxlint/binding-android-arm-eabi": "1.64.0",
93
- "@oxlint/binding-linux-arm-gnueabihf": "1.64.0",
94
- "@oxlint/binding-linux-arm-musleabihf": "1.64.0",
95
- "@oxlint/binding-win32-ia32-msvc": "1.64.0",
96
- "@oxlint/binding-linux-ppc64-gnu": "1.64.0",
97
- "@oxlint/binding-linux-riscv64-gnu": "1.64.0",
98
- "@oxlint/binding-linux-riscv64-musl": "1.64.0",
99
- "@oxlint/binding-linux-s390x-gnu": "1.64.0",
100
- "@oxlint/binding-darwin-x64": "1.64.0",
101
- "@oxlint/binding-win32-x64-msvc": "1.64.0",
102
- "@oxlint/binding-freebsd-x64": "1.64.0",
103
- "@oxlint/binding-linux-x64-gnu": "1.64.0",
104
- "@oxlint/binding-linux-x64-musl": "1.64.0"
86
+ "@oxlint/binding-darwin-arm64": "1.66.0",
87
+ "@oxlint/binding-android-arm64": "1.66.0",
88
+ "@oxlint/binding-win32-arm64-msvc": "1.66.0",
89
+ "@oxlint/binding-linux-arm64-gnu": "1.66.0",
90
+ "@oxlint/binding-linux-arm64-musl": "1.66.0",
91
+ "@oxlint/binding-openharmony-arm64": "1.66.0",
92
+ "@oxlint/binding-android-arm-eabi": "1.66.0",
93
+ "@oxlint/binding-linux-arm-gnueabihf": "1.66.0",
94
+ "@oxlint/binding-linux-arm-musleabihf": "1.66.0",
95
+ "@oxlint/binding-win32-ia32-msvc": "1.66.0",
96
+ "@oxlint/binding-linux-ppc64-gnu": "1.66.0",
97
+ "@oxlint/binding-linux-riscv64-gnu": "1.66.0",
98
+ "@oxlint/binding-linux-riscv64-musl": "1.66.0",
99
+ "@oxlint/binding-linux-s390x-gnu": "1.66.0",
100
+ "@oxlint/binding-darwin-x64": "1.66.0",
101
+ "@oxlint/binding-win32-x64-msvc": "1.66.0",
102
+ "@oxlint/binding-freebsd-x64": "1.66.0",
103
+ "@oxlint/binding-linux-x64-gnu": "1.66.0",
104
+ "@oxlint/binding-linux-x64-musl": "1.66.0"
105
105
  }
106
106
  }