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)
```