oxlint 1.16.0 → 1.17.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,5 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import { readFileSync } from "fs";
4
+ import { spawnSync, execSync } from "child_process";
5
+ import { createRequire } from "module";
6
+
7
+ const require = createRequire(import.meta.url);
8
+
3
9
  const isMusl = () => {
4
10
  let musl = false;
5
11
  if (process.platform === "linux") {
@@ -17,7 +23,6 @@ const isMusl = () => {
17
23
  const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
18
24
 
19
25
  const isMuslFromFilesystem = () => {
20
- const { readFileSync } = require("fs");
21
26
  try {
22
27
  return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
23
28
  } catch {
@@ -46,8 +51,7 @@ const isMuslFromReport = () => {
46
51
 
47
52
  const isMuslFromChildProcess = () => {
48
53
  try {
49
- return require("child_process")
50
- .execSync("ldd --version", { encoding: "utf8" })
54
+ return execSync("ldd --version", { encoding: "utf8" })
51
55
  .includes("musl");
52
56
  } catch (e) {
53
57
  // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
@@ -95,7 +99,7 @@ const PLATFORMS = {
95
99
  let binPath = PLATFORMS[platform]?.[arch]?.[isMusl() ? "musl" : "gnu"];
96
100
 
97
101
  if (binPath) {
98
- const result = require("child_process").spawnSync(
102
+ const result = spawnSync(
99
103
  require.resolve(binPath),
100
104
  process.argv.slice(2),
101
105
  {
package/bin/oxlint CHANGED
@@ -1,149 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const isMusl = () => {
4
- let musl = false;
5
- if (process.platform === "linux") {
6
- musl = isMuslFromFilesystem();
7
- if (musl === null) {
8
- musl = isMuslFromReport();
9
- }
10
- if (musl === null) {
11
- musl = isMuslFromChildProcess();
12
- }
13
- }
14
- return musl;
15
- };
16
-
17
- const isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-");
18
-
19
- const isMuslFromFilesystem = () => {
20
- const { readFileSync } = require("fs");
21
- try {
22
- return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
23
- } catch(_error) {
24
- return null;
25
- }
26
- };
27
-
28
- const isMuslFromReport = () => {
29
- const report =
30
- typeof process.report.getReport === "function"
31
- ? process.report.getReport()
32
- : null;
33
- if (!report) {
34
- return null;
35
- }
36
- if (report.header && report.header.glibcVersionRuntime) {
37
- return false;
38
- }
39
- if (Array.isArray(report.sharedObjects)) {
40
- if (report.sharedObjects.some(isFileMusl)) {
41
- return true;
42
- }
43
- }
44
- return false;
45
- };
46
-
47
- const isMuslFromChildProcess = () => {
48
- try {
49
- return require("child_process")
50
- .execSync("ldd --version", { encoding: "utf8" })
51
- .includes("musl");
52
- } catch (e) {
53
- // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
54
- return false;
55
- }
56
- };
57
-
58
- const { platform, arch, env, version, release } = process;
59
-
60
- const PLATFORMS = {
61
- win32: {
62
- x64: {
63
- musl: "@oxlint/win32-x64/oxlint.exe",
64
- gnu: "@oxlint/win32-x64/oxlint.exe",
65
- },
66
- arm64: {
67
- musl: "@oxlint/win32-arm64/oxlint.exe",
68
- gnu: "@oxlint/win32-arm64/oxlint.exe",
69
- },
70
- },
71
- darwin: {
72
- x64: {
73
- musl: "@oxlint/darwin-x64/oxlint",
74
- gnu: "@oxlint/darwin-x64/oxlint",
75
- },
76
- arm64: {
77
- musl: "@oxlint/darwin-arm64/oxlint",
78
- gnu: "@oxlint/darwin-arm64/oxlint",
79
- },
80
- },
81
- linux: {
82
- x64: {
83
- musl: "@oxlint/linux-x64-musl/oxlint",
84
- gnu: "@oxlint/linux-x64-gnu/oxlint",
85
- },
86
- arm64: {
87
- musl: "@oxlint/linux-arm64-musl/oxlint",
88
- gnu: "@oxlint/linux-arm64-gnu/oxlint",
89
- },
90
- },
91
- };
92
-
93
- let binPath = (
94
- PLATFORMS &&
95
- PLATFORMS[platform] &&
96
- PLATFORMS[platform][arch] &&
97
- PLATFORMS[platform][arch][isMusl() ? "musl" : "gnu"]
98
- ) || null;
99
-
100
- if (binPath) {
101
- const result = require("child_process").spawnSync(
102
- require.resolve(binPath),
103
- process.argv.slice(2),
104
- {
105
- shell: false,
106
- stdio: "inherit",
107
- env: Object.assign({}, env, {
108
- JS_RUNTIME_VERSION: version,
109
- JS_RUNTIME_NAME: release.name,
110
- NODE_PACKAGE_MANAGER: detectPackageManager(),
111
- }),
112
- }
113
- );
114
-
115
- if (result.error) {
116
- throw result.error;
117
- }
118
-
119
- process.exitCode = result.status;
120
- } else {
121
- let target = `${platform}-${arch}`;
122
- if (isMusl()) {
123
- target = `${target}-musl`;
124
- }
125
- console.error(
126
- `The oxlint CLI package doesn't ship with prebuilt binaries for your platform (${target}) yet. ` +
127
- "You can create an issue at https://github.com/oxc-project/oxc/issues for support."
128
- );
129
- process.exitCode = 1;
130
- }
131
-
132
- /**
133
- * NPM, Yarn, and other package manager set the `npm_config_user_agent`. It has the following format:
134
- *
135
- * ```
136
- * "npm/8.3.0 node/v16.13.2 win32 x64 workspaces/false
137
- * ```
138
- *
139
- * @returns The package manager string (`npm/8.3.0`) or null if the user agent string isn't set.
140
- */
141
- function detectPackageManager() {
142
- const userAgent = env.npm_config_user_agent;
143
-
144
- if (userAgent == null) {
145
- return null;
146
- }
147
-
148
- return userAgent.split(" ")[0];
149
- }
3
+ import "../dist/cli.js";
package/dist/cli.js ADDED
@@ -0,0 +1,400 @@
1
+ import { createRequire } from "node:module";
2
+ const require = createRequire(import.meta.url);
3
+ new URL(".", import.meta.url).pathname;
4
+ const { readFileSync } = require("node:fs");
5
+ let nativeBinding = null;
6
+ const loadErrors = [], isMusl = () => {
7
+ let musl = !1;
8
+ return process.platform === "linux" && (musl = isMuslFromFilesystem(), musl === null && (musl = isMuslFromReport()), musl === null && (musl = isMuslFromChildProcess())), musl;
9
+ }, isFileMusl = (f) => f.includes("libc.musl-") || f.includes("ld-musl-"), isMuslFromFilesystem = () => {
10
+ try {
11
+ return readFileSync("/usr/bin/ldd", "utf-8").includes("musl");
12
+ } catch {
13
+ return null;
14
+ }
15
+ }, isMuslFromReport = () => {
16
+ let report = null;
17
+ return typeof process.report?.getReport == "function" && (process.report.excludeNetwork = !0, report = process.report.getReport()), report ? report.header && report.header.glibcVersionRuntime ? !1 : !!(Array.isArray(report.sharedObjects) && report.sharedObjects.some(isFileMusl)) : null;
18
+ }, isMuslFromChildProcess = () => {
19
+ try {
20
+ return require("child_process").execSync("ldd --version", { encoding: "utf8" }).includes("musl");
21
+ } catch {
22
+ return !1;
23
+ }
24
+ };
25
+ function requireNative() {
26
+ if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) try {
27
+ return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
28
+ } catch (err) {
29
+ loadErrors.push(err);
30
+ }
31
+ else if (process.platform === "android") if (process.arch === "arm64") {
32
+ try {
33
+ return require("./oxlint.android-arm64.node");
34
+ } catch (e) {
35
+ loadErrors.push(e);
36
+ }
37
+ try {
38
+ let binding = require("@oxlint/android-arm64"), bindingPackageVersion = require("@oxlint/android-arm64/package.json").version;
39
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
40
+ return binding;
41
+ } catch (e) {
42
+ loadErrors.push(e);
43
+ }
44
+ } else if (process.arch === "arm") {
45
+ try {
46
+ return require("./oxlint.android-arm-eabi.node");
47
+ } catch (e) {
48
+ loadErrors.push(e);
49
+ }
50
+ try {
51
+ let binding = require("@oxlint/android-arm-eabi"), bindingPackageVersion = require("@oxlint/android-arm-eabi/package.json").version;
52
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
53
+ return binding;
54
+ } catch (e) {
55
+ loadErrors.push(e);
56
+ }
57
+ } else loadErrors.push(/* @__PURE__ */ Error(`Unsupported architecture on Android ${process.arch}`));
58
+ else if (process.platform === "win32") if (process.arch === "x64") {
59
+ try {
60
+ return require("./oxlint.win32-x64-msvc.node");
61
+ } catch (e) {
62
+ loadErrors.push(e);
63
+ }
64
+ try {
65
+ let binding = require("@oxlint/win32-x64"), bindingPackageVersion = require("@oxlint/win32-x64/package.json").version;
66
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
67
+ return binding;
68
+ } catch (e) {
69
+ loadErrors.push(e);
70
+ }
71
+ } else if (process.arch === "ia32") {
72
+ try {
73
+ return require("./oxlint.win32-ia32-msvc.node");
74
+ } catch (e) {
75
+ loadErrors.push(e);
76
+ }
77
+ try {
78
+ let binding = require("@oxlint/win32-ia32"), bindingPackageVersion = require("@oxlint/win32-ia32/package.json").version;
79
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
80
+ return binding;
81
+ } catch (e) {
82
+ loadErrors.push(e);
83
+ }
84
+ } else if (process.arch === "arm64") {
85
+ try {
86
+ return require("./oxlint.win32-arm64-msvc.node");
87
+ } catch (e) {
88
+ loadErrors.push(e);
89
+ }
90
+ try {
91
+ let binding = require("@oxlint/win32-arm64"), bindingPackageVersion = require("@oxlint/win32-arm64/package.json").version;
92
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
93
+ return binding;
94
+ } catch (e) {
95
+ loadErrors.push(e);
96
+ }
97
+ } else loadErrors.push(/* @__PURE__ */ Error(`Unsupported architecture on Windows: ${process.arch}`));
98
+ else if (process.platform === "darwin") {
99
+ try {
100
+ return require("./oxlint.darwin-universal.node");
101
+ } catch (e) {
102
+ loadErrors.push(e);
103
+ }
104
+ try {
105
+ let binding = require("@oxlint/darwin-universal"), bindingPackageVersion = require("@oxlint/darwin-universal/package.json").version;
106
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
107
+ return binding;
108
+ } catch (e) {
109
+ loadErrors.push(e);
110
+ }
111
+ if (process.arch === "x64") {
112
+ try {
113
+ return require("./oxlint.darwin-x64.node");
114
+ } catch (e) {
115
+ loadErrors.push(e);
116
+ }
117
+ try {
118
+ let binding = require("@oxlint/darwin-x64"), bindingPackageVersion = require("@oxlint/darwin-x64/package.json").version;
119
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
120
+ return binding;
121
+ } catch (e) {
122
+ loadErrors.push(e);
123
+ }
124
+ } else if (process.arch === "arm64") {
125
+ try {
126
+ return require("./oxlint.darwin-arm64.node");
127
+ } catch (e) {
128
+ loadErrors.push(e);
129
+ }
130
+ try {
131
+ let binding = require("@oxlint/darwin-arm64"), bindingPackageVersion = require("@oxlint/darwin-arm64/package.json").version;
132
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
133
+ return binding;
134
+ } catch (e) {
135
+ loadErrors.push(e);
136
+ }
137
+ } else loadErrors.push(/* @__PURE__ */ Error(`Unsupported architecture on macOS: ${process.arch}`));
138
+ } else if (process.platform === "freebsd") if (process.arch === "x64") {
139
+ try {
140
+ return require("./oxlint.freebsd-x64.node");
141
+ } catch (e) {
142
+ loadErrors.push(e);
143
+ }
144
+ try {
145
+ let binding = require("@oxlint/freebsd-x64"), bindingPackageVersion = require("@oxlint/freebsd-x64/package.json").version;
146
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
147
+ return binding;
148
+ } catch (e) {
149
+ loadErrors.push(e);
150
+ }
151
+ } else if (process.arch === "arm64") {
152
+ try {
153
+ return require("./oxlint.freebsd-arm64.node");
154
+ } catch (e) {
155
+ loadErrors.push(e);
156
+ }
157
+ try {
158
+ let binding = require("@oxlint/freebsd-arm64"), bindingPackageVersion = require("@oxlint/freebsd-arm64/package.json").version;
159
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
160
+ return binding;
161
+ } catch (e) {
162
+ loadErrors.push(e);
163
+ }
164
+ } else loadErrors.push(/* @__PURE__ */ Error(`Unsupported architecture on FreeBSD: ${process.arch}`));
165
+ else if (process.platform === "linux") if (process.arch === "x64") if (isMusl()) {
166
+ try {
167
+ return require("./oxlint.linux-x64-musl.node");
168
+ } catch (e) {
169
+ loadErrors.push(e);
170
+ }
171
+ try {
172
+ let binding = require("@oxlint/linux-x64-musl"), bindingPackageVersion = require("@oxlint/linux-x64-musl/package.json").version;
173
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
174
+ return binding;
175
+ } catch (e) {
176
+ loadErrors.push(e);
177
+ }
178
+ } else {
179
+ try {
180
+ return require("./oxlint.linux-x64-gnu.node");
181
+ } catch (e) {
182
+ loadErrors.push(e);
183
+ }
184
+ try {
185
+ let binding = require("@oxlint/linux-x64-gnu"), bindingPackageVersion = require("@oxlint/linux-x64-gnu/package.json").version;
186
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
187
+ return binding;
188
+ } catch (e) {
189
+ loadErrors.push(e);
190
+ }
191
+ }
192
+ else if (process.arch === "arm64") if (isMusl()) {
193
+ try {
194
+ return require("./oxlint.linux-arm64-musl.node");
195
+ } catch (e) {
196
+ loadErrors.push(e);
197
+ }
198
+ try {
199
+ let binding = require("@oxlint/linux-arm64-musl"), bindingPackageVersion = require("@oxlint/linux-arm64-musl/package.json").version;
200
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
201
+ return binding;
202
+ } catch (e) {
203
+ loadErrors.push(e);
204
+ }
205
+ } else {
206
+ try {
207
+ return require("./oxlint.linux-arm64-gnu.node");
208
+ } catch (e) {
209
+ loadErrors.push(e);
210
+ }
211
+ try {
212
+ let binding = require("@oxlint/linux-arm64-gnu"), bindingPackageVersion = require("@oxlint/linux-arm64-gnu/package.json").version;
213
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
214
+ return binding;
215
+ } catch (e) {
216
+ loadErrors.push(e);
217
+ }
218
+ }
219
+ else if (process.arch === "arm") if (isMusl()) {
220
+ try {
221
+ return require("./oxlint.linux-arm-musleabihf.node");
222
+ } catch (e) {
223
+ loadErrors.push(e);
224
+ }
225
+ try {
226
+ let binding = require("@oxlint/linux-arm-musleabihf"), bindingPackageVersion = require("@oxlint/linux-arm-musleabihf/package.json").version;
227
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
228
+ return binding;
229
+ } catch (e) {
230
+ loadErrors.push(e);
231
+ }
232
+ } else {
233
+ try {
234
+ return require("./oxlint.linux-arm-gnueabihf.node");
235
+ } catch (e) {
236
+ loadErrors.push(e);
237
+ }
238
+ try {
239
+ let binding = require("@oxlint/linux-arm-gnueabihf"), bindingPackageVersion = require("@oxlint/linux-arm-gnueabihf/package.json").version;
240
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
241
+ return binding;
242
+ } catch (e) {
243
+ loadErrors.push(e);
244
+ }
245
+ }
246
+ else if (process.arch === "loong64") if (isMusl()) {
247
+ try {
248
+ return require("./oxlint.linux-loong64-musl.node");
249
+ } catch (e) {
250
+ loadErrors.push(e);
251
+ }
252
+ try {
253
+ let binding = require("@oxlint/linux-loong64-musl"), bindingPackageVersion = require("@oxlint/linux-loong64-musl/package.json").version;
254
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
255
+ return binding;
256
+ } catch (e) {
257
+ loadErrors.push(e);
258
+ }
259
+ } else {
260
+ try {
261
+ return require("./oxlint.linux-loong64-gnu.node");
262
+ } catch (e) {
263
+ loadErrors.push(e);
264
+ }
265
+ try {
266
+ let binding = require("@oxlint/linux-loong64-gnu"), bindingPackageVersion = require("@oxlint/linux-loong64-gnu/package.json").version;
267
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
268
+ return binding;
269
+ } catch (e) {
270
+ loadErrors.push(e);
271
+ }
272
+ }
273
+ else if (process.arch === "riscv64") if (isMusl()) {
274
+ try {
275
+ return require("./oxlint.linux-riscv64-musl.node");
276
+ } catch (e) {
277
+ loadErrors.push(e);
278
+ }
279
+ try {
280
+ let binding = require("@oxlint/linux-riscv64-musl"), bindingPackageVersion = require("@oxlint/linux-riscv64-musl/package.json").version;
281
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
282
+ return binding;
283
+ } catch (e) {
284
+ loadErrors.push(e);
285
+ }
286
+ } else {
287
+ try {
288
+ return require("./oxlint.linux-riscv64-gnu.node");
289
+ } catch (e) {
290
+ loadErrors.push(e);
291
+ }
292
+ try {
293
+ let binding = require("@oxlint/linux-riscv64-gnu"), bindingPackageVersion = require("@oxlint/linux-riscv64-gnu/package.json").version;
294
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
295
+ return binding;
296
+ } catch (e) {
297
+ loadErrors.push(e);
298
+ }
299
+ }
300
+ else if (process.arch === "ppc64") {
301
+ try {
302
+ return require("./oxlint.linux-ppc64-gnu.node");
303
+ } catch (e) {
304
+ loadErrors.push(e);
305
+ }
306
+ try {
307
+ let binding = require("@oxlint/linux-ppc64-gnu"), bindingPackageVersion = require("@oxlint/linux-ppc64-gnu/package.json").version;
308
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
309
+ return binding;
310
+ } catch (e) {
311
+ loadErrors.push(e);
312
+ }
313
+ } else if (process.arch === "s390x") {
314
+ try {
315
+ return require("./oxlint.linux-s390x-gnu.node");
316
+ } catch (e) {
317
+ loadErrors.push(e);
318
+ }
319
+ try {
320
+ let binding = require("@oxlint/linux-s390x-gnu"), bindingPackageVersion = require("@oxlint/linux-s390x-gnu/package.json").version;
321
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
322
+ return binding;
323
+ } catch (e) {
324
+ loadErrors.push(e);
325
+ }
326
+ } else loadErrors.push(/* @__PURE__ */ Error(`Unsupported architecture on Linux: ${process.arch}`));
327
+ else if (process.platform === "openharmony") if (process.arch === "arm64") {
328
+ try {
329
+ return require("./oxlint.openharmony-arm64.node");
330
+ } catch (e) {
331
+ loadErrors.push(e);
332
+ }
333
+ try {
334
+ let binding = require("@oxlint/openharmony-arm64"), bindingPackageVersion = require("@oxlint/openharmony-arm64/package.json").version;
335
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
336
+ return binding;
337
+ } catch (e) {
338
+ loadErrors.push(e);
339
+ }
340
+ } else if (process.arch === "x64") {
341
+ try {
342
+ return require("./oxlint.openharmony-x64.node");
343
+ } catch (e) {
344
+ loadErrors.push(e);
345
+ }
346
+ try {
347
+ let binding = require("@oxlint/openharmony-x64"), bindingPackageVersion = require("@oxlint/openharmony-x64/package.json").version;
348
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
349
+ return binding;
350
+ } catch (e) {
351
+ loadErrors.push(e);
352
+ }
353
+ } else if (process.arch === "arm") {
354
+ try {
355
+ return require("./oxlint.openharmony-arm.node");
356
+ } catch (e) {
357
+ loadErrors.push(e);
358
+ }
359
+ try {
360
+ let binding = require("@oxlint/openharmony-arm"), bindingPackageVersion = require("@oxlint/openharmony-arm/package.json").version;
361
+ if (bindingPackageVersion !== "1.17.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw Error(`Native binding package version mismatch, expected 1.17.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
362
+ return binding;
363
+ } catch (e) {
364
+ loadErrors.push(e);
365
+ }
366
+ } else loadErrors.push(/* @__PURE__ */ Error(`Unsupported architecture on OpenHarmony: ${process.arch}`));
367
+ else loadErrors.push(/* @__PURE__ */ Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`));
368
+ }
369
+ if (nativeBinding = requireNative(), !nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
370
+ let wasiBinding = null, wasiBindingError = null;
371
+ try {
372
+ wasiBinding = require("./oxlint.wasi.cjs"), nativeBinding = wasiBinding;
373
+ } catch (err) {
374
+ process.env.NAPI_RS_FORCE_WASI && (wasiBindingError = err);
375
+ }
376
+ if (!nativeBinding) try {
377
+ wasiBinding = require("@oxlint/wasm32-wasi"), nativeBinding = wasiBinding;
378
+ } catch (err) {
379
+ process.env.NAPI_RS_FORCE_WASI && (wasiBindingError.cause = err, loadErrors.push(err));
380
+ }
381
+ if (process.env.NAPI_RS_FORCE_WASI === "error" && !wasiBinding) {
382
+ let error = /* @__PURE__ */ Error("WASI binding not found and NAPI_RS_FORCE_WASI is set to error");
383
+ throw error.cause = wasiBindingError, error;
384
+ }
385
+ }
386
+ if (!nativeBinding) throw loadErrors.length > 0 ? Error("Cannot find native binding. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both package-lock.json and node_modules directory.", { cause: loadErrors.reduce((err, cur) => (cur.cause = err, cur)) }) : Error("Failed to load native binding");
387
+ const { lint } = nativeBinding;
388
+ let loadPlugin = null, lintFile = null;
389
+ function loadPluginWrapper(path) {
390
+ if (loadPlugin === null) {
391
+ let require$1 = createRequire(import.meta.url);
392
+ ({loadPlugin, lintFile} = require$1("./plugins/index.js"));
393
+ }
394
+ return loadPlugin(path);
395
+ }
396
+ function lintFileWrapper(filePath, bufferId, buffer, ruleIds) {
397
+ return lintFile(filePath, bufferId, buffer, ruleIds);
398
+ }
399
+ await lint(loadPluginWrapper, lintFileWrapper) || (process.exitCode = 1);
400
+ export {};