@ohos-rs/oxk 0.4.0 → 0.5.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/README.md CHANGED
@@ -1,31 +1,133 @@
1
1
  # `@ohos-rs/oxk`
2
2
 
3
- > This is forked from [package-template-pnpm](https://github.com/napi-rs/package-template-pnpm).
3
+ ArkTS/ArkUI parser, formatter, and lint tooling based on OXC and oxlint.
4
4
 
5
- ## Usage
6
-
7
- Install with npm
5
+ ## Install
8
6
 
9
7
  ```bash
10
8
  npm install @ohos-rs/oxk
11
9
  ```
12
10
 
13
- ### Run with cli
11
+ For CLI usage, install it in your project and run it through your package
12
+ manager, or install it globally:
14
13
 
15
14
  ```bash
16
- oxk format xxx.ets
15
+ npm install -g @ohos-rs/oxk
16
+ oxk --help
17
17
  ```
18
18
 
19
- ### Run with code
19
+ The npm package requires Node.js `^20.19.0 || >=22.18.0`.
20
+
21
+ ## Format
22
+
23
+ ```bash
24
+ oxk format src/index.ets
25
+ oxk format "src/**/*.{ts,ets}"
26
+ ```
27
+
28
+ Formatter config is loaded from `.oxfmtrc.json` or `.oxfmtrc.jsonc`.
29
+
30
+ ## Lint
31
+
32
+ ```bash
33
+ oxk lint src --threads 1
34
+ oxk lint src/index.ets --format json
35
+ oxk lint --config .oxlintrc.jsonc "src/**/*.ets"
36
+ ```
37
+
38
+ `oxk lint` embeds `oxlint::CliRunner`; it does not shell out to an external
39
+ `oxlint` binary. The npm CLI includes the oxlint JavaScript runtime for:
40
+
41
+ - `.oxlintrc.json` and `.oxlintrc.jsonc`
42
+ - `oxlint.config.ts`
43
+ - oxlint built-in plugin configuration, such as `plugins: ["react"]`
44
+ - JavaScript plugins configured with `jsPlugins`
45
+ - plugin settings and globals
46
+
47
+ The cargo CLI keeps a pure Rust runner. Use JSON or JSONC config files there;
48
+ the JavaScript runtime and `oxlint.config.ts` are npm-only.
20
49
 
21
- Using napi-native module format.
50
+ ## ArkTS Rules
51
+
52
+ ArkTS migration rules are built in as the virtual `arkts` plugin. See
53
+ [Built-in Lint](../../crates/lint/README.md) for the rule list, configuration
54
+ examples, `arkts/system-api-version`, and the SDK sync workflow.
55
+
56
+ Example:
57
+
58
+ ```ts
59
+ // index.ets
60
+ const key = Symbol('id')
61
+ let marker: symbol
62
+ ```
63
+
64
+ ```bash
65
+ oxk lint index.ets --threads 1 --format json
66
+ ```
67
+
68
+ ## JavaScript API
69
+
70
+ Use the formatter wrapper:
22
71
 
23
72
  ```js
24
- const oxk = require('@ohos-rs/oxk')
73
+ const { format } = require('@ohos-rs/oxk/format')
25
74
  ```
26
75
 
27
- Using wrapper module format.
76
+ Use the lint wrapper with oxlint-compatible CLI arguments:
28
77
 
29
78
  ```js
30
- const oxk = require('@ohos-rs/oxk/format')
79
+ const { lint } = require('@ohos-rs/oxk/lint')
80
+
81
+ const ok = await lint(['src/index.ets', '--threads', '1'])
82
+ process.exitCode = ok ? 0 : 1
83
+ ```
84
+
85
+ The native module is also available from the package root:
86
+
87
+ ```js
88
+ const oxk = require('@ohos-rs/oxk')
89
+ ```
90
+
91
+ For linting from JavaScript, prefer `@ohos-rs/oxk/lint`; it wires the oxlint JS
92
+ runtime callbacks for plugins and JavaScript config files.
93
+
94
+ ## WASI
95
+
96
+ Build the WASI artifact locally:
97
+
98
+ ```bash
99
+ pnpm build --target wasm32-wasip1-threads
100
+ pnpm run test:wasi
101
+ ```
102
+
103
+ `test:wasi` forces `NAPI_RS_FORCE_WASI=1` and verifies the generated WASI
104
+ binding can load and execute `parse` and `format`. Linting is intentionally not
105
+ available from the WASI build because the oxlint runner and JavaScript plugin
106
+ runtime are native-only; use the native npm package or cargo CLI for linting.
107
+
108
+ ## Local Development
109
+
110
+ Build the local NAPI binary before running npm CLI tests:
111
+
112
+ ```bash
113
+ pnpm --filter @ohos-rs/oxk run build:debug
114
+ pnpm --filter @ohos-rs/oxk test
115
+ pnpm --filter @ohos-rs/oxk run build --target wasm32-wasip1-threads
116
+ pnpm --filter @ohos-rs/oxk run test:wasi
117
+ ```
118
+
119
+ Update the bundled oxlint JavaScript runtime after changing the upstream source
120
+ or dependency versions:
121
+
122
+ ```bash
123
+ pnpm --filter @ohos-rs/oxk run build:oxlint-runtime
124
+ ```
125
+
126
+ Run the Rust checks:
127
+
128
+ ```bash
129
+ cargo check -p lint -p oxk
130
+ cargo check -p oxk-napi
131
+ cargo test -p lint -p oxk
132
+ git diff --check
31
133
  ```
package/bin/format.js CHANGED
@@ -2,7 +2,7 @@ const { existsSync, readFileSync, writeFileSync } = require('node:fs')
2
2
  const path = require('node:path')
3
3
  const { glob } = require('glob')
4
4
 
5
- const { format } = require('../index.js')
5
+ const { format } = require('../format.js')
6
6
 
7
7
  const CONFIG_FILES = ['.oxfmtrc.json', '.oxfmtrc.jsonc']
8
8
  const RECOVERABLE_ERROR_PATTERNS = [
package/bin/oxk.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  const VERSION = require('../package.json').version
4
4
  const { formatFiles } = require('./format.js')
5
+ const { lint } = require('../lint.js')
5
6
 
6
7
  function parseBoolean(value, flagName) {
7
8
  if (value === 'true') {
@@ -43,11 +44,16 @@ Usage:
43
44
 
44
45
  Commands:
45
46
  format Format files
47
+ lint Lint files
46
48
 
47
49
  Global Options:
48
50
  --help, -h Show help
49
51
  --version, -v Show version
50
52
 
53
+ Lint Options:
54
+ Supports oxlint-compatible options, configuration files, built-in plugins, and JS plugins.
55
+ Run "oxk lint --help" for the full lint option list.
56
+
51
57
  Format Options:
52
58
  --config PATH
53
59
  --thread, -t THREAD
@@ -72,6 +78,9 @@ Format Options:
72
78
  Examples:
73
79
  oxk format src/**/*.ets
74
80
  oxk format --exclude dist/** --config .oxfmtrc.json "src/**/*.{ts,ets}"
81
+ oxk lint src
82
+ oxk lint --config .oxlintrc.json --react-plugin "src/**/*.{ts,tsx,ets}"
83
+ oxk lint --config .oxlintrc.json "src/**/*.ets"
75
84
  `)
76
85
  }
77
86
 
@@ -268,13 +277,21 @@ async function main() {
268
277
  process.exit(0)
269
278
  }
270
279
 
271
- if (command !== 'format') {
280
+ if (command !== 'format' && command !== 'lint') {
272
281
  console.error(`Unknown command: ${command}`)
273
282
  console.error("Run 'oxk --help' for usage information")
274
283
  process.exit(1)
275
284
  }
276
285
 
277
286
  try {
287
+ if (command === 'lint') {
288
+ const success = await lint(args.slice(1))
289
+ if (!success) {
290
+ process.exit(1)
291
+ }
292
+ return
293
+ }
294
+
278
295
  const { help, formatArgs } = parseFormatArgs(args.slice(1))
279
296
  if (help) {
280
297
  showHelp()
package/index.d.ts CHANGED
@@ -7,6 +7,25 @@ export interface Comment {
7
7
  end: number
8
8
  }
9
9
 
10
+ export interface ErrorLabel {
11
+ message: string | null
12
+ start: number
13
+ end: number
14
+ }
15
+
16
+ export interface OxcError {
17
+ severity: Severity
18
+ message: string
19
+ labels: Array<ErrorLabel>
20
+ helpMessage: string | null
21
+ codeframe: string | null
22
+ }
23
+
24
+ export declare const enum Severity {
25
+ Error = 'Error',
26
+ Warning = 'Warning',
27
+ Advice = 'Advice'
28
+ }
10
29
  export interface DynamicImport {
11
30
  start: number
12
31
  end: number
@@ -26,12 +45,6 @@ export interface EcmaScriptModule {
26
45
  importMetas: Array<Span>
27
46
  }
28
47
 
29
- export interface ErrorLabel {
30
- message: string | null
31
- start: number
32
- end: number
33
- }
34
-
35
48
  export interface ExportExportName {
36
49
  kind: ExportExportNameKind
37
50
  name: string | null
@@ -78,6 +91,7 @@ export declare const enum ExportLocalNameKind {
78
91
  * This function supports multiple file types:
79
92
  * - JavaScript/TypeScript files (via oxc_formatter)
80
93
  * - TOML files (via oxc_toml)
94
+ * - JSON/JSON5/JSONC files (via native Rust formatters)
81
95
  * - Other files (via external formatter callbacks when napi feature is enabled)
82
96
  */
83
97
  export declare function format(filename: string, sourceText: string, options?: any | undefined | null, initExternalFormatterCb?: (numThreads: number) => Promise<string[]>, formatEmbeddedCb?: (options: Record<string, any>, tagName: string, code: string) => Promise<string>, formatFileCb?: (options: Record<string, any>, parserName: string, fileName: string, code: string) => Promise<string>): Promise<FormatResult>
@@ -102,13 +116,14 @@ export declare const enum ImportNameKind {
102
116
  Default = 'Default'
103
117
  }
104
118
 
105
- export interface OxcError {
106
- severity: Severity
107
- message: string
108
- labels: Array<ErrorLabel>
109
- helpMessage: string | null
110
- codeframe: string | null
111
- }
119
+ /** Run the oxlint-compatible linter. */
120
+ export declare function lint(args: Array<string>): Promise<boolean>
121
+
122
+ /** Run the oxlint-compatible linter synchronously. */
123
+ export declare function lintSync(args: Array<string>): boolean
124
+
125
+ /** Run the oxlint-compatible linter with JavaScript plugin callbacks. */
126
+ export declare function lintWithPlugins(args: Array<string>, loadPlugin: (arg0: string, arg1: string | undefined | null, arg2: boolean, arg3?: string | undefined | null) => Promise<string>, setupRuleConfigs: (arg: string) => string | null, lintFile: (arg0: string, arg1: number, arg2: Uint8Array | undefined | null, arg3: Array<number>, arg4: Array<number>, arg5: string, arg6: string, arg7?: string | undefined | null) => string | null, createWorkspace: (arg: string) => Promise<undefined>, destroyWorkspace: (arg: string) => void, loadJsConfigs: (arg: Array<string>) => Promise<string>): Promise<boolean>
112
127
 
113
128
  /** Parse JS/TS/ArkTS source text and return an ESTree-compatible AST. */
114
129
  export declare function parse(filename: string, sourceText: string, options?: ParserOptions | undefined | null): Promise<ParseResult>
@@ -136,12 +151,6 @@ export interface ParserOptions {
136
151
  showSemanticErrors?: boolean
137
152
  }
138
153
 
139
- export declare const enum Severity {
140
- Error = 'Error',
141
- Warning = 'Warning',
142
- Advice = 'Advice'
143
- }
144
-
145
154
  export interface Span {
146
155
  start: number
147
156
  end: number
package/index.js CHANGED
@@ -77,8 +77,8 @@ function requireNative() {
77
77
  try {
78
78
  const binding = require('@ohos-rs/oxk-android-arm64')
79
79
  const bindingPackageVersion = require('@ohos-rs/oxk-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
82
  }
83
83
  return binding
84
84
  } catch (e) {
@@ -93,8 +93,8 @@ function requireNative() {
93
93
  try {
94
94
  const binding = require('@ohos-rs/oxk-android-arm-eabi')
95
95
  const bindingPackageVersion = require('@ohos-rs/oxk-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
98
  }
99
99
  return binding
100
100
  } catch (e) {
@@ -114,8 +114,8 @@ function requireNative() {
114
114
  try {
115
115
  const binding = require('@ohos-rs/oxk-win32-x64-gnu')
116
116
  const bindingPackageVersion = require('@ohos-rs/oxk-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
119
  }
120
120
  return binding
121
121
  } catch (e) {
@@ -130,8 +130,8 @@ function requireNative() {
130
130
  try {
131
131
  const binding = require('@ohos-rs/oxk-win32-x64-msvc')
132
132
  const bindingPackageVersion = require('@ohos-rs/oxk-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
135
  }
136
136
  return binding
137
137
  } catch (e) {
@@ -147,8 +147,8 @@ function requireNative() {
147
147
  try {
148
148
  const binding = require('@ohos-rs/oxk-win32-ia32-msvc')
149
149
  const bindingPackageVersion = require('@ohos-rs/oxk-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
152
  }
153
153
  return binding
154
154
  } catch (e) {
@@ -163,8 +163,8 @@ function requireNative() {
163
163
  try {
164
164
  const binding = require('@ohos-rs/oxk-win32-arm64-msvc')
165
165
  const bindingPackageVersion = require('@ohos-rs/oxk-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
168
  }
169
169
  return binding
170
170
  } catch (e) {
@@ -182,8 +182,8 @@ function requireNative() {
182
182
  try {
183
183
  const binding = require('@ohos-rs/oxk-darwin-universal')
184
184
  const bindingPackageVersion = require('@ohos-rs/oxk-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
187
  }
188
188
  return binding
189
189
  } catch (e) {
@@ -198,8 +198,8 @@ function requireNative() {
198
198
  try {
199
199
  const binding = require('@ohos-rs/oxk-darwin-x64')
200
200
  const bindingPackageVersion = require('@ohos-rs/oxk-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
203
  }
204
204
  return binding
205
205
  } catch (e) {
@@ -214,8 +214,8 @@ function requireNative() {
214
214
  try {
215
215
  const binding = require('@ohos-rs/oxk-darwin-arm64')
216
216
  const bindingPackageVersion = require('@ohos-rs/oxk-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
219
  }
220
220
  return binding
221
221
  } catch (e) {
@@ -234,8 +234,8 @@ function requireNative() {
234
234
  try {
235
235
  const binding = require('@ohos-rs/oxk-freebsd-x64')
236
236
  const bindingPackageVersion = require('@ohos-rs/oxk-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
239
  }
240
240
  return binding
241
241
  } catch (e) {
@@ -250,8 +250,8 @@ function requireNative() {
250
250
  try {
251
251
  const binding = require('@ohos-rs/oxk-freebsd-arm64')
252
252
  const bindingPackageVersion = require('@ohos-rs/oxk-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
255
  }
256
256
  return binding
257
257
  } catch (e) {
@@ -271,8 +271,8 @@ function requireNative() {
271
271
  try {
272
272
  const binding = require('@ohos-rs/oxk-linux-x64-musl')
273
273
  const bindingPackageVersion = require('@ohos-rs/oxk-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
276
  }
277
277
  return binding
278
278
  } catch (e) {
@@ -287,8 +287,8 @@ function requireNative() {
287
287
  try {
288
288
  const binding = require('@ohos-rs/oxk-linux-x64-gnu')
289
289
  const bindingPackageVersion = require('@ohos-rs/oxk-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
292
  }
293
293
  return binding
294
294
  } catch (e) {
@@ -305,8 +305,8 @@ function requireNative() {
305
305
  try {
306
306
  const binding = require('@ohos-rs/oxk-linux-arm64-musl')
307
307
  const bindingPackageVersion = require('@ohos-rs/oxk-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
310
  }
311
311
  return binding
312
312
  } catch (e) {
@@ -321,8 +321,8 @@ function requireNative() {
321
321
  try {
322
322
  const binding = require('@ohos-rs/oxk-linux-arm64-gnu')
323
323
  const bindingPackageVersion = require('@ohos-rs/oxk-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
326
  }
327
327
  return binding
328
328
  } catch (e) {
@@ -339,8 +339,8 @@ function requireNative() {
339
339
  try {
340
340
  const binding = require('@ohos-rs/oxk-linux-arm-musleabihf')
341
341
  const bindingPackageVersion = require('@ohos-rs/oxk-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
344
  }
345
345
  return binding
346
346
  } catch (e) {
@@ -355,8 +355,8 @@ function requireNative() {
355
355
  try {
356
356
  const binding = require('@ohos-rs/oxk-linux-arm-gnueabihf')
357
357
  const bindingPackageVersion = require('@ohos-rs/oxk-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
360
  }
361
361
  return binding
362
362
  } catch (e) {
@@ -373,8 +373,8 @@ function requireNative() {
373
373
  try {
374
374
  const binding = require('@ohos-rs/oxk-linux-loong64-musl')
375
375
  const bindingPackageVersion = require('@ohos-rs/oxk-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
378
  }
379
379
  return binding
380
380
  } catch (e) {
@@ -389,8 +389,8 @@ function requireNative() {
389
389
  try {
390
390
  const binding = require('@ohos-rs/oxk-linux-loong64-gnu')
391
391
  const bindingPackageVersion = require('@ohos-rs/oxk-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
394
  }
395
395
  return binding
396
396
  } catch (e) {
@@ -407,8 +407,8 @@ function requireNative() {
407
407
  try {
408
408
  const binding = require('@ohos-rs/oxk-linux-riscv64-musl')
409
409
  const bindingPackageVersion = require('@ohos-rs/oxk-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
412
  }
413
413
  return binding
414
414
  } catch (e) {
@@ -423,8 +423,8 @@ function requireNative() {
423
423
  try {
424
424
  const binding = require('@ohos-rs/oxk-linux-riscv64-gnu')
425
425
  const bindingPackageVersion = require('@ohos-rs/oxk-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
428
  }
429
429
  return binding
430
430
  } catch (e) {
@@ -440,8 +440,8 @@ function requireNative() {
440
440
  try {
441
441
  const binding = require('@ohos-rs/oxk-linux-ppc64-gnu')
442
442
  const bindingPackageVersion = require('@ohos-rs/oxk-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
445
  }
446
446
  return binding
447
447
  } catch (e) {
@@ -456,8 +456,8 @@ function requireNative() {
456
456
  try {
457
457
  const binding = require('@ohos-rs/oxk-linux-s390x-gnu')
458
458
  const bindingPackageVersion = require('@ohos-rs/oxk-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
461
  }
462
462
  return binding
463
463
  } catch (e) {
@@ -476,8 +476,8 @@ function requireNative() {
476
476
  try {
477
477
  const binding = require('@ohos-rs/oxk-openharmony-arm64')
478
478
  const bindingPackageVersion = require('@ohos-rs/oxk-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
481
  }
482
482
  return binding
483
483
  } catch (e) {
@@ -492,8 +492,8 @@ function requireNative() {
492
492
  try {
493
493
  const binding = require('@ohos-rs/oxk-openharmony-x64')
494
494
  const bindingPackageVersion = require('@ohos-rs/oxk-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
497
  }
498
498
  return binding
499
499
  } catch (e) {
@@ -508,8 +508,8 @@ function requireNative() {
508
508
  try {
509
509
  const binding = require('@ohos-rs/oxk-openharmony-arm')
510
510
  const bindingPackageVersion = require('@ohos-rs/oxk-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '0.3.1-beta.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 0.3.1-beta.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '0.5.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 0.5.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -572,10 +572,13 @@ if (!nativeBinding) {
572
572
  }
573
573
 
574
574
  module.exports = nativeBinding
575
+ module.exports.Severity = nativeBinding.Severity
575
576
  module.exports.ExportExportNameKind = nativeBinding.ExportExportNameKind
576
577
  module.exports.ExportImportNameKind = nativeBinding.ExportImportNameKind
577
578
  module.exports.ExportLocalNameKind = nativeBinding.ExportLocalNameKind
578
579
  module.exports.format = nativeBinding.format
579
580
  module.exports.ImportNameKind = nativeBinding.ImportNameKind
581
+ module.exports.lint = nativeBinding.lint
582
+ module.exports.lintSync = nativeBinding.lintSync
583
+ module.exports.lintWithPlugins = nativeBinding.lintWithPlugins
580
584
  module.exports.parse = nativeBinding.parse
581
- module.exports.Severity = nativeBinding.Severity
package/lint.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function lint(args: Array<string>): Promise<boolean>