Skip to content

Commit 286e79f

Browse files
committed
feat(linter): convert oxlint to NAPI app
1 parent 265d6a6 commit 286e79f

File tree

100 files changed

+262
-424
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+262
-424
lines changed

.github/generated/ast_changes_watch_list.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
src:
55
- '.github/generated/ast_changes_watch_list.yml'
6+
- 'apps/oxlint/src-js/generated/constants.mjs'
7+
- 'apps/oxlint/src/generated/raw_transfer_constants.rs'
68
- 'crates/oxc_allocator/src/generated/assert_layouts.rs'
79
- 'crates/oxc_allocator/src/generated/fixed_size_constants.rs'
810
- 'crates/oxc_allocator/src/pool/fixed_size.rs'
@@ -64,8 +66,6 @@ src:
6466
- 'crates/oxc_syntax/src/serialize.rs'
6567
- 'crates/oxc_syntax/src/symbol.rs'
6668
- 'crates/oxc_traverse/src/generated/scopes_collector.rs'
67-
- 'napi/oxlint/src-js/generated/constants.mjs'
68-
- 'napi/oxlint/src/generated/raw_transfer_constants.rs'
6969
- 'napi/parser/generated/constants.mjs'
7070
- 'napi/parser/generated/deserialize/js.mjs'
7171
- 'napi/parser/generated/deserialize/ts.mjs'

.github/workflows/ci.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ jobs:
2626
save-cache: ${{ github.ref_name == 'main' }}
2727
cache-key: warm
2828
- run: cargo ck
29-
- run: cargo test --all-features
29+
- run: cargo test --workspace --all-features --exclude website
30+
- run: cargo test -p website # Run separately to avoid feature unification problems with `oxlint`
3031
- run: git diff --exit-code # Must commit everything
3132

3233
test-ubuntu-aarch64:
@@ -41,7 +42,8 @@ jobs:
4142
save-cache: ${{ github.ref_name == 'main' }}
4243
cache-key: warm-aarch64
4344
- run: cargo ck
44-
- run: cargo test --all-features
45+
- run: cargo test --workspace --all-features --exclude website
46+
- run: cargo test -p website # Run separately to avoid feature unification problems with `oxlint`
4547
- run: git diff --exit-code # Must commit everything
4648

4749
test-mac: # Separate job to save a job on PRs
@@ -56,7 +58,8 @@ jobs:
5658
save-cache: ${{ github.ref_name == 'main' }}
5759
cache-key: warm
5860
- run: cargo ck
59-
- run: cargo test --all-features
61+
- run: cargo test --workspace --all-features --exclude website
62+
- run: cargo test -p website # Run separately to avoid feature unification problems with `oxlint`
6063
- run: git diff --exit-code # Must commit everything
6164

6265
test-windows:
@@ -98,7 +101,12 @@ jobs:
98101
save-if: ${{ github.ref_name == 'main' }}
99102
shared-key: windows-latest
100103

101-
- run: cargo test --all-features # cargo ck # no need to `cargo ck` because it's already checked in linux
104+
- name: Run tests
105+
# No need for `cargo ck` because it's already checked in linux
106+
# Run `website` tests separately to avoid feature unification problems with `oxlint`
107+
run: |
108+
cargo test --workspace --all-features --exclude website
109+
cargo test -p website
102110
working-directory: ${{ env.DEV_DRIVE_WORKSPACE }}
103111
shell: bash
104112

@@ -114,7 +122,9 @@ jobs:
114122
save-cache: ${{ github.ref_name == 'main' }}
115123
cache-key: s390x-unknown-linux-gnu
116124
tools: cross
117-
- run: cross test --all-features --target s390x-unknown-linux-gnu
125+
- run: cross test --workspace --all-features --exclude website --target s390x-unknown-linux-gnu
126+
# Run separately to avoid feature unification problems with `oxlint`
127+
- run: cross test -p website --target s390x-unknown-linux-gnu
118128

119129
test-wasm32-wasip1-threads:
120130
name: Test wasm32-wasip1-threads

Cargo.lock

Lines changed: 3 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/oxlint/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
*.node
3+
dist/

apps/oxlint/Cargo.toml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ authors.workspace = true
55
categories.workspace = true
66
edition.workspace = true
77
homepage.workspace = true
8+
include = ["/src", "build.rs"]
89
keywords.workspace = true
910
license.workspace = true
1011
publish = false
@@ -16,16 +17,10 @@ description.workspace = true
1617
workspace = true
1718

1819
[lib]
19-
crate-type = ["lib"]
20+
crate-type = ["cdylib", "lib"]
2021
path = "src/lib.rs"
2122
doctest = false
2223

23-
[[bin]]
24-
name = "oxlint"
25-
path = "src/main.rs"
26-
test = false
27-
doctest = false
28-
2924
[dependencies]
3025
oxc_allocator = { workspace = true, features = ["fixed_size"] }
3126
oxc_diagnostics = { workspace = true }
@@ -36,13 +31,15 @@ bpaf = { workspace = true, features = ["autocomplete", "bright-color", "derive"]
3631
cow-utils = { workspace = true }
3732
ignore = { workspace = true, features = ["simd-accel"] }
3833
miette = { workspace = true }
39-
napi = { workspace = true }
34+
napi = { workspace = true, features = ["async"], optional = true }
35+
napi-derive = { workspace = true, optional = true }
4036
rayon = { workspace = true }
4137
rustc-hash = { workspace = true }
4238
serde = { workspace = true }
4339
serde_json = { workspace = true }
4440
simdutf8 = { workspace = true }
4541
tempfile = { workspace = true }
42+
tokio = { workspace = true, features = ["rt-multi-thread"] }
4643
tracing-subscriber = { workspace = true, features = [] } # Omit the `regex` feature
4744

4845
[target.'cfg(not(any(target_os = "linux", target_os = "freebsd", target_arch = "arm", target_family = "wasm")))'.dependencies]
@@ -54,11 +51,15 @@ mimalloc-safe = { workspace = true, optional = true, features = ["skip_collect_o
5451
[target.'cfg(all(target_os = "linux", target_arch = "aarch64"))'.dependencies]
5552
mimalloc-safe = { workspace = true, optional = true, features = ["skip_collect_on_exit", "local_dynamic_tls", "no_opt_arch"] }
5653

54+
[build-dependencies]
55+
napi-build = { workspace = true }
56+
5757
[dev-dependencies]
5858
insta = { workspace = true }
5959
lazy-regex = { workspace = true }
6060

6161
[features]
62-
default = []
62+
default = ["napi"]
63+
napi = ["dep:napi", "dep:napi-derive"]
6364
allocator = ["dep:mimalloc-safe"]
6465
force_test_reporter = ["oxc_linter/force_test_reporter"]
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,28 @@
1414
"test": "tsc && vitest --dir ./test run"
1515
},
1616
"engines": {
17-
"node": ">=20.0.0"
17+
"node": ">=8.*"
1818
},
19-
"description": "Staging package for oxlint while we integrate custom JS plugins into oxlint",
19+
"description": "Linter for the JavaScript Oxidation Compiler",
2020
"author": "Boshen and oxc contributors",
2121
"license": "MIT",
2222
"homepage": "https://oxc.rs",
2323
"bugs": "https://github.com/oxc-project/oxc/issues",
2424
"repository": {
2525
"type": "git",
2626
"url": "https://github.com/oxc-project/oxc.git",
27-
"directory": "napi/oxlint"
27+
"directory": "apps/oxlint"
2828
},
2929
"publishConfig": {
3030
"registry": "https://registry.npmjs.org/",
3131
"access": "public"
3232
},
3333
"files": [
34-
"dist"
34+
"dist",
35+
"bin/oxlint",
36+
"bin/oxc_language_server",
37+
"configuration_schema.json",
38+
"README.md"
3539
],
3640
"devDependencies": {
3741
"execa": "^9.6.0",
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import { join } from 'node:path';
44

55
const oxlintDirPath = join(import.meta.dirname, '..'),
66
distDirPath = join(oxlintDirPath, 'dist'),
7-
parserDirPath = join(oxlintDirPath, '../parser');
7+
parserDirPath = join(oxlintDirPath, '../../napi/parser');
88

99
// Build with tsdown
1010
console.log('Building with tsdown...');
1111
execSync('pnpm tsdown', { stdio: 'inherit', cwd: oxlintDirPath });
1212

13-
// Copy files from `napi/parser` to `napi/oxlint/dist`
13+
// Copy files from `napi/parser` to `apps/oxlint/dist`
1414
console.log('Copying files from parser...');
1515

1616
const parserFilePaths = [

0 commit comments

Comments
 (0)