oxc/crates
Jelle van der Waa 1cca2a8d92
refactor(eslint): convert with_labels to with_label where applicable (#3946)
Following earlier work in d6437fec0b prefer `with_label` over
`with_labels`. Automatically converted using CoccinelleForRust.

---

I noticed some conversions of `with_labels` to `with_label` for a single
span in https://github.com/oxc-project/oxc/pull/3854 and in my recent
pull requests. The Linux kernel uses Coccinelle to automatically
converted helper functions, so I was wondering if there was something
similar for Rust as Coccinelle only does C. It turns out that there is a
[Coccinelle for
Rust](https://gitlab.inria.fr/coccinelle/coccinelleforrust), so I wrote
a small Coccinelle rule to automatically convert all rules. (This PR
only touches eslint, I am happy to run it for the whole rules directory,
this is more a test if the project is willing to accept such massive
automatic refactors).

To convert this automatically build the tool, and save the snippet below
as `with_labels.cocci` and run:

```
~/code/coccinelleforrust/target/debug/cfr --apply --coccifile with_labels.cocci  crates/oxc_linter/src/rules/eslint
```

with_labels.cocci:
```
@@
expression E, OxcDiagnostic;
@@

OxcDiagnostic.
- with_labels([E.into()])
+ with_label(E)
```
2024-06-27 15:11:19 -04:00
..
oxc Release crates v0.16.0 (#3930) 2024-06-27 20:38:31 +08:00
oxc_allocator Release crates v0.16.0 (#3930) 2024-06-27 20:38:31 +08:00
oxc_ast Release crates v0.16.0 (#3930) 2024-06-27 20:38:31 +08:00
oxc_ast_macros Release crates v0.16.0 (#3930) 2024-06-27 20:38:31 +08:00
oxc_cfg Release crates v0.16.0 (#3930) 2024-06-27 20:38:31 +08:00
oxc_codegen Release crates v0.16.0 (#3930) 2024-06-27 20:38:31 +08:00
oxc_diagnostics Release crates v0.16.0 (#3930) 2024-06-27 20:38:31 +08:00
oxc_index Release crates v0.16.0 (#3930) 2024-06-27 20:38:31 +08:00
oxc_isolated_declarations Release crates v0.16.0 (#3930) 2024-06-27 20:38:31 +08:00
oxc_js_regex chore: crates should only publish src and examples directory 2024-06-08 16:35:16 +08:00
oxc_language_server refactor(linter): LintContext can now only be constructed with a cfg enabled semantic. (#3761) 2024-06-19 13:01:33 +00:00
oxc_linter refactor(eslint): convert with_labels to with_label where applicable (#3946) 2024-06-27 15:11:19 -04:00
oxc_macros chore: do not compile test crates that have no tests 2024-06-24 00:20:04 +08:00
oxc_minifier Release crates v0.16.0 (#3930) 2024-06-27 20:38:31 +08:00
oxc_module_lexer Release crates v0.16.0 (#3930) 2024-06-27 20:38:31 +08:00
oxc_parser Release crates v0.16.0 (#3930) 2024-06-27 20:38:31 +08:00
oxc_prettier refactor(parser): improve parsing of TypeScript types (#3903) 2024-06-26 05:58:16 +00:00
oxc_semantic Release crates v0.16.0 (#3930) 2024-06-27 20:38:31 +08:00
oxc_sourcemap Release crates v0.16.0 (#3930) 2024-06-27 20:38:31 +08:00
oxc_span Release crates v0.16.0 (#3930) 2024-06-27 20:38:31 +08:00
oxc_syntax Release crates v0.16.0 (#3930) 2024-06-27 20:38:31 +08:00
oxc_transformer Release crates v0.16.0 (#3930) 2024-06-27 20:38:31 +08:00
oxc_traverse Release crates v0.16.0 (#3930) 2024-06-27 20:38:31 +08:00
oxc_wasm refactor(linter): LintContext can now only be constructed with a cfg enabled semantic. (#3761) 2024-06-19 13:01:33 +00:00