mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
0db127cc16
# Oxlint ### 💥 BREAKING CHANGES -8c4552dlinter: [**BREAKING**] Split react/react-compiler into per-category rules (#25500) (Boshen) ### 🚀 Features -9b7394elinter/typescript/no-empty-object-type: Implement suggestion (#25833) (Mikhail Baev) ### 🐛 Bug Fixes -345f981react_compiler: Skip node_modules by default (#25859) (Boshen) -2f40afalinter/unicorn/no-array-callback-reference: Ignore effect library imports (#25857) (Michaël Bitard) -7b565a0linter: Align React Compiler rule categories (#25840) (Boshen) -228e8e0linter: Resolve inactive React compiler rules (#25830) (Boshen) -f8e4884linter/eslint/no-useless-constructor: Allow parameter properties (#25811) (camc314) -e4b6993linter: Report exhaustive effect dependencies (#25829) (Boshen) -742e25flinter/eslint/no-return-assign: Anchor diagnostic on return stmt (#25803) (camc314) -b831ca8react-compiler: Improve derived state diagnostic (#25804) (Boshen) -5908c87linter/jest/prefer-mock-return-shorthand: Preserve implementations using this (#25802) (camc314) -f6b2265linter/eslint/no-redeclare: Run in ES modules, skipping only the globals check (#25691) (Hamody We) -ca9f553linter/unicorn/prefer-default-parameters: Mark fixer as a suggestion (#25801) (camc314) -aa49d86linter: Allow spread rule options in config types (#25675) (ch3rry) -d5483f8linter/typescript/no-useless-empty-export: Skip TS declaration files (#25789) (Evyatar Daud) -57f2199linter/typescript/no-useless-empty-export: Report after imports (#25786) (camc314) -633bc19linter/typescript/no-unnecessary-type-conversion: Mark fixer as `suggestion` (#25787) (camc314) -dea3339linter/typescript/explicit-module-boundary-types: Anchor diagnostics on arrows (#25779) (camc314) -5cd6f02linter/eslint/array-callback-return: Anchor diagnostic on callback (#25780) (camc314) -ef8cebflinter/eslint/preserve-caught-error: Handle AggregateError options (#25775) (camc314) -c108d5clinter: Improve React Compiler diagnostics (#25742) (Boshen) -c9ec55ereact-compiler: Improve diagnostic spans (#25731) (Boshen) -1cbbcb7linter/unicorn/prefer-string-replace-all: Apply fixes in one pass (#25709) (Mikhail Baev) -dec0a86react-compiler: Standardize diagnostics (#25702) (Boshen) -5fd77f7linter/react/display-name: Report curried HOC inner component (#25662) (camc314) -4dbb80elinter/import/no-named-as-default: Report local export conflicts (#25658) (camc314) -e8a7214linter/react/rules-of-hooks: Report hooks inside try blocks (#25670) (camc314) -36f8451linter/eslint/no-eval: Align indirect default with ESLint (#25656) (camc314) -d901d24linter/react/exhaustive-deps: Handle destructured object dependencies (#25669) (camc314) -beb724dlinter/eslint/no-unused-vars: Report bare underscore parameters (#25663) (camc314) -fa36f26linter/react/no-this-in-sfc: Detect this in nested arrow callbacks (#25653) (camc314) -44d1be3linter/typescript/no-var-requires: Run rule on JavaScript (#25664) (camc314) -4004c10linter/eslint/no-irregular-whitespace: Check comments by default (#25660) (camc314) -625401dlinter/import/no-named-default: Flag type-only named defaults (#25661) (camc314) -8eacb2dlinter/typescript/no-non-null-asserted-optional-chain: Detect assertions after continued optional chains (#25659) (camc314) -d55b76clinter/react/no-direct-mutation-state: Detect computed state mutations (#25654) (camc314) -f92c651linter/unicorn/no-abusive-eslint-disable: Use directive prefix in diagnostic (#25657) (camc314) -ee44996linter/eslint/max-classes-per-file: Anchor diagnostic at program start (#25652) (camc314) -403ec40linter/eslint/no-multi-assign: Handle parenthesized declarator initializers (#25651) (camc314) -6c9ba37linter/jest/expect-expect: Detect assertions in nested function declarations (#25650) (camc314) -285820elinter/no-large-snapshots: Precompile and document allowed snapshot matchers (#25611) (Mikhail Baev) -1be1e20linter/eslint/prefer-promise-reject-errors: Report on spread arguments (#25648) (Mikhail Baev) -a38f7b3oxlint,oxfmt: Apply .gitignore only to walk targets, not explicitly named files (#25531) (leaysgur) -509931bsemantic: Classify global references per identifier (#25608) (camc314) -0c68b7festree: Emit `decorators` on `FormalParameterRest` (#25582) (camc314) -1d22912linter/plugins: Parse rule-less directive justifications (#25559) (camc314) -eaf80d8linter/unicorn/prefer-node-protocol: Validate exact Node.js built-in specifiers (#25558) (camc314) -57b94aflinter/promise/no-multiple-resolved: Ignore unresolved globals (#25530) (Tushar Singh) -80e64c2linter/expect-expect: Validate assertion regex (#25504) (Mikhail Baev) -7830604linter/react/exhaustive-deps: Treat binary expressions as a stable dependency (#25508) (Hamody We) -4df5835linter: Allow capitalized built-in calls (#25516) (Boshen) -9d49d27react_compiler: Bail out instead of panicking on "Expected a node for all scopes" (#25506) (Boshen) -d43b562linter/vitest/prefer-expect-assertions: Handle parameterized Vitest assertion suggestions (#25476) (camc314) ### ⚡ Performance -e8303d6linter: Shrink rule serialization dispatch (#25818) (Boshen) -c84ede3estree_tokens: Share JS token update entry point (#25826) (Boshen) -35c8eb2linter: Compute sort keys once with sort_by_cached_key (#25821) (Boshen) -f0121edlinter: Share config deserialization entry point (#25820) (Boshen) -2dacf7aoxlint: Reduce debug formatting code size (#25797) (Boshen) -9ed10b7linter: Use unstable sorts for unique keys (#25778) (Boshen) -63ff8eflinter: Outline diagnostic construction (#25762) (Boshen) -2dd7446diagnostics: Preallocate graphical output (#25721) (Boshen) -9c8ababdiagnostics: Batch graphical reports (#25710) (Boshen) -8e9b95flinter: Use table for rule names (#25458) (Boshen) # Oxfmt ### 🚀 Features -c07fe7coxfmt: Support `experimentalOperatorPosition` (#25643) (leaysgur) -2adb8fbformatter: Implement `operatorPosition` option (#25581) (leaysgur) ### 🐛 Bug Fixes -44231fbformatter: Fix comment and indent issues around unions (#25665) (leaysgur) -2465e87formatter: Keep comments in place when dropping `EmptyStatement` (#25730) (leaysgur) -7e4f3b7formatter: Print `JSDocUnknownType` (#25729) (leaysgur) -5238d9eformatter: Keep nested awaited-paren member chain grouped in call arguments (#25646) (leaysgur) -a38f7b3oxlint,oxfmt: Apply .gitignore only to walk targets, not explicitly named files (#25531) (leaysgur) -5c0a5ffformatter_css: Fill own-line block comments inside space-separated values (#25578) (leaysgur) -53debfaformatter_css: Keep trailing comma and indent after comment-preceded last map value (#25577) (leaysgur) -1a83a8doxfmt: Mirror printer line suppression and restore dedent-to-root (#25573) (leaysgur) -7f350d1formatter: Keep unary comment and print only needed parens (#25526) (leaysgur) -f405789formatter_yaml: Consistent chomped eos behavior (#25523) (leaysgur) -a243311formatter_yaml: Bump oxc-yaml-parser for contentless block scalar (#25519) (leaysgur) -40d38a0formatter_css: Keep multi value function args intact after leading comment (#25518) (leaysgur) ### 📚 Documentation -223e785oxfmt/conformance: Update notes on conformance (#25757) (Yuji Sugiura) -673dc6doxfmt: Move some docs from AGENTS.md to code comment (#25649) (leaysgur) -fed6681oxfmt: Skip expanding overrides options (#25572) (leaysgur) Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
713 lines
28 KiB
JavaScript
713 lines
28 KiB
JavaScript
// prettier-ignore
|
|
/* eslint-disable */
|
|
// @ts-nocheck
|
|
/* auto-generated by NAPI-RS */
|
|
|
|
import { createRequire } from 'module'
|
|
const require = createRequire(import.meta.url)
|
|
const __dirname = new URL('.', import.meta.url).pathname
|
|
|
|
const { readFileSync } = require('fs')
|
|
let nativeBinding = null
|
|
const loadErrors = []
|
|
|
|
const isMusl = () => {
|
|
let musl = false
|
|
if (process.platform === 'linux') {
|
|
musl = isMuslFromFilesystem()
|
|
if (musl === null) {
|
|
musl = isMuslFromReport()
|
|
}
|
|
if (musl === null) {
|
|
musl = isMuslFromChildProcess()
|
|
}
|
|
}
|
|
return musl
|
|
}
|
|
|
|
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
|
|
const isMuslFromFilesystem = () => {
|
|
try {
|
|
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
|
} catch {
|
|
return null
|
|
}
|
|
}
|
|
|
|
const isMuslFromReport = () => {
|
|
let report = null
|
|
if (process.report && typeof process.report.getReport === 'function') {
|
|
process.report.excludeNetwork = true
|
|
report = process.report.getReport()
|
|
}
|
|
if (!report) {
|
|
return null
|
|
}
|
|
if (report.header && report.header.glibcVersionRuntime) {
|
|
return false
|
|
}
|
|
if (Array.isArray(report.sharedObjects)) {
|
|
if (report.sharedObjects.some(isFileMusl)) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
const isMuslFromChildProcess = () => {
|
|
try {
|
|
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
|
} catch (e) {
|
|
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
return false
|
|
}
|
|
}
|
|
|
|
function requireNative() {
|
|
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
try {
|
|
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
|
} catch (err) {
|
|
loadErrors.push(err)
|
|
}
|
|
} else if (process.platform === 'android') {
|
|
if (process.arch === 'arm64') {
|
|
try {
|
|
return require('./oxlint.android-arm64.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-android-arm64')
|
|
const bindingPackageVersion = require('@oxlint/binding-android-arm64/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else if (process.arch === 'arm') {
|
|
try {
|
|
return require('./oxlint.android-arm-eabi.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-android-arm-eabi')
|
|
const bindingPackageVersion = require('@oxlint/binding-android-arm-eabi/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else {
|
|
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
|
}
|
|
} else if (process.platform === 'win32') {
|
|
if (process.arch === 'x64') {
|
|
if ((process.config && process.config.variables && process.config.variables.shlib_suffix === 'dll.a') || (process.config && process.config.variables && process.config.variables.node_target_type === 'shared_library')) {
|
|
try {
|
|
return require('./oxlint.win32-x64-gnu.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-win32-x64-gnu')
|
|
const bindingPackageVersion = require('@oxlint/binding-win32-x64-gnu/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else {
|
|
try {
|
|
return require('./oxlint.win32-x64-msvc.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-win32-x64-msvc')
|
|
const bindingPackageVersion = require('@oxlint/binding-win32-x64-msvc/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
}
|
|
} else if (process.arch === 'ia32') {
|
|
try {
|
|
return require('./oxlint.win32-ia32-msvc.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-win32-ia32-msvc')
|
|
const bindingPackageVersion = require('@oxlint/binding-win32-ia32-msvc/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else if (process.arch === 'arm64') {
|
|
try {
|
|
return require('./oxlint.win32-arm64-msvc.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-win32-arm64-msvc')
|
|
const bindingPackageVersion = require('@oxlint/binding-win32-arm64-msvc/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else {
|
|
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
|
}
|
|
} else if (process.platform === 'darwin') {
|
|
try {
|
|
return require('./oxlint.darwin-universal.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-darwin-universal')
|
|
const bindingPackageVersion = require('@oxlint/binding-darwin-universal/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
if (process.arch === 'x64') {
|
|
try {
|
|
return require('./oxlint.darwin-x64.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-darwin-x64')
|
|
const bindingPackageVersion = require('@oxlint/binding-darwin-x64/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else if (process.arch === 'arm64') {
|
|
try {
|
|
return require('./oxlint.darwin-arm64.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-darwin-arm64')
|
|
const bindingPackageVersion = require('@oxlint/binding-darwin-arm64/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else {
|
|
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
|
}
|
|
} else if (process.platform === 'freebsd') {
|
|
if (process.arch === 'x64') {
|
|
try {
|
|
return require('./oxlint.freebsd-x64.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-freebsd-x64')
|
|
const bindingPackageVersion = require('@oxlint/binding-freebsd-x64/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else if (process.arch === 'arm64') {
|
|
try {
|
|
return require('./oxlint.freebsd-arm64.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-freebsd-arm64')
|
|
const bindingPackageVersion = require('@oxlint/binding-freebsd-arm64/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else {
|
|
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
|
}
|
|
} else if (process.platform === 'linux') {
|
|
if (process.arch === 'x64') {
|
|
if (isMusl()) {
|
|
try {
|
|
return require('./oxlint.linux-x64-musl.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-linux-x64-musl')
|
|
const bindingPackageVersion = require('@oxlint/binding-linux-x64-musl/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else {
|
|
try {
|
|
return require('./oxlint.linux-x64-gnu.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-linux-x64-gnu')
|
|
const bindingPackageVersion = require('@oxlint/binding-linux-x64-gnu/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
}
|
|
} else if (process.arch === 'arm64') {
|
|
if (isMusl()) {
|
|
try {
|
|
return require('./oxlint.linux-arm64-musl.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-linux-arm64-musl')
|
|
const bindingPackageVersion = require('@oxlint/binding-linux-arm64-musl/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else {
|
|
try {
|
|
return require('./oxlint.linux-arm64-gnu.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-linux-arm64-gnu')
|
|
const bindingPackageVersion = require('@oxlint/binding-linux-arm64-gnu/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
}
|
|
} else if (process.arch === 'arm') {
|
|
if (isMusl()) {
|
|
try {
|
|
return require('./oxlint.linux-arm-musleabihf.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-linux-arm-musleabihf')
|
|
const bindingPackageVersion = require('@oxlint/binding-linux-arm-musleabihf/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else {
|
|
try {
|
|
return require('./oxlint.linux-arm-gnueabihf.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-linux-arm-gnueabihf')
|
|
const bindingPackageVersion = require('@oxlint/binding-linux-arm-gnueabihf/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
}
|
|
} else if (process.arch === 'loong64') {
|
|
if (isMusl()) {
|
|
try {
|
|
return require('./oxlint.linux-loong64-musl.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-linux-loong64-musl')
|
|
const bindingPackageVersion = require('@oxlint/binding-linux-loong64-musl/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else {
|
|
try {
|
|
return require('./oxlint.linux-loong64-gnu.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-linux-loong64-gnu')
|
|
const bindingPackageVersion = require('@oxlint/binding-linux-loong64-gnu/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
}
|
|
} else if (process.arch === 'riscv64') {
|
|
if (isMusl()) {
|
|
try {
|
|
return require('./oxlint.linux-riscv64-musl.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-linux-riscv64-musl')
|
|
const bindingPackageVersion = require('@oxlint/binding-linux-riscv64-musl/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else {
|
|
try {
|
|
return require('./oxlint.linux-riscv64-gnu.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-linux-riscv64-gnu')
|
|
const bindingPackageVersion = require('@oxlint/binding-linux-riscv64-gnu/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
}
|
|
} else if (process.arch === 'ppc64') {
|
|
try {
|
|
return require('./oxlint.linux-ppc64-gnu.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-linux-ppc64-gnu')
|
|
const bindingPackageVersion = require('@oxlint/binding-linux-ppc64-gnu/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else if (process.arch === 's390x') {
|
|
try {
|
|
return require('./oxlint.linux-s390x-gnu.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-linux-s390x-gnu')
|
|
const bindingPackageVersion = require('@oxlint/binding-linux-s390x-gnu/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else {
|
|
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
}
|
|
} else if (process.platform === 'openharmony') {
|
|
if (process.arch === 'arm64') {
|
|
try {
|
|
return require('./oxlint.openharmony-arm64.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-openharmony-arm64')
|
|
const bindingPackageVersion = require('@oxlint/binding-openharmony-arm64/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else if (process.arch === 'x64') {
|
|
try {
|
|
return require('./oxlint.openharmony-x64.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-openharmony-x64')
|
|
const bindingPackageVersion = require('@oxlint/binding-openharmony-x64/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else if (process.arch === 'arm') {
|
|
try {
|
|
return require('./oxlint.openharmony-arm.node')
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
try {
|
|
const binding = require('@oxlint/binding-openharmony-arm')
|
|
const bindingPackageVersion = require('@oxlint/binding-openharmony-arm/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
throw new Error(`Native binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
return binding
|
|
} catch (e) {
|
|
loadErrors.push(e)
|
|
}
|
|
} else {
|
|
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
|
|
}
|
|
} else {
|
|
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
}
|
|
}
|
|
|
|
function createLoadErrorChain(errors) {
|
|
return errors.reduce((previous, current) => {
|
|
let message
|
|
try {
|
|
message =
|
|
current && typeof current.message === 'string'
|
|
? current.message
|
|
: String(current)
|
|
} catch {
|
|
message = 'Unknown error'
|
|
}
|
|
const error = new Error(message)
|
|
error.cause = previous
|
|
return error
|
|
}, null)
|
|
}
|
|
|
|
// NAPI_RS_FORCE_WASI is a tri-state flag:
|
|
// unset / any other value → native binding preferred, WASI is only a fallback
|
|
// 'true' → prefer WASI, but retain native as a lazy fallback
|
|
// 'error' → require WASI without initializing a native fallback
|
|
// Treating any non-empty string as truthy (the historical behavior) meant
|
|
// NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
|
|
// the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
|
|
//
|
|
// NAPI_RS_WASI_FLAVOR selects one exact generated flavor and implies strict
|
|
// WASI loading. It never crosses into another flavor or falls back to native.
|
|
const __napiWasiFlavors = ["wasm32-wasi"]
|
|
const __napiWasiFlavor = process.env.NAPI_RS_WASI_FLAVOR
|
|
const __napiWasiFlavorRequested =
|
|
typeof __napiWasiFlavor === 'string' && __napiWasiFlavor.length > 0
|
|
if (
|
|
__napiWasiFlavorRequested &&
|
|
__napiWasiFlavors.indexOf(__napiWasiFlavor) === -1
|
|
) {
|
|
throw new Error(
|
|
'Unsupported WASI flavor "' +
|
|
__napiWasiFlavor +
|
|
'". Available flavors: ' +
|
|
__napiWasiFlavors.join(', '),
|
|
)
|
|
}
|
|
const forceWasiError = process.env.NAPI_RS_FORCE_WASI === 'error'
|
|
const forceWasi =
|
|
process.env.NAPI_RS_FORCE_WASI === 'true' ||
|
|
forceWasiError ||
|
|
__napiWasiFlavorRequested
|
|
|
|
if (!forceWasi) {
|
|
nativeBinding = requireNative()
|
|
}
|
|
|
|
if (!nativeBinding || forceWasi) {
|
|
let wasiBinding = null
|
|
let wasiBindingLoaded = false
|
|
const wasiBindingErrors = []
|
|
const __napiWasiResolveCandidate = (specifier, isPackage, localArtifacts) => {
|
|
try {
|
|
require.resolve(specifier)
|
|
} catch (resolveError) {
|
|
if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
|
|
throw resolveError
|
|
}
|
|
if (isPackage) {
|
|
try {
|
|
require.resolve(specifier + '/package.json')
|
|
} catch (packageError) {
|
|
if (packageError && packageError.code === 'MODULE_NOT_FOUND') {
|
|
return resolveError
|
|
}
|
|
// An exports restriction proves the package exists even when its
|
|
// package.json is not public. Preserve the root resolution failure.
|
|
throw resolveError
|
|
}
|
|
// The package exists but its main/export target is broken.
|
|
throw resolveError
|
|
}
|
|
return resolveError
|
|
}
|
|
if (localArtifacts) {
|
|
let artifactError = null
|
|
for (let i = 0; i < localArtifacts.length; i++) {
|
|
try {
|
|
require.resolve(localArtifacts[i])
|
|
return null
|
|
} catch (resolveError) {
|
|
if (!resolveError || resolveError.code !== 'MODULE_NOT_FOUND') {
|
|
throw resolveError
|
|
}
|
|
artifactError = resolveError
|
|
}
|
|
}
|
|
return artifactError
|
|
}
|
|
return null
|
|
}
|
|
if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) {
|
|
let candidateError = null
|
|
let candidateFailed = false
|
|
try {
|
|
candidateError = __napiWasiResolveCandidate('./oxlint.wasi.cjs', false, ["./oxlint.wasm32-wasi.debug.wasm","./oxlint.wasm32-wasi.wasm"])
|
|
candidateFailed = candidateError !== null
|
|
if (!candidateFailed) {
|
|
wasiBinding = require('./oxlint.wasi.cjs')
|
|
nativeBinding = wasiBinding
|
|
wasiBindingLoaded = true
|
|
}
|
|
} catch (err) {
|
|
candidateError = err
|
|
candidateFailed = true
|
|
}
|
|
if (candidateFailed) {
|
|
wasiBindingErrors.push(candidateError)
|
|
loadErrors.push(candidateError)
|
|
}
|
|
}
|
|
if (!wasiBindingLoaded && (!__napiWasiFlavorRequested || __napiWasiFlavor === "wasm32-wasi")) {
|
|
let candidateError = null
|
|
let candidateFailed = false
|
|
try {
|
|
candidateError = __napiWasiResolveCandidate('@oxlint/binding-wasm32-wasi', true, undefined)
|
|
candidateFailed = candidateError !== null
|
|
if (!candidateFailed) {
|
|
if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
const bindingPackageVersion = require('@oxlint/binding-wasm32-wasi/package.json').version
|
|
if (bindingPackageVersion !== '1.79.0') {
|
|
throw new Error(`WASI binding package version mismatch, expected 1.79.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
}
|
|
}
|
|
wasiBinding = require('@oxlint/binding-wasm32-wasi')
|
|
nativeBinding = wasiBinding
|
|
wasiBindingLoaded = true
|
|
}
|
|
} catch (err) {
|
|
candidateError = err
|
|
candidateFailed = true
|
|
}
|
|
if (candidateFailed) {
|
|
wasiBindingErrors.push(candidateError)
|
|
loadErrors.push(candidateError)
|
|
}
|
|
}
|
|
if (
|
|
!wasiBindingLoaded &&
|
|
forceWasi &&
|
|
!forceWasiError &&
|
|
!__napiWasiFlavorRequested
|
|
) {
|
|
nativeBinding = requireNative()
|
|
}
|
|
if ((forceWasiError || __napiWasiFlavorRequested) && !wasiBindingLoaded) {
|
|
const error = new Error(
|
|
__napiWasiFlavorRequested
|
|
? 'WASI binding for flavor "' + __napiWasiFlavor + '" not found'
|
|
: 'WASI binding not found and NAPI_RS_FORCE_WASI is set to error',
|
|
)
|
|
error.cause = createLoadErrorChain(wasiBindingErrors)
|
|
throw error
|
|
}
|
|
}
|
|
|
|
if (!nativeBinding) {
|
|
if (loadErrors.length > 0) {
|
|
const error = new 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.',
|
|
)
|
|
// assign instead of the `new Error(message, { cause })` options form,
|
|
// which Node < 16.9 silently ignores
|
|
error.cause = createLoadErrorChain(loadErrors)
|
|
throw error
|
|
}
|
|
throw new Error(`Failed to load native binding`)
|
|
}
|
|
|
|
const { Severity, applyFixes, getBufferOffset, lint, parseRawSync, rawTransferSupported } = nativeBinding
|
|
export { Severity }
|
|
export { applyFixes }
|
|
export { getBufferOffset }
|
|
export { lint }
|
|
export { parseRawSync }
|
|
export { rawTransferSupported }
|