Skip to content

Commit 14b65d3

Browse files
overlookmotelCopilot
authored andcommitted
test(linter/plugins): add conformance tests (#16650)
Add conformance tester for JS plugins. The tester runs all of ESLint's test cases for all its built-in rules, but using Oxlint's `RuleTester` in place of ESLint's. i.e. the ESLint rules are run as Oxlint JS plugins. It outputs the results in `snapshot.md` file. Majority of the failing test cases are false positives. Later PRs will improve the conformance tester and `RuleTester` so it correctly handles `sourceType`, `jsx`, and TypeScript sources. These tests do not run in CI. For now it's just useful for me to commit this, while I work on improving the tester. I'm not sure if inside `apps/oxlint` is the right place for this ultimately, but for now I think it's passable.
1 parent fb04d6b commit 14b65d3

File tree

15 files changed

+136620
-2
lines changed

15 files changed

+136620
-2
lines changed

.typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
extend-exclude = [
77
"**/*.snap",
88
"**/*/CHANGELOG.md",
9+
"apps/oxlint/conformance/snapshot.md",
910
"crates/oxc_linter/fixtures",
1011
"crates/oxc_linter/src/rules/eslint/no_unused_vars/ignored.rs",
1112
"crates/oxc_linter/src/rules/eslint/no_unused_vars/options.rs",

apps/oxlint/conformance/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
submodules

apps/oxlint/conformance/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Oxlint JS plugins conformance tests
2+
3+
Conformance tests run all ESLint's tests for its built-in rules as Oxlint JS plugins.
4+
5+
They do this by substituting ESLint's `RuleTester` for Oxlint's version, and then `require()`ing the ESLint test files
6+
to run the tests.
7+
8+
The results are saved in `conformance/snapshot.md`.
9+
10+
## Setup
11+
12+
Build Oxlint in debug mode:
13+
14+
```sh
15+
cd apps/oxlint
16+
pnpm run build-test
17+
```
18+
19+
Initialize ESLint submodule:
20+
21+
```sh
22+
pnpm run init-conformance
23+
```
24+
25+
## Run conformance tests
26+
27+
```sh
28+
pnpm run conformance
29+
```

apps/oxlint/conformance/init.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -e
3+
4+
ESLINT_SHA="e593aa0fd29f51edea787815ffc847aa723ef1f8"
5+
6+
# Delete existing `submodules` directory
7+
rm -rf submodules
8+
9+
# Clone ESLint repo into `submodules/eslint`
10+
git clone --single-branch --depth 1 https://github.com/eslint/eslint.git submodules/eslint
11+
cd submodules/eslint
12+
git fetch --depth 1 origin "$ESLINT_SHA"
13+
git reset --hard "$ESLINT_SHA"
14+
git clean -f -q
15+
16+
# Install dependencies
17+
pnpm install --ignore-workspace
18+
19+
# Copy TS-ESLint parser shim into `node_modules/@typescript-eslint/parser`
20+
rm node_modules/@typescript-eslint/parser
21+
cp -r tools/typescript-eslint-parser node_modules/@typescript-eslint/parser
22+
cd node_modules/@typescript-eslint/parser
23+
24+
# Install dependencies of TS-ESLint parser shim
25+
pnpm install --ignore-workspace

0 commit comments

Comments
 (0)