Skip to content

Commit

Permalink
test(linter): use snapshot testing instead of LintResult
Browse files Browse the repository at this point in the history
  • Loading branch information
Sysix authored and Boshen committed Jan 25, 2025
1 parent 4a2f2a9 commit 1220719
Show file tree
Hide file tree
Showing 49 changed files with 869 additions and 228 deletions.
261 changes: 57 additions & 204 deletions apps/oxlint/src/lint.rs

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions ...es__issue_7566__tests__main.js [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: --ignore-path fixtures/issue_7566/.oxlintignore fixtures/issue_7566/tests/main.js fixtures/issue_7566/tests/function/main.js
working directory:
----------
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: --ignore-path fixtures/linter/.customignore --no-ignore fixtures/linter/nan.js
working directory:
----------

! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/use-isnan.html\eslint(use-isnan)]8;;\: Requires calls to isNaN() when checking for NaN
,-[fixtures/linter/nan.js:1:8]
1 | 123 == NaN;
: ^^^
`----
help: Use the isNaN function to compare with NaN.
Found 1 warning and 0 errors.
Finished in <variable>ms on 1 file with 97 rules using 1 threads.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: --ignore-path fixtures/linter/.customignore fixtures/linter/nan.js
working directory:
----------
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: --ignore-pattern **/*.js --ignore-pattern **/*.vue fixtures/linter
working directory:
----------
Found 0 warnings and 0 errors.
Finished in <variable>ms on 0 files with 97 rules using 1 threads.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: --import-plugin -A all -D no-cycle fixtures/flow/
working directory:
----------
Found 0 warnings and 0 errors.
Finished in <variable>ms on 2 files with 99 rules using 1 threads.
9 changes: 9 additions & 0 deletions apps/oxlint/src/snapshots/_--import-plugin [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: --import-plugin fixtures/flow/index.mjs
working directory:
----------
Found 0 warnings and 0 errors.
Finished in <variable>ms on 1 file with 99 rules using 1 threads.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
source: apps/oxlint/src/tester.rs
---
##########
--print-config
arguments: --print-config
working directory:
----------
{
"plugins": [
Expand Down
26 changes: 26 additions & 0 deletions ..._vitest_replace__eslintrc.json [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: --vitest-plugin -c fixtures/eslintrc_vitest_replace/eslintrc.json fixtures/eslintrc_vitest_replace/foo.test.js
working directory:
----------

! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/jest/expect-expect.html\eslint-plugin-jest(expect-expect)]8;;\: Test has no assertions
,-[fixtures/eslintrc_vitest_replace/foo.test.js:1:1]
1 | test.skip('foo', () => {
: ^^^^^^^^^
2 | // ...
`----
help: Add assertion(s) in this Test
x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/jest/no-disabled-tests.html\eslint-plugin-jest(no-disabled-tests)]8;;\: Disabled test
,-[fixtures/eslintrc_vitest_replace/foo.test.js:1:1]
1 | test.skip('foo', () => {
: ^^^^^^^^^
2 | // ...
`----
help: Remove the appending `.skip`
Found 1 warning and 1 error.
Finished in <variable>ms on 1 file with 109 rules using 1 threads.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
source: apps/oxlint/src/tester.rs
---
##########
-A all --print-config
arguments: -A all --print-config
working directory:
----------
{
"plugins": [
Expand Down
9 changes: 9 additions & 0 deletions apps/oxlint/src/snapshots/_-A all [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -A all fixtures/linter
working directory:
----------
Found 0 warnings and 0 errors.
Finished in <variable>ms on 3 files with 0 rules using 1 threads.
17 changes: 17 additions & 0 deletions apps/oxlint/src/snapshots/_-D correctness [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -D correctness fixtures/linter/debugger.js
working directory:
----------

x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\eslint(no-debugger)]8;;\: `debugger` statement is not allowed
,-[fixtures/linter/debugger.js:1:1]
1 | debugger;
: ^^^^^^^^^
`----
help: Delete this code.
Found 0 warnings and 1 error.
Finished in <variable>ms on 1 file with 97 rules using 1 threads.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -W correctness -A no-debugger fixtures/linter/debugger.js
working directory:
----------
Found 0 warnings and 0 errors.
Finished in <variable>ms on 1 file with 96 rules using 1 threads.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -W no-undef -c fixtures/eslintrc_env/eslintrc_no_env.json fixtures/eslintrc_env/test.js
working directory:
----------

! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-undef.html\eslint(no-undef)]8;;\: 'console' is not defined.
,-[fixtures/eslintrc_env/test.js:1:1]
1 | console.log('')
: ^^^^^^^
`----
Found 1 warning and 0 errors.
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -W no-undef -c fixtures/no_undef/eslintrc.json fixtures/no_undef/test.js
working directory:
----------

! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-undef.html\eslint(no-undef)]8;;\: 'console' is not defined.
,-[fixtures/no_undef/test.js:1:1]
1 | console.log(foo)
: ^^^^^^^
`----
Found 1 warning and 0 errors.
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
15 changes: 15 additions & 0 deletions ...e_extension__eslintrc.json [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -c fixtures/config_ignore_patterns/ignore_extension/eslintrc.json fixtures/config_ignore_patterns/ignore_extension
working directory:
----------

! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-empty-file.html\eslint-plugin-unicorn(no-empty-file)]8;;\: Empty files are not allowed.
,-[fixtures/config_ignore_patterns/ignore_extension/main.ts:1:1]
`----
help: Delete this file or add some code to it.
Found 1 warning and 0 errors.
Finished in <variable>ms on 1 file with 97 rules using 1 threads.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -c fixtures/eslintrc_env/eslintrc_env_browser.json fixtures/eslintrc_env/test.js
working directory:
----------
Found 0 warnings and 0 errors.
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -c fixtures/eslintrc_off/eslintrc.json fixtures/eslintrc_off/test.js
working directory:
----------

! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-empty-file.html\eslint-plugin-unicorn(no-empty-file)]8;;\: Empty files are not allowed.
,-[fixtures/eslintrc_off/test.js:1:1]
`----
help: Delete this file or add some code to it.
Found 1 warning and 0 errors.
Finished in <variable>ms on 1 file with 97 rules using 1 threads.
9 changes: 9 additions & 0 deletions ..._vitest_replace__eslintrc.json [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -c fixtures/eslintrc_vitest_replace/eslintrc.json fixtures/eslintrc_vitest_replace/foo.test.js
working directory:
----------
Found 0 warnings and 0 errors.
Finished in <variable>ms on 1 file with 97 rules using 1 threads.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -c fixtures/import/.oxlintrc.json fixtures/import/test.js
working directory:
----------

x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/import/no-default-export.html\eslint-plugin-import(no-default-export)]8;;\: Prefer named exports
,-[fixtures/import/test.js:7:8]
6 | // import/no-default-export
7 | export default function foo() {}
: ^^^^^^^
8 |
`----
Found 0 warnings and 1 error.
Finished in <variable>ms on 1 file with 50 rules using 1 threads.
36 changes: 36 additions & 0 deletions ...lias_rules__oxlint-vitest.json [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -c fixtures/jest_and_vitest_alias_rules/oxlint-jest.json fixtures/jest_and_vitest_alias_rules/test.js
working directory:
----------

x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/jest/no-identical-title.html\eslint-plugin-jest(no-identical-title)]8;;\: Test title is used multiple times in the same describe block.
,-[fixtures/jest_and_vitest_alias_rules/test.js:3:6]
2 | it("works", () => {});
3 | it("works", () => {});
: ^^^^^^^
4 | });
`----
help: Change the title of test.
Found 0 warnings and 1 error.
Finished in <variable>ms on 1 file with 1 rules using 1 threads.
##########
arguments: -c fixtures/jest_and_vitest_alias_rules/oxlint-vitest.json fixtures/jest_and_vitest_alias_rules/test.js
working directory:
----------
x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/jest/no-identical-title.html\eslint-plugin-jest(no-identical-title)]8;;\: Test title is used multiple times in the same describe block.
,-[fixtures/jest_and_vitest_alias_rules/test.js:3:6]
2 | it("works", () => {});
3 | it("works", () => {});
: ^^^^^^^
4 | });
`----
help: Change the title of test.
Found 0 warnings and 1 error.
Finished in <variable>ms on 1 file with 1 rules using 1 threads.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -c fixtures/linter/eslintrc.json fixtures/linter/debugger.js
working directory:
----------

x ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html\eslint(no-debugger)]8;;\: `debugger` statement is not allowed
,-[fixtures/linter/debugger.js:1:1]
1 | debugger;
: ^^^^^^^^^
`----
help: Delete this code.
Found 0 warnings and 1 error.
Finished in <variable>ms on 1 file with 97 rules using 1 threads.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -c fixtures/no_console_off/eslintrc.json fixtures/no_console_off/test.js
working directory:
----------
Found 0 warnings and 0 errors.
Finished in <variable>ms on 1 file with 97 rules using 1 threads.
9 changes: 9 additions & 0 deletions ...atch__eslintrc.json -W no-empty [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -c fixtures/no_empty_allow_empty_catch/eslintrc.json -W no-empty fixtures/no_empty_allow_empty_catch/test.js
working directory:
----------
Found 0 warnings and 0 errors.
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
17 changes: 17 additions & 0 deletions ...h__eslintrc.json -W no-empty [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
source: apps/oxlint/src/tester.rs
---
##########
arguments: -c fixtures/no_empty_disallow_empty_catch/eslintrc.json -W no-empty fixtures/no_empty_disallow_empty_catch/test.js
working directory:
----------

! ]8;;https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-empty.html\eslint(no-empty)]8;;\: Unexpected empty block statements
,-[fixtures/no_empty_disallow_empty_catch/test.js:1:29]
1 | try { console.log() } catch {}
: ^^
`----
help: Remove this block or add a comment inside it
Found 1 warning and 0 errors.
Finished in <variable>ms on 1 file with 98 rules using 1 threads.
Loading

0 comments on commit 1220719

Please sign in to comment.