Commit Graph

2615 Commits

Author SHA1 Message Date
Boshen 62bffede65 refactor(rust): allow a few annoying clippy rules (#9588)
Seems like an annoying rule

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-03-07 20:16:08 +08:00
Sysix 4ca62abe43 fix(linter): output right file line and column for .vue, .astro and .svelte files (#9484)
closes #9333
2025-03-05 17:46:38 +00:00
camchenry 934a3873cc test(linter): remove test dependency on oxlint (#9513)
Moves test fixtures around so that `oxc_linter` doesn't need to depend on test fixtures in `oxlint`.
2025-03-04 04:04:27 +00:00
camchenry 310515973d fix(linter): do not output number of rules with nested configs (#9476)
This is a small output update to fix some noisy snapshot tests that output the number of rules. When using nested configs, outputting the number of rules is not helpful I think since it varies from file to file, but open to feedback on this.
2025-03-04 04:04:27 +00:00
camchenry 41f32eafb2 feat(linter): allow adding more overrides via extends configs (#9475)
- closes https://github.com/oxc-project/oxc/issues/9307

Implements basic support for appending to the `overrides` array via configuration files referenced with `extends`.
2025-03-04 03:54:46 +00:00
camchenry fb7cf10549 feat(linter): allowing plugins to be extended with extends (#9473)
Adds support for merging the `plugins` arrays in configuration files referenced in `extends` to the top-level `plugins` array of a configuration file. Essentially acts as if you had placed it in the plugins array at the top-level to begin with.
2025-03-04 03:54:45 +00:00
camchenry 5ecda01c7f fix(linter): support nested extending (#9472)
- part of https://github.com/oxc-project/oxc/issues/9307

Allows for using the `extends` keyword to chain multiple extended config files together: for example, a package config that extends a base config that extends a config from `node_modules` and so on.

I don't really love what we're having to do here with using both `override_rules` and `ConfigStoreBuilder.with_rule`. I think there is a refactoring opportunity to merge some functionality together here, but I don't want to refactor and optimize before we have a more comprehensive test suite.
2025-03-04 03:37:17 +00:00
camchenry fc748490e9 feat(linter): inherit rules via the extended config files (#9308)
- part of https://github.com/oxc-project/oxc/issues/9307

This gives the `extends` keyword some functionality: specifically to allow inheriting rules from other configuration files. Rules that are in the extended configuration will be used as the base, and then files in the config doing the extending will override the extended rules.

So, you can, for example, specify a base configuration that defines rules that you generally want to be enabled. Then, in each nested configuration file, you could disable rules depending on the directory:

```text
.oxlintrc.json       // { "rules: { "no-useless-escape": "error" } }
package1/
  .oxlintrc.json     // { "extends": ["../.oxlintrc.json"], "rules": { "no-useless-escape": "off" } }
package2/
  src                // uses ../.oxlintrc.json with `no-useless-escape` enabled
```

As a side effect of this, building a config from a `.oxlintrc.json` file can result in config errors, even if all of the syntax and rules are configured correctly, because an extended configuration file might be incorrect or unparseable. For now, we simply raise an error if this occurs and stop execution, but in the future we could make this more graceful if we wanted and just ignore that file.

We will also need to revisit performance here, as I think a global cache config might be necessary so that we never load a file more than once and parse it more than once.
2025-03-04 02:37:03 +00:00
oxc-bot a84f6c2a00 release(oxlint): v0.15.13 (#9523)
## [0.15.13] - 2025-03-04

### Features

- 7bb0121 linter: Add `react/no-namespace` (#9404) (Mikhail Baev)
- 0a7ca20 linter: Support allowable method diagnostic for
eslint/no-console (#9454) (Boshen)
- d99bc51 linter: Add import/no-absolute-path rule (#9415) (yefan)
- 8c71590 linter: Add import/no-mutable-exports rule (#9434) (yefan)
- b65f8a5 linter: Add `promise/no-nesting` (#9345) (Tom)
- d38e6de linter: Add `eslint/no-spaced-func` (#9360) (Tom)
- 25392de linter: Add eslint/operator-assignment rule (#9208) (yefan)
- bf77167 linter: Add `curly` rule (#8123) (Yuichiro Yamashita)
- e3b6eeb linter: Add `unicorn/consistent-date-clone` (#9346) (Amol
Bhave)
- 5ee2cab linter: Improve no_invalid_fetch_options (#9347)
(Brooooooklyn)
- 4ad328b linter: Add oxc/no-redundant-constructor-init (#9299) (Ben
Jones)

### Bug Fixes

- c4624a6 linter: Fix panic in `import/no-absolute-path` (#9500)
(camc314)
- 4b0327b linter: False positive in `eslint/curly` (#9471) (Kevin Deng
三咲智子)
- 8804555 linter: Skip `no-absolute-path` tests on windows (#9435)
(Cameron)
- 06fe76d linter: Rule `no-restricted-imports` use right span for
exports statements (#9442) (Sysix)
- 3da3565 linter: Rule `unicorn/no-invalid-fetch-options` (#9416) (Tom)
- 85fbe8c linter: Rule `eslint/radix` look into globals config (#9407)
(Sysix)
- 1113e3b linter: Rule `eslint/no-object-constructor` look into globals
config (#9406) (Sysix)
- 0217ebb linter: Support more cases for no_redundant_constructor_init
(#9364) (Ben Jones)

### Documentation

- 24850e7 linter: Add example of how configure rule (#9469) (Cédric
DIRAND)
- acb1e2c linter: Add end code tag on rule doc (#9470) (Cédric DIRAND)
- d43b456 linter: Add full documentation to rule `no-restricted-imports`
(#9440) (Sysix)

### Refactor

- ffec3f6 linter: Improve `eslint/no-new` (#9423) (Tom)
- 7c27f10 linter: Move rule `no-restricted-imports` to category
`restriction` (#9443) (Sysix)
- 7e118a3 linter: Improve `typescript/explicit-function-return-type`
(#9439) (Tom)
- 5318cf2 linter: Improve `eslint/no-spaced-func` (#9419) (shulaoda)
- 802f00e linter: Use the `javascript-globals` crate (#9412) (Boshen)
- bff83c9 linter: Improve `eslint/no-unsafe-negation` (#9362) (dalaoshu)
- 228bf99 linter: Improve `unicorn/empty-brace-spaces` (#9341)
(dalaoshu)
- 55d071b linter: Improve `unicorn/consistent-existence-index-check`
(#9339) (dalaoshu)
- 17acece linter: Improve `eslint/no-template-curly-in-string` (#9090)
(dalaoshu)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-03-04 09:46:19 +08:00
Ben Jones 4ad328bdc1 feat(linter): add oxc/no-redundant-constructor-init (#9299)
closes #9267
2025-02-24 19:28:49 +08:00
oxc-bot 6764b8d7ec release(oxlint): v0.15.12 (#9300) 2025-02-24 15:42:32 +08:00
camchenry e49c92d0c2 test(linter): ensure CLI filters take precedence over nested configs (#9156)
- part of https://github.com/oxc-project/oxc/issues/7408

Adds some regression tests to ensure that filters like `-D <rule>` or `-A <rule>` will override whatever is loaded from a configuration file that is either automatically loaded as a nested config, or explicitly loaded from the `--config` option.
2025-02-22 23:15:29 +00:00
camchenry 4ed9d765b8 fix(linter): do not use nested configs with --config option (#9155)
- part of https://github.com/oxc-project/oxc/issues/7408

Ensures that when a config file is explicitly passed via `-c` or `--config`, that file will take precedence over all nested config files, and we will not search for config files within any directories.
2025-02-22 23:15:29 +00:00
camchenry 9bc301725b feat(linter): add support for nested config files (#9153)
- part of https://github.com/oxc-project/oxc/issues/7408

This is the initial implementation for nested config support, without the `extends` keyword factoring into it yet. So we only load a single config file for any given file still, but it will always be the one closest to the file being linted.

Performance is somewhat of a big TODO here, obviously there is some inherent cost to adding support for nested configurations since we need to check if any directory contains an `.oxlintrc.json` file, load it if it exists, and then for every file below that directory check if we should use it. I've left a few TODOs of different ways we might be able to cache more data at the cost of memory but at the potential gain of some CPU time. Optimizing iteration over files/directories is one way in which we might be able to make this faster, so we never need to visit the same directory twice.

For now, this will remain an experimental feature that should not affect the current functionality until we enable it for everyone. PRs stacked on top of this will focus on ensuring that other features work well with this, such as `--config`, `-D <rule>`, and then we'll add new features like `extends`.

The configuration loading all happens upfront currently, while the config resolution happens at lint-time. There is a new `nested_configs` field on the `Linter` that passes all of the configs that are available, so it can pick which one to use later. Eventually we'll refactor this to not have two duplicate config fields, but I'm leaving it as-is to ensure we're not messing up the existing functionality.
2025-02-22 22:43:55 +00:00
Boshen 1d81adac48 Rust Edition 2024 (#9289)
closes #9271

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-02-22 11:56:25 +08:00
camchenry cded0add23 feat(oxlint): add --experimental-nested-config option (#9152)
- part of https://github.com/oxc-project/oxc/issues/7408

Since the nested configuration work is too big to fit in one PR or even a stack of PRs, I suggest that we make it temporarily an opt-in CLI flag. Once we feel confident in the implementation replacing the existing code, we can remove the flag and make it true by default.
2025-02-20 02:40:46 +00:00
Boshen 9f361819b9 refactor(rust): apply cllippy::nursery rules (#9232) 2025-02-20 01:51:04 +00:00
Boshen 63bb214555 refactor(oxc): apply clippy::redundant_clone (#9252) 2025-02-20 01:28:55 +00:00
Mikhail Baev cc8dd48e37 feat(linter): add unicorn/no-invalid-fetch-options rule (#9212)
This PR implements
[unicorn/no-invalid-fetch-options](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v56.0.1/docs/rules/no-invalid-fetch-options.md)
rule

issue: https://github.com/oxc-project/oxc/issues/684

---------

Co-authored-by: shulaoda <laipichan@qq.com>
2025-02-19 19:40:37 +01:00
dalaoshu af13b1b9df feat(linter): promote eslint/no-eval to correctness (#9231)
closes #9188
2025-02-19 23:26:45 +08:00
Sysix 542bbd77ed feat(linter): support import-x plugin name (#9074)
closes #8779

The `import-x` rules are the reimplementation of the `import` rules. No rules added or removed.
Some eslint-plugins/configs are handling the plugin the same way.

Here a snippet from a config which `next-auth` is using:
https://github.com/antfu/eslint-config/blob/998887cedb0b09c5b95d08602689a2c86e6662c7/src/factory.ts#L56-L67

Could not find more places where some mapping is happening. Please have a look because I did not test it.
2025-02-18 19:44:12 +00:00
oxc-bot 7f5c5d2c10 release(oxlint): v0.15.11 (#9150) 2025-02-16 09:17:05 +08:00
Sysix 47c16495f9 fix(linter): output line/column for --format=stylish instead of offset + length (#9136)
closes #9098
2025-02-15 16:00:57 +00:00
Sysix 5d508a4418 feat(linter): support env and globals in overrides configuration (#8915)
This PR supports `env` and `globals` keys in `overrides[x]`.

I added tests where I could. Snapshot CLI tests are working 🥳
2025-02-09 12:41:00 +00:00
overlookmotel a4a8e7deda style(all): replace #[allow] with #[expect] (#8930)
Replace `#[allow]` with `#[expect]` through the whole codebase.

This also surfaced many places where the `#[allow]` attributes were outdated/pointless and could be removed entirely.

Only places `#[allow]` remains are:

1. In generated code and macros, where lint errors may or may not be triggered depending on the generated code.
2. A few places where clippy malfunctions. These use e.g. `#[allow(unused, clippy::allow_attributes)]`.
2025-02-07 14:50:02 +00:00
oxc-bot 6942d2d0fb release(oxlint): v0.15.10 (#8918)
## [0.15.10] - 2025-02-06

### Features

- d6d80f7 linter: Add suggestion fixer for `eslint/no-iterator` (#8894)
(dalaoshu)
- 7e8568b linter: Junit reporter (#8756) (Tapan Prakash)
- f4662a9 oxc_language_server: Implement `oxc.fixAll` workspace command
(#8858) (Marek Vospel)

### Bug Fixes

- baf3e4e linter: Correctly replace rule severity with duplicate rule
name configurations (#8840) (dalaoshu)

### Performance

- 8a4988d linter: Use parallel iterator directly instead of iter and
parallel bridge (#8831) (Cam McHenry)

### Refactor

- bb9d763 linter: Remove usage of `url` crate (#8833) (camchenry)
- 4fcf719 linter: Replace MIME guessing with extension check (#8832)
(camchenry)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
2025-02-06 14:35:37 +08:00
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`.


https://github.com/oxc-project/oxc/blob/655b2126889a3307929a1a20047b317c1eefb140/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:
https://github.com/oxc-project/oxc/blob/4a2f2a9cd996cacf85b9e14467397d34497f6e96/apps/oxlint/src/output_formatter/default.rs#L84-L110

Bug found here:
https://github.com/oxc-project/oxc/blob/659c225c5683363c8bd5ac78444ce7ce349b43e3/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:

https://github.com/oxc-project/oxc/blob/c15af02e52e124f3968b098d487e28b49d937b56/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