Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/generated/ast_changes_watch_list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

src:
- '.github/generated/ast_changes_watch_list.yml'
- 'apps/oxlint/src-js/generated/constants.mjs'
- 'apps/oxlint/src/generated/raw_transfer_constants.rs'
- 'crates/oxc_allocator/src/generated/assert_layouts.rs'
- 'crates/oxc_allocator/src/generated/fixed_size_constants.rs'
- 'crates/oxc_allocator/src/pool/fixed_size.rs'
Expand Down Expand Up @@ -64,8 +66,6 @@ src:
- 'crates/oxc_syntax/src/serialize.rs'
- 'crates/oxc_syntax/src/symbol.rs'
- 'crates/oxc_traverse/src/generated/scopes_collector.rs'
- 'napi/oxlint/src-js/generated/constants.mjs'
- 'napi/oxlint/src/generated/raw_transfer_constants.rs'
- 'napi/parser/generated/constants.mjs'
- 'napi/parser/generated/deserialize/js.mjs'
- 'napi/parser/generated/deserialize/ts.mjs'
Expand Down
20 changes: 15 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ jobs:
save-cache: ${{ github.ref_name == 'main' }}
cache-key: warm
- run: cargo ck
- run: cargo test --all-features
- run: cargo test --workspace --all-features --exclude website
- run: cargo test -p website # Run separately to avoid feature unification problems with `oxlint`
- run: git diff --exit-code # Must commit everything

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

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

test-windows:
Expand Down Expand Up @@ -98,7 +101,12 @@ jobs:
save-if: ${{ github.ref_name == 'main' }}
shared-key: windows-latest

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

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

test-wasm32-wasip1-threads:
name: Test wasm32-wasip1-threads
Expand Down
48 changes: 37 additions & 11 deletions .github/workflows/release_oxlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,34 +48,42 @@ jobs:
- os: windows-latest
target: x86_64-pc-windows-msvc
code-target: win32-x64
build-oxlint: pnpm run build-napi-release --target x86_64-pc-windows-msvc

- os: windows-latest
target: aarch64-pc-windows-msvc
code-target: win32-arm64
build-oxlint: pnpm run build-napi-release --target aarch64-pc-windows-msvc

- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
code-target: linux-x64-gnu
build-oxlint: pnpm run build-napi-release --target x86_64-unknown-linux-gnu --use-napi-cross

- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
code-target: linux-arm64-gnu
build-oxlint: pnpm run build-napi-release --target aarch64-unknown-linux-gnu --use-napi-cross

- os: ubuntu-latest
target: x86_64-unknown-linux-musl
code-target: linux-x64-musl
build-oxlint: pnpm run build-napi-release --target x86_64-unknown-linux-musl -x

- os: ubuntu-latest
target: aarch64-unknown-linux-musl
code-target: linux-arm64-musl
build-oxlint: pnpm run build-napi-release --target aarch64-unknown-linux-musl -x

- os: macos-latest
target: x86_64-apple-darwin
code-target: darwin-x64
build-oxlint: pnpm run build-napi-release --target x86_64-apple-darwin

- os: macos-latest
target: aarch64-apple-darwin
code-target: darwin-arm64
build-oxlint: pnpm run build-napi-release --target aarch64-apple-darwin

name: Package ${{ matrix.code-target }}
runs-on: ${{ matrix.os }}
Expand All @@ -100,21 +108,35 @@ jobs:
- name: Add Rust Target
run: rustup target add ${{ matrix.target }}

- name: Build
- uses: oxc-project/setup-node@f42e3bda950c7454575e78ee4eaac880a077700c # v1.0.0

- uses: goto-bus-stop/setup-zig@abea47f85e598557f500fa1fd2ab7464fcb39406 # v2.2.1
if: ${{ contains(matrix.target, 'musl') }}
with:
version: 0.13.0

- name: Build oxlint
working-directory: apps/oxlint
run: ${{ matrix.build-oxlint }} --features allocator
shell: bash
env:
TARGET_CC: clang # for mimalloc
run: |
cross build --release -p oxlint --bin oxlint --features allocator --target=${{ matrix.target }}
cross build --release -p oxc_language_server --bin oxc_language_server --target=${{ matrix.target }}

- name: Build language server
shell: bash
env:
TARGET_CC: clang # for mimalloc
run: cross build --release -p oxc_language_server --bin oxc_language_server --target=${{ matrix.target }}

# The binaries are zipped to fix permission loss https://github.com/actions/upload-artifact#permission-loss
- name: Archive Binaries
if: runner.os == 'Windows'
# Windows `.node` files have `-msvc` postfix e.g. `oxlint.win32-x64-msvc.node`. Remove the postfix.
run: |
OXLINT_BIN_NAME=oxlint-${{ matrix.code-target }}
mv target/${{ matrix.target }}/release/oxlint.exe $OXLINT_BIN_NAME.exe
7z a $OXLINT_BIN_NAME.zip $OXLINT_BIN_NAME.exe
OXLINT_BIN_SRC_NAME=oxlint.${{ matrix.code-target }}-msvc.node
OXLINT_BIN_NAME=oxlint.${{ matrix.code-target }}.node
mv apps/oxlint/src-js/$OXLINT_BIN_SRC_NAME $OXLINT_BIN_NAME
7z a oxlint-${{ matrix.code-target }}.zip $OXLINT_BIN_NAME

OXLS_BIN_NAME=oxc_language_server-${{ matrix.code-target }}
mv target/${{ matrix.target }}/release/oxc_language_server.exe $OXLS_BIN_NAME.exe
Expand All @@ -124,9 +146,9 @@ jobs:
- name: Archive Binaries
if: runner.os != 'Windows'
run: |
OXLINT_BIN_NAME=oxlint-${{ matrix.code-target }}
mv target/${{ matrix.target }}/release/oxlint $OXLINT_BIN_NAME
tar czf $OXLINT_BIN_NAME.tar.gz $OXLINT_BIN_NAME
OXLINT_BIN_NAME=oxlint.${{ matrix.code-target }}.node
mv apps/oxlint/src-js/$OXLINT_BIN_NAME .
tar czf oxlint-${{ matrix.code-target }}.tar.gz $OXLINT_BIN_NAME

OXLS_BIN_NAME=oxc_language_server-${{ matrix.code-target }}
mv target/${{ matrix.target }}/release/oxc_language_server $OXLS_BIN_NAME
Expand Down Expand Up @@ -184,6 +206,10 @@ jobs:

- uses: oxc-project/setup-node@fdbf0dfd334c4e6d56ceeb77d91c76339c2a0885 # v1.0.4

- name: Generate oxlint JS build
working-directory: apps/oxlint
run: pnpm run build-js

- name: Generate npm packages
run: |
node npm/oxlint/scripts/generate-packages.mjs
Expand Down Expand Up @@ -253,7 +279,7 @@ jobs:
ref: main
inputs: '{ "version": "${{ needs.check.outputs.version }}" }'

- name: Bump oxc-project/eslint-plugin-oxlint
- name: Bump oxc-project/oxlint-migrate
uses: benc-uk/workflow-dispatch@e2e5e9a103e331dad343f381a29e654aea3cf8fc # v1.2.4
with:
repo: oxc-project/oxlint-migrate
Expand Down
16 changes: 3 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions apps/oxlint/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
*.node
dist/
18 changes: 9 additions & 9 deletions apps/oxlint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,10 @@ description.workspace = true
workspace = true

[lib]
crate-type = ["lib"]
crate-type = ["cdylib", "lib"]
path = "src/lib.rs"
doctest = false

[[bin]]
name = "oxlint"
path = "src/main.rs"
test = false
doctest = false

[dependencies]
oxc_allocator = { workspace = true, features = ["fixed_size"] }
oxc_diagnostics = { workspace = true }
Expand All @@ -36,13 +30,15 @@ bpaf = { workspace = true, features = ["autocomplete", "bright-color", "derive"]
cow-utils = { workspace = true }
ignore = { workspace = true, features = ["simd-accel"] }
miette = { workspace = true }
napi = { workspace = true }
napi = { workspace = true, features = ["async"], optional = true }
napi-derive = { workspace = true, optional = true }
rayon = { workspace = true }
rustc-hash = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
simdutf8 = { workspace = true }
tempfile = { workspace = true }
tokio = { workspace = true, features = ["rt-multi-thread"] }
tracing-subscriber = { workspace = true, features = [] } # Omit the `regex` feature

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

[build-dependencies]
napi-build = { workspace = true }

[dev-dependencies]
insta = { workspace = true }
lazy-regex = { workspace = true }

[features]
default = []
default = ["napi"]
napi = ["dep:napi", "dep:napi-derive"]
allocator = ["dep:mimalloc-safe"]
force_test_reporter = ["oxc_linter/force_test_reporter"]
File renamed without changes.
7 changes: 4 additions & 3 deletions napi/oxlint/package.json → apps/oxlint/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "oxlint",
"version": "0.1.0",
"bin": "dist/index.js",
"bin": "dist/cli.js",
"type": "module",
"scripts": {
"build": "pnpm run build-napi-release && pnpm run build-js",
Expand All @@ -16,15 +16,15 @@
"engines": {
"node": ">=20.0.0"
},
"description": "Staging package for oxlint while we integrate custom JS plugins into oxlint",
"description": "Linter for the JavaScript Oxidation Compiler",
"author": "Boshen and oxc contributors",
"license": "MIT",
"homepage": "https://oxc.rs",
"bugs": "https://github.com/oxc-project/oxc/issues",
"repository": {
"type": "git",
"url": "https://github.com/oxc-project/oxc.git",
"directory": "napi/oxlint"
"directory": "apps/oxlint"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/",
Expand All @@ -41,6 +41,7 @@
},
"napi": {
"binaryName": "oxlint",
"packageName": "@oxlint/binding",
"targets": [
"win32-x64",
"win32-arm64",
Expand Down
25 changes: 22 additions & 3 deletions napi/oxlint/scripts/build.js → apps/oxlint/scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
import { execSync } from 'node:child_process';
import { copyFileSync, mkdirSync, readdirSync } from 'node:fs';
import { copyFileSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';

const oxlintDirPath = join(import.meta.dirname, '..'),
distDirPath = join(oxlintDirPath, 'dist'),
parserDirPath = join(oxlintDirPath, '../parser');
parserDirPath = join(oxlintDirPath, '../../napi/parser');

// Modify `bindings.js` to use correct package names
console.log('Modifying bindings.js...');
const bindingsPath = join(oxlintDirPath, 'src-js/bindings.js');
let bindingsJs = readFileSync(bindingsPath, 'utf8');
bindingsJs = bindingsJs.replace(/require\('@oxlint\/binding-(.+?)'\)/g, (_, name) => {
name = name.replace(/-msvc(\/|$)/g, '$1');
return `require('@oxlint/${name}')`;
});
writeFileSync(bindingsPath, bindingsJs);

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

// Copy files from `napi/parser` to `napi/oxlint/dist`
// Add `package.json` to `dist` dir.
// `npm/oxlint` package is CommonJS, so we need this file to tell Node.js that `dist` is ESM.
console.log('Adding package.json to dist...');
writeFileSync(
join(distDirPath, 'package.json'),
JSON.stringify({ type: 'module' }, null, 2) + '\n',
);
console.log('- Created package.json');

// Copy files from `napi/parser` to `apps/oxlint/dist`
console.log('Copying files from parser...');

const parserFilePaths = [
Expand Down
File renamed without changes.
Loading
Loading