Commit graph

139 commits

Author SHA1 Message Date
dalaoshu
baf3e4e6fb
fix(linter): correctly replace rule severity with duplicate rule name configurations (#8840)
See the snapshot changes of
`apps/oxlint/fixtures/typescript_eslint/eslintrc.json`.
2025-02-02 14:26:09 +01:00
Tapan Prakash
7e8568bca5
feat(linter): Junit reporter (#8756)
closes https://github.com/oxc-project/oxc/issues/7960

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-02-02 17:09:15 +08:00
oxc-bot
0063318102
release(oxlint): v0.15.9 (#8824)
## [0.15.9] - 2025-02-01

### Features

- 1a41181 linter: Implement `eslint/prefer-object-spread` (#8216)
(tbashiyy)
- adb8ebd linter: Implement no-useless-call rule (#8789) (keita hino)
- 3790933 linter: Add vitest/prefer-lowercase-title rule (#8152) (Tyler
Earls)
- e8e6917 linter: Unicorn/switch-cases-braces support options (#8704)
(1zumii)

### Bug Fixes

- 8ce21d1 linter: Can't disable `no-nested-ternary` rule anymore (#8600)
(dalaoshu)
- e929f26 linter: Output `LintCommandInfo` for
`CliRunResult::LintNoFilesFound` (#8714) (Sysix)
- 4f30a17 linter: Unicorn/switch-case-braces mangles code when applying
fix (#8758) (Tyler Earls)
- 9cc9d5f linter: `ignorePatterns` does not work when files are provided
as command arguments (#8590) (dalaoshu)
- 1de6f85 linter: No-lone-blocks erroring on block statements containing
comments (#8720) (Tyler Earls)
- 77ef61a linter: Fix diagnostic spans for `oxc/no-async-await` (#8721)
(camchenry)
- f15bdce linter: Catch `Promise` in `typescript/array-type` rule
(#8702) (Rintaro Itokawa)
- 5041cb3 vscode: Fix commands by reverting commit `259a47b` (#8819)
(Alexander S.)

### Performance

- d318238 linter: Remove sorting of rules in cache (#8718) (camchenry)

### Documentation

- 57b7ca8 ast: Add documentation for all remaining JS AST methods
(#8820) (Cam McHenry)

### Refactor

- c2fdfc4 linter: Correctly handle loose options for `eslint/eqeqeq`
(#8798) (dalaoshu)
- 0aeaedd linter: Support loose options for `eslint/eqeqeq` (#8790)
(dalaoshu)
- 194a5ff linter: Remove `LintResult` (#8712) (Sysix)
- 4a2f2a9 linter: Move default `all_rules` output to trait (#8710)
(Sysix)
- 741fb40 linter: Move stdout outside LintRunner (#8694) (Sysix)
- 10e5920 linter: Move finishing default diagnostic message to
`GraphicalReporter` (#8683) (Sysix)
- 9731c56 oxlint: Move output from `CliRunResult::InvalidOption` to
outside and use more Enums for different invalid options (#8778) (Sysix)
- fe45bee oxlint: Create different `CliRunResult` instead of passing
`ExitCode` to it (#8777) (Sysix)
- 2378fef oxlint: Move ConfigFileInit output outside CliRunResult, exit
code 1 when it fails (#8776) (Sysix)
- f4cecb5 oxlint: Remove unused `CliRunResult::PathNotFound` (#8775)
(Sysix)

### Testing

- ad35e82 linter: Use snapshot testing instead of LintResult (#8711)
(Sysix)
- bf895eb linter: Add diagnostic format test snapshots (#8696)
(Alexander S.)
- 34d3d72 linter: Add snapshot tester for cli (#8695) (Sysix)
- 0bf2bcf oxlint: Test two real rules with same name but from different
plugins (#8821) (dalaoshu)
- 2b83b71 oxlint: Improve disabling "no-nested-ternary" tests (#8814)
(Alexander S.)
- 45648e7 oxlint: Fix InvalidOptionTsConfig tests for windows (#8791)
(Alexander S.)
- 48bfed9 oxlint: Ignore windows path mismatch (Boshen)
- 6f4a023 oxlint: Remove "--print-config" test (#8792) (Sysix)
- 55c2025 oxlint: Add `CliRunResult` to snapshot (#8780) (Sysix)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-02-01 22:01:30 +08:00
dalaoshu
0bf2bcf359
test(oxlint): test two real rules with same name but from different plugins (#8821)
Related to #8814 

This test case is designed to verify that two different rules, having
the same name but coming from different plugins, are treated as distinct
rules rather than simple aliases.

In `unicorn`, there is only one rule, `no-negated-condition`, which is
aliased to `eslint`.


655b212688/crates/oxc_linter/src/config/rules.rs (L166-L178)
2025-02-01 14:29:23 +01:00
Alexander S.
2b83b71b94
test(oxlint): improve disabling "no-nested-ternary" tests (#8814)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-31 14:19:11 +01:00
dalaoshu
8ce21d1d48
fix(linter): can't disable no-nested-ternary rule anymore (#8600)
closes #8485 

Since we currently support two rules with the same `rule_name` but
different `plugin_names`, some of the original logic is no longer
applicable. As a result, I have made some adjustments.
2025-01-31 21:03:53 +08:00
Sysix
e929f26826 fix(linter): output LintCommandInfo for CliRunResult::LintNoFilesFound (#8714)
In the older version we outputted the found warnings and errors (which also be zero).
This is only reimplementing a part of the old behavior ands skips the old output here:
4a2f2a9cd9/apps/oxlint/src/output_formatter/default.rs (L84-L110)

Bug found here:
659c225c56/apps/oxlint/src/snapshots/_--ignore-path%20fixtures__linter__.customignore%20fixtures__linter__nan.js%40oxlint.snap
2025-01-31 11:48:23 +00:00
dalaoshu
9cc9d5f1d1
fix(linter): ignorePatterns does not work when files are provided as command arguments (#8590)
closes #8505 

Here is why this issue occurs:

c15af02e52/apps/oxlint/src/lint.rs (L66-L70)
2025-01-31 12:24:23 +08:00
Boshen
bebee7597e
Revert "test(oxlint): ignore windows path mismatch"
This reverts commit 48bfed9f43.
2025-01-31 11:49:24 +08:00
Alexander S.
45648e794a
test(oxlint): fix InvalidOptionTsConfig tests for windows (#8791)
because of:
https://github.com/oxc-project/oxc/actions/runs/13058657372/job/36435970934
> The tsconfig file "E:\\oxc\\apps\\oxlint\\oxc/tsconfig.json"

now I know the reason why eslint is printing it in POSIX style

---------

Co-authored-by: Sysix <alexander.schlegel@clicksports.de>
2025-01-31 11:49:00 +08:00
Boshen
48bfed9f43
test(oxlint): ignore windows path mismatch 2025-01-31 11:42:42 +08:00
Sysix
6f4a0234ca test(oxlint): remove "--print-config" test (#8792)
it is only removing one test. This test is removed because of: https://github.com/oxc-project/oxc/pull/8789#discussion_r1935775539
Boshen thought too that this should be a problem in the future. I did not believe him :/

Merging without review
2025-01-30 18:14:30 +00:00
Sysix
55c2025a3b test(oxlint): add CliRunResult to snapshot (#8780) 2025-01-30 01:43:42 +00:00
Sysix
9731c56b6a refactor(oxlint): move output from CliRunResult::InvalidOption to outside and use more Enums for different invalid options (#8778)
Now we can choose which exit code to use for a specific (unexpected) result
2025-01-30 01:43:42 +00:00
Sysix
fe45bee0c2 refactor(oxlint): create different CliRunResult instead of passing ExitCode to it (#8777) 2025-01-30 01:43:42 +00:00
Sysix
2378fef3cf refactor(oxlint): move ConfigFileInit output outside CliRunResult, exit code 1 when it fails (#8776) 2025-01-30 01:43:41 +00:00
Sysix
f4cecb52b1 refactor(oxlint): remove unused CliRunResult::PathNotFound (#8775) 2025-01-30 01:43:41 +00:00
Sysix
194a5ff76a refactor(linter): remove LintResult (#8712) 2025-01-29 02:26:18 +00:00
Sysix
ad35e82165 test(linter): use snapshot testing instead of LintResult (#8711)
Welcome to the new testing area for oxlint CLI 🥳

There is still one test left to be snapshotted (for invalid options), but everything else works great.
I put some comments on code which I think are the key points of the PR
2025-01-29 02:26:17 +00:00
Sysix
4a2f2a9cd9 refactor(linter): move default all_rules output to trait (#8710) 2025-01-25 13:42:20 +00:00
Alexander S.
bf895eb90d
test(linter): add diagnostic format test snapshots (#8696)
windows will fail, looks like the offset missmatch is because of `\r\n`
vs `\n`.

```
Snapshot file: apps\oxlint\src\snapshots\--format=json test.js@oxlint.snap
Snapshot: --format=json test.js@oxlint
Source: C:\dev\oxc:74
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────-old snapshot
+new results
────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────    0     0 │ ##########
    1     1 │ --format=json test.js
    2     2 │ ----------
    3     3 │ [
    4       │-  {"message": "`debugger` statement is not allowed","code": "eslint(no-debugger)","severity": "error","causes": [],"url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html","help": "Delete this code.","filename": "test.js","labels": [{"span": {"offset": 38,"length": 9}}],"related": []},
          4 │+  {"message": "`debugger` statement is not allowed","code": "eslint(no-debugger)","severity": "error","causes": [],"url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-debugger.html","help": "Delete this code.","filename": "test.js","labels": [{"span": {"offset": 42,"length": 9}}],"related": []},
    5     5 │   {"message": "Function 'foo' is declared but never used.","code": "eslint(no-unused-vars)","severity": "warning","causes": [],"url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-vars.html","help": "Consider removing this declaration.","filename": "test.js","labels": [{"label": "'foo' is declared here","span": {"offset": 9,"length": 3}}],"related": []},
    6     6 │   {"message": "Parameter 'b' is declared but never used. Unused parameters should start with a '_'.","code": "eslint(no-unused-vars)","severity": "warning","causes": [],"url": "https://oxc.rs/docs/guide/usage/linter/rules/eslint/no-unused-vars.html","help": "Consider removing this parameter.","filename": "test.js","labels": [{"label": "'b' is declared here","span": {"offset": 16,"length": 1}}],"related": []}
    7     7 │ ]
────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────To update snapshots run `cargo insta review`
Stopped on the first failure. Run `cargo insta test` to run all snapshots.
thread 'output_formatter::test::test_output_formatter_diagnostic_json' panicked at C:\Users\sysix\.cargo\registry\src\index.crates.io-6f17d22bba15001f\insta-1.42.0\src\runtime.rs:679:13:
snapshot assertion for '--format=json test.js@oxlint' failed in line 74
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- output_formatter::test::test_output_formatter_diagnostic_stylish stdout ----
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Snapshot Summary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Snapshot file: apps\oxlint\src\snapshots\--format=stylish test.js@oxlint.snap
Snapshot: --format=stylish test.js@oxlint
Source: C:\dev\oxc:74
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────-old snapshot
+new results
────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────    3     3 │
    4     4 │ ␛[4mtest.js␛[0m␊
    5     5 │   ␛[2m9:3 ␛[0m  ␛[33mwarning␛[0m  Function 'foo' is declared but never used.  ␛[2meslint(no-unused-vars)␛[0m␊
    6     6 │   ␛[2m16:1␛[0m  ␛[33mwarning␛[0m  Parameter 'b' is declared but never used. Unused parameters should start with a '_'.  ␛[2meslint(no-unused-vars)␛[0m␊
    7       │-  ␛[2m38:9␛[0m  ␛[31merror␛[0m  `debugger` statement is not allowed  ␛[2meslint(no-debugger)␛[0m␊
          7 │+  ␛[2m42:9␛[0m  ␛[31merror␛[0m  `debugger` statement is not allowed  ␛[2meslint(no-debugger)␛[0m␊
    8     8 │ 
    9     9 │ ␛[31m✖ 3 problems (1 error, 2 warnings)␛[0m
────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────To update snapshots run `cargo insta review`
Stopped on the first failure. Run `cargo insta test` to run all snapshots.
thread 'output_formatter::test::test_output_formatter_diagnostic_stylish' panicked at C:\Users\sysix\.cargo\registry\src\index.crates.io-6f17d22bba15001f\insta-1.42.0\src\runtime.rs:679:13:
snapshot assertion for '--format=stylish test.js@oxlint' failed in line 74


failures:
    output_formatter::test::test_output_formatter_diagnostic_json
    output_formatter::test::test_output_formatter_diagnostic_stylish

test result: FAILED. 85 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.12s

```
2025-01-25 18:51:00 +08:00
Sysix
34d3d72b64 test(linter): add snapshot tester for cli (#8695)
Our first Snapshot 🥳
2025-01-24 17:19:31 +00:00
Sysix
741fb40a53 refactor(linter): move stdout outside LintRunner (#8694)
This is needed so we can use a custom `Write` implementation (or just `[u8]`) to make snapshots.
In this step I also updated `OutputFormatter::all_rules` so the Formatter does not need to handle the write-error.
2025-01-24 17:05:19 +00:00
Sysix
10e59209ef refactor(linter): move finishing default diagnostic message to GraphicalReporter (#8683)
Now every lint output is owned by is right OutputFormatter and his DiagnosticReporter 🥳
Next step is to setup a snapshot Tester, so I can remove the ToDos.

Reorded some lines so the outfor is now for: `cargo run -p oxlint -- test.js --max-warnings=2`
```
Found 4 warnings and 0 errors.
Exceeded maximum number of warnings. Found 4.
Finished in 5ms on 1 file with 97 rules using 24 threads.
```

and for `cargo run -p oxlint -- test.js`

```
Found 4 warnings and 0 errors.
Finished in 5ms on 1 file with 97 rules using 24 threads.
```

The output time and warnings/error count wil be always printed.
2025-01-24 16:39:17 +00:00
oxc-bot
b97767874f
release(oxlint): v0.15.8 (#8689)
## [0.15.8] - 2025-01-24

### Features

- 79ba9b5 linter: Added support to run in Node.JS legacy versions
(#8648) (Luiz Felipe Weber)
- dcaebe6 linter: Add "strict" option to `promise/prefer-await-to-then`
rule (#8674) (Neil Fisher)
- 4ae568e linter: Add DiagnosticResult to the Reporters for receiving a
sub part result (#8666) (Alexander S.)
- 8a0eb2a oxlint: Add stylish formatter (#8607) (Andrew Powell)

### Bug Fixes

- 40316af linter: Fix github `endColumn` output (#8647) (Alexander S.)
- dc912fa linter: Added missing $schema property to default config
(#8625) (Tapan Prakash)

### Refactor

- a3dc4c3 crates: Clean up snapshot files (#8680) (Boshen)
- e66da9f isolated_declarations, linter, minifier, prettier, semantic,
transformer: Remove unnecessary `ref` / `ref mut` syntax (#8643)
(overlookmotel)
- 23b49a6 linter: Use `cow_to_ascii_lowercase` instead
`cow_to_lowercase` (#8678) (Boshen)
- b8d9a51 span: Deal only in owned `Atom`s (#8641) (overlookmotel)
- ac4f98e span: Derive `Copy` on `Atom` (#8596) (branchseer)
- 259a47b vscode: Move commands and `findBinary` to separate files
(#8605) (Alexander S.)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-01-24 18:07:14 +08:00
Alexander S.
4ae568e8c9
feat(linter): add DiagnosticResult to the Reporters for receiving a sub part result (#8666)
We are currently outputting only for the default-outputter some extra
information:


3be03926e8/apps/oxlint/src/result.rs (L61-L87)

My goal is that all information will be passed to our new
DiagnosticReporter / OutputFormatter.
This will break the output format in the next PR. **Merging this PR is
the OK for me to make this change** ⚠️
The only breaking point:
`"Found {number_of_warnings} warning{} and {number_of_errors} error{}."`
will still be outputted when `max_warnings_exceeded` is true.

Because this is something the `DiagnosticReporter` should do and not the
`OutputFormatter`.

The end goal is:
- no `println!`, our `OutputFormatter` and his `DiagnosticReporter` will
return `Option<String>` and we output it the our `stdout`
- `LintResult` will only handle `ExitCode` result and nothing more
- `stdout` can be changed from outside (for the next part)
- add snapshots with a custom `stdout`

I do not know if all goals can be done easily. Last two parts should be
a bit tricky for me, never did test setups in rust.
But we do never stop to learn ;)
2025-01-23 10:09:51 +08:00
Alexander S.
40316afa7e
fix(linter): fix github endColumn output (#8647)
added `start` and `end` for `Info`, so every reporter can use both if
they want.
Then end calculation is a bit hacky, but i looks like it works.
2025-01-22 09:10:40 +08:00
Tapan Prakash
dc912fa58e
fix(linter): Added missing $schema property to default config (#8625)
The $schema property was not added when the --init command was used to
create the configuration. Now, $schema is added based on the
availability of configuration_schema.json in the current working
directory.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-22 09:09:39 +08:00
camc314
b75d4919ee chore(linter): update doc comment to reflect existance of stylish formatter (#8645)
after:
```
Output
    -f, --format=ARG          Use a specific output format (default, json, unix, checkstyle, github,
                              stylish)
```
2025-01-21 15:38:15 +00:00
Andrew Powell
8a0eb2abb7
feat(oxlint): add stylish formatter (#8607)
👋 This implements a reporter for `--format` on `oxlint` which aims to be
visually similar to
https://eslint.org/docs/latest/use/formatters/#stylish

Please note that this is my first time working with Rust and my
knowledge is very limited. I'm unlikely to understand best-practice or
best-pattern references outside of what clippy/cargo lint has already
had me change. If this needs modification, please help me out by making
code suggestions that can be merged to this PR.

Resolves #8422

---------

Co-authored-by: Cameron <cameron.clark@hey.com>
2025-01-21 09:55:07 +08:00
oxc-bot
66c8720002
release(oxlint): v0.15.7 (#8592)
## [0.15.7] - 2025-01-19

### Features

- 01ac773 linter: Support `ignoreTypeOfTestName` for `jest/valid-title`
(#8589) (dalaoshu)
- 538b24a linter: Format the configuration documentation correctly
(#8583) (Tapan Prakash)
- 7ab14cc linter: Add more Vitest compatible Jest rules (#8445) (Anson
Heung)
- d178360 linter: Implement `eslint/prefer-promise-reject-errors`
(#8254) (tbashiyy)
- 4ac2e99 oxlint: Implement `--init` cli option (#8453) (Tapan Prakash)

### Bug Fixes

- 855c839 codegen: Shorthand assignment target identifier consider
mangled names (#8536) (Boshen)
- c15af02 linter: False positive in `eslint/no-lone-blocks` (#8587)
(dalaoshu)
- 41f2070 linter: Rule `no-restricted-imports` support missing options
(#8076) (Alexander S.)
- 869bc73 linter: Enhance `default_param_last` rule to handle optional
parameters (#8563) (Tapan Prakash)
- c6260c2 linter: Support rest params for `prefer_promise_reject_errors`
(#8468) (Yuichiro Yamashita)
- 2be1e82 linter/no-unused-vars: False positives when variable and type
have same name (#8465) (Dunqing)

### Performance

- 250bbd1 linter/react-exhaustive-deps: Use stack of `AstType`s instead
of `AstKind`s (#8522) (overlookmotel)

### Refactor

- 40f5165 linter: Improve `eslint/no-lone-blocks` (#8588) (dalaoshu)
- b4c87e2 linter: Move DiagnosticsReporters to oxlint (#8454) (Alexander
S.)
- bf00f82 linter: Move rule `prefer-each` from vitest to jest +
remapping (#8448) (Alexander S.)
- 8dd0013 linter/consistent-function-scoping: Remove `Visit::enter_node`
usage (#8538) (overlookmotel)
- 30c0689 linter/no-map-spread: Remove `Visit::enter_node` usage (#8537)
(overlookmotel)
- b5ed58e span: All methods take owned `Span` (#8297) (overlookmotel)

### Styling

- 3789d2f linter/react-exhaustive-deps: Fix indentation (#8520)
(overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-01-19 09:00:00 +08:00
Alexander S.
b4c87e27a1
refactor(linter): move DiagnosticsReporters to oxlint (#8454)
it was never the plan that oxc_diagnostics should be the
`std::io::stdout` writer:

8fc238ac34/crates/oxc_diagnostics/src/service.rs (L84-L85)

This PR does refactor all reporters to `oxlint` crate and make the
current implementation of `oxc_diagnostics` public for others to
consume.

I added some tests to reflect to expected output (and found some bugs^^)

For the future I think the BufWriter for `std::io::stdout` should come
from outside.
Or maybe `std::fmt::stdout`? I do not know^^"

I could not test 100% of the code, I hope I can fix this with the next
PR which will include a own Tester for oxlint (like `oxc_linter`).
Please be extra careful when reviewing it.

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-16 16:11:22 +08:00
Tapan Prakash
4ac2e990a2
feat(oxlint): implement --init cli option (#8453)
Implemented --init cli option to create oxlint configuration files with
default values.
close https://github.com/oxc-project/oxc/issues/7453

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-14 13:49:42 +08:00
oxc-bot
424c770012
release(oxlint): v0.15.6 (#8456)
## [0.15.6] - 2025-01-13

### Features

- 457aa31 linter: Implement `no-lone-blocks` rule (#8145) (Yuichiro
Yamashita)

### Refactor

- aea9551 ast: Simplify `get_identifier_reference` of `TSType` and
`TSTypeName` (#8273) (Dunqing)
- 43ed3e1 linter: Add output formatter (#8436) (Alexander S.)
- 4e05e66 linter: Remove glob for windows (#8390) (Alexander S.)
- b19d809 linter: Split `unicorn/prefer-spread` and
`eslint/prefer-spread` into own rules (#8329) (Alexander S.)
- 3c534ae linter: Refactor `LintBuilder` to prep for nested configs
(#8034) (camc314)
- 2f9fab9 linter: Remove remapping for plugin name in diagnostics
(#8223) (Alexander S.)

### Testing

- b6c1546 linter: Use plugin name instead of category for finding rule
(#8353) (Alexander S.)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-01-13 11:08:34 +08:00
Alexander S.
43ed3e1722
refactor(linter): add output formatter (#8436)
I want to start grouping all the different Formats for action X, Y and Z
into own place.
This is the first step and probably not the best one to be honest :)

~~I prefer that the `OutputFormatter` is a part of `oxlint` and not
`oxc_linter`~~
~~but all `use create::rules::RULES` is not public from outside.~~
EDIT: I pushed a commit with this changes can easily be reverted and
move back to `oxc_linter`

Also their is a crate `oxc_diagnostics` which has already the concept
too but only for the lint part of `oxlint` and not for the other parts.
The next goal would be splitting the `DiagnosticService` with its
reporters to `oxlint`.
2025-01-12 08:22:56 +08:00
Boshen
d15c856b13 chore(rust): update clippy rules (#8408) 2025-01-10 06:41:53 +00:00
Alexander S.
4e05e66d7c
refactor(linter): remove glob for windows (#8390)
The current implementations does not work. Under linux it tells me 0
files, under windows:

```
> oxc-vscode@0.15.5 lint C:\dev\oxc\editors\vscode
> npx oxlint --config=oxlint.json --tsconfig=tsconfig.json client/*.js

Finished in 5ms on 5 files with 101 rules using 24 threads.
Found 0 warnings and 0 errors.
```

I do not think this glob is needed. we are using `ignore` in our
`Walker`, which should already covering the use case.

---------

Co-authored-by: Sysix <alexander.schlegel@clicksports.de>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-01-10 10:03:43 +08:00
camc314
3c534aeb5a refactor(linter): refactor LintBuilder to prep for nested configs (#8034)
More simplification/preparations for nested configurations:

1. renames `LinterBuilder` to `ConfigStoreBuilder`
2. moves the `options` logic out of `LintBuilder`
3. make `ConfigStoreBuilder::build()` return a result (currently always returns OK, but it will return errors when nested config is implemented

The next steps to implement nested config which i hope to do in the next week are:
1. refactor the `from_oxlintrc` to accept a file path
2. introduce a new method on `ConfigStoreBuilder` (name TBC) that walks all child directories, collecting `.oxlintrc` files. these will be put into `ConfigStore` as a hash map of path > config.
2025-01-05 04:08:26 +00:00
oxc-bot
d2d90b077b
release(oxlint): v0.15.5 (#8218)
## [0.15.5] - 2025-01-02

### Features

- 0e168b8 linter: Catch more cases in const-comparisons (#8215)
(Cameron)
- bde44a3 linter: Add `statement_span` to `ModuleRecord/ImportEntry`
(#8195) (Alexander S.)
- ccaa9f7 linter: Implement `eslint/new-cap`  (#8146) (Alexander S.)

### Bug Fixes

- 2b14a6f linter: Fix `ignorePattern` config for windows (#8214)
(Alexander S.)

### Testing

- cb709c9 linter: Fix some oxlint tests on windows (#8204) (Cameron)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-01-02 18:55:31 +08:00
Alexander S.
2b14a6fb54
fix(linter): fix ignorePattern config for windows (#8214)
Changes:

- Config `ignorePatterns` not as `Path`, because the create `ignore`
does only handle `/` and not Win-style `\`
- Passed full path to the config and do not use `canonicalize` because
it prefix the paths with `\\?\`,
  read more here: https://stackoverflow.com/a/41233992/7387397
- Updated and enabled tests for windows, some are still failing 

closes #8188

---------

Co-authored-by: Alexander Schlegel <alexander.schlegel@clicksports.de>
2025-01-02 18:34:02 +08:00
Cameron
cb709c9d83
test(linter): fix some oxlint tests on windows (#8204) 2025-01-01 10:22:10 +08:00
oxc-bot
936623ea45
release(oxlint): v0.15.4 (#8190)
## [0.15.4] - 2024-12-30

### Features

- 47cea9a linter: Implement `eslint/no-extra-label` (#8181) (Anson
Heung)
- ef76e28 linter: Implement `eslint/no-multi-assign` (#8158) (Anson
Heung)
- 384858b linter: Implement `jsx-a11y/no-noninteractive-tabindex`
(#8167) (Tyler Earls)
- afc21a6 linter: Implement `eslint/vars-on-top` (#8157) (Yuichiro
Yamashita)
- 65796c4 linter: Implement `eslint/prefer-rest-params` (#8155)
(Yuichiro Yamashita)
- 5234d96 linter: Implement `eslint/no-nested-ternary` (#8150) (Yuichiro
Yamashita)
- 1c5db72 linter: Implement eslint/no-labels (#8131) (Anson Heung)
- 0b04288 linter: Move `import/named` to nursery (#8068) (Boshen)

### Bug Fixes

- 0794bee editor/vscode: Set minimum supported ver. to `^1.93.0` (#8182)
(Pavel Smirnov)
- f3050d4 linter: Exclude svelte files from `no_unused_vars` rule
(#8170) (Yuichiro Yamashita)
- faf7464 linter: Disable rule `react/rules-of-hook` by file extension
(#8168) (Alexander S.)
- 1171e00 linter: Disable `react/rules-of-hooks` for vue and svelte
files (#8165) (Alexander S.)
- 1b9a5ba linter: False positiver in private member expr in
oxc/const-comparison (#8164) (camc314)
- 6bd9ddb linter: False positive in `typescript/ban-tslint-comment`
(#8094) (dalaoshu)
- 10a1fd5 linter: Rule: `no-restricted-imports` support option
`patterns` with `group` key (#8050) (Alexander S.)
- b3f38ae linter: Rule `no-restricted-imports`: support option
`allowImportNames` (#8002) (Alexander S.)
- 340cc90 linter: Rule `no-restricted-imports`: fix option "importNames"
(#7943) (Alexander S.)
- ec2128e linter: Fix line calculation for `eslint/max-lines` in
diagnostics (#7962) (Dmitry Zakharov)
- 79af100 semantic: Reference flags not correctly resolved when after an
export stmt (#8134) (camc314)

### Performance

- d8d2ec6 linter: Run rules which require typescript syntax only when
source type is actually typescript (#8166) (Alexander S.)
- 2736657 semantic: Allocate `UnresolvedReferences` in allocator (#8046)
(Boshen)

### Refactor

- de8246b language_server: Move structs into own file (#8026) (Alexander
S.)
- 774babb linter: Read `exported_bindings_from_star_export` lazily
(#8062) (Boshen)
- 547c102 linter: Use `RwLock<FxHashMap>` instead of `FxDashMap` for
module record data (#8061) (Boshen)
- 952d7e4 linter: Rename `flat.rs` to `config.rs` (#8033) (camc314)
- 50848ed linter: Simplify `ConfigStore` to prep for nested configs
(#8032) (camc314)
- b2a4a78 linter: Remove unused `with_rules` and `set_rule` methods
(#8029) (camc314)
- 6da0b21 oxlint: Remove unused `git.rs` (#7990) (Boshen)
- 58e7777 oxlint: Remove extra if check in `Walkdir` (#7989) (Boshen)
- 02f968d semantic: Change `Bindings` to a plain `FxHashMap` (#8019)
(Boshen)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-30 15:47:06 +08:00
Yuichiro Yamashita
f3050d4f31
fix(linter): exclude svelte files from no_unused_vars rule (#8170) 2024-12-29 17:10:33 +00:00
Boshen
6da0b219dd refactor(oxlint): remove unused git.rs (#7990) 2024-12-18 08:41:50 +00:00
Boshen
58e7777814 refactor(oxlint): remove extra if check in Walkdir (#7989) 2024-12-18 08:37:20 +00:00
oxc-bot
fc5380442b
release(oxlint): v0.15.3 (#7954)
## [0.15.3] - 2024-12-17

### Features

- 25ddb35 linter: Add the import/no_named_default rule (#7902)
(Guillaume Piedigrossi)
- ee26b44 linter: Enhance `get_element_type` to resolve more element
types (#7885) (dalaoshu)

### Bug Fixes

- 6f41d92 linter: False positive in `unicorn/no-useless-spread` (#7940)
(dalaoshu)
- 0867b40 linter: Fix configuration parser for `no-restricted-imports`
(#7921) (Alexander S.)
- 9c9b73d linter: Fix incorrect fixer for `prefer-regexp-test` (#7898)
(Cameron)
- 32935e6 linter: False positive in
`jsx-a11y/label-has-associated-control` (#7881) (dalaoshu)
- 14c51ff semantic: Remove inherting `ScopeFlags::Modifier` from parent
scope (#7932) (Dunqing)

### Refactor

- 3858221 global: Sort imports (#7883) (overlookmotel)
- b99ee37 linter: Move rule "no-restricted-imports" to nursery (#7897)
(Alexander S.)
- ff2a68f linter/yoda: Simplify code (#7941) (overlookmotel)

### Styling

- 7fb9d47 rust: `cargo +nightly fmt` (#7877) (Boshen)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-17 12:24:09 +08:00
Boshen
7fb9d47460 style(rust): cargo +nightly fmt (#7877) 2024-12-14 06:03:31 +00:00
oxc-bot
b40c410824
release(oxlint): v0.15.2 (#7876)
## [0.15.2] - 2024-12-14

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-14 13:37:03 +08:00
oxc-bot
bb4a92c80c
release(oxlint): v0.15.1 (#7845)
## [0.15.1] - 2024-12-13

### Features

- 38b1c2e editor: Create a command to apply all auto-fixes for the
current active text editor (#7672) (Nicholas Rayburn)

### Bug Fixes

- 2b187e5 linter: Fix configuration casing for
`typescript/no_this_alias` (#7836) (Boshen)
- 06e6d38 linter: Fix unicorn/prefer-query-selector to use the correct
replacement for getElementsByClassName (#7796) (Nicholas Rayburn)
- 7a83230 semantic: Missing reference when `export default` references a
type alias binding (#7813) (Dunqing)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-13 21:23:33 +08:00
oxc-bot
bde753b4ee
release(oxlint): v0.15.0 (#7782)
## [0.15.0] - 2024-12-10

- 39b9c5d linter: [**BREAKING**] Remove unmaintained security plugin
(#7773) (Boshen)

### Features

- 065f7dc linter: Support `expectTypeOf`, `assert` and `assertType` in
`vitest/expect-expect` (#7742) (Yuichiro Yamashita)
- 3d5f0a1 linter/no_restricted_imports: Add the no_restricted_imports
rules (#7629) (Guillaume Piedigrossi)

### Bug Fixes

- ad27b20 linter: Only resolve esm files for import plugin (#7720)
(Boshen)
- 5e6053f linter: False positive in `eslint/yoda` (#7719) (dalaoshu)

### Refactor

- c6a19aa linter: Remove unused `serde` features (#7738) (Boshen)
- b9a2b35 linter: Remove `aho-corasick` (#7718) (Boshen)

### Testing

- 62f0a22 linter: Port `react-jsx-uses-vars` rules to no_unused_vars
(#7731) (Tyler Earls)
- 02f9903 linter: Add regression tests for `import/namespace` (#7723)
(dalaoshu)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2024-12-11 00:58:03 +08:00