oxc/crates
camchenry d6a0d2e164 fix(linter): fix file name checking behavior of unicorn/filename-case (#6463)
- closes #6459

Currently, the `unicorn/filename-case` doesn't match the behavior of the original rule. There are several issues which this PR fixes:

- The defaults cases were incorrect: only kebab case should be enabled by default, according to the original rule docs.
- Setting a single case or multiple cases did not remove the default cases as it should.
- Leading/trailing underscores were not ignored by default.
- We did not provide a clear diagnostic message indicating which cases are allowed.
- We did not try to parse out multiple file parts (separated by `.`).
  - TODO: We should also support multiple file part checking (which the original rule supports via a config option), for file names such as `someTest.fileName.js`

I have also added many of the original test cases to ensure we are more closely compatible.

This also improves the performance of just running the `unicorn/filename-case` alone by 4% (20ms total) on the `vscode` codebase:

```
Benchmark 1: ./oxlint-main -A all -W unicorn/filename-case --silent vscode
  Time (mean ± σ):     489.4 ms ±  24.0 ms    [User: 2623.8 ms, System: 447.2 ms]
  Range (min … max):   474.7 ms … 622.9 ms    100 runs

  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.

Benchmark 2: ./oxlint-new-filename-case -A all -W unicorn/filename-case --silent vscode
  Time (mean ± σ):     470.8 ms ±  22.9 ms    [User: 2478.8 ms, System: 463.5 ms]
  Range (min … max):   455.6 ms … 599.3 ms    100 runs

  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.

Summary
  ./oxlint-new-filename-case -A all -W unicorn/filename-case --silent vscode ran
    1.04 ± 0.07 times faster than ./oxlint-main -A all -W unicorn/filename-case --silent vscode
```

Perplexingly, it seems like it might actually be even faster on the `vscode` repository, saving ~5% (70ms) with the default ruleset enabled as well. Maybe my laptop was just running a bit faster.

```
Benchmark 1: ./oxlint-main -W unicorn/filename-case --silent vscode
  Time (mean ± σ):      1.402 s ±  0.096 s    [User: 8.863 s, System: 0.505 s]
  Range (min … max):    1.318 s …  1.920 s    100 runs

  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.

Benchmark 2: ./oxlint-new-filename-case -W unicorn/filename-case --silent vscode
  Time (mean ± σ):      1.339 s ±  0.042 s    [User: 8.582 s, System: 0.511 s]
  Range (min … max):    1.266 s …  1.506 s    100 runs

Summary
  ./oxlint-new-filename-case -W unicorn/filename-case --silent vscode ran
    1.05 ± 0.08 times faster than ./oxlint-main -W unicorn/filename-case --silent vscode
```
2024-10-13 14:22:14 +00:00
..
oxc refactor(codegen)!: remove Codegen::enableSourceMap API (#6452) 2024-10-12 04:56:43 +00:00
oxc_allocator feat(allocator): add Vec::into_boxed_slice (#6195) 2024-10-12 04:29:43 +00:00
oxc_ast feat(ecmascript): add ToBoolean, ToNumber, ToString (#6502) 2024-10-13 11:03:08 +00:00
oxc_ast_macros release(crates): v0.31.0 (#6360) 2024-10-08 20:55:24 +08:00
oxc_cfg release(crates): v0.31.0 (#6360) 2024-10-08 20:55:24 +08:00
oxc_codegen refactor(codegen): rename CodeBuffer::print_bytes_unchecked method (#6517) 2024-10-13 13:14:49 +00:00
oxc_data_structures release(crates): v0.31.0 (#6360) 2024-10-08 20:55:24 +08:00
oxc_diagnostics release(crates): v0.31.0 (#6360) 2024-10-08 20:55:24 +08:00
oxc_ecmascript refactor(ecmascript): remove NumberValue (#6519) 2024-10-13 14:11:37 +00:00
oxc_index release(crates): v0.31.0 (#6360) 2024-10-08 20:55:24 +08:00
oxc_isolated_declarations refactor(ecmascript): move ToInt32 from oxc_syntax to oxc_ecmascript (#6471) 2024-10-12 09:29:46 +00:00
oxc_language_server feat(oxc_language_server): add diagnostic code with link (#6487) 2024-10-13 07:07:43 +00:00
oxc_linter fix(linter): fix file name checking behavior of unicorn/filename-case (#6463) 2024-10-13 14:22:14 +00:00
oxc_macros
oxc_mangler feat(ast)! add source_text to Program (#6444) 2024-10-11 04:13:41 +00:00
oxc_minifier refactor(ecmascript): remove NumberValue (#6519) 2024-10-13 14:11:37 +00:00
oxc_module_lexer chore(oxc): rename crate oxc_syntax_operations to oxc_ecmascript (#6469) 2024-10-12 08:34:42 +00:00
oxc_parser refactor(parser): fix typo in var name (#6500) 2024-10-13 10:14:37 +00:00
oxc_prettier refactor(prettier)!: remove source_text argument from constructor (#6448) 2024-10-11 06:27:33 +00:00
oxc_regular_expression feat(regular_expression): Support RegExp Modifiers (#6410) 2024-10-10 14:46:17 +00:00
oxc_semantic chore(oxc): rename crate oxc_syntax_operations to oxc_ecmascript (#6469) 2024-10-12 08:34:42 +00:00
oxc_sourcemap release(crates): v0.31.0 (#6360) 2024-10-08 20:55:24 +08:00
oxc_span docs(span): document validity of ModuleKind::Unambiguous (#6423) 2024-10-10 14:59:41 +00:00
oxc_syntax refactor(ecmascript): move ToInt32 from oxc_syntax to oxc_ecmascript (#6471) 2024-10-12 09:29:46 +00:00
oxc_transformer feat(transformer): support helper loader (#6162) 2024-10-13 08:09:08 +00:00
oxc_traverse chore(oxc): rename crate oxc_syntax_operations to oxc_ecmascript (#6469) 2024-10-12 08:34:42 +00:00
oxc_wasm refactor(prettier)!: remove source_text argument from constructor (#6448) 2024-10-11 06:27:33 +00:00