Skip to content

Comments

refactor(eslint): convert with_labels to with_label where applicable#3946

Merged
DonIsaac merged 1 commit intooxc-project:mainfrom
jelly:eslint-with-labels
Jun 27, 2024
Merged

refactor(eslint): convert with_labels to with_label where applicable#3946
DonIsaac merged 1 commit intooxc-project:mainfrom
jelly:eslint-with-labels

Conversation

@jelly
Copy link
Contributor

@jelly jelly commented Jun 27, 2024

Following earlier work in d6437fe 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 #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, 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)

Following earlier work in d6437fe prefer `with_label` over
`with_labels`. Automatically converted using CoccinelleForRust.
@github-actions github-actions bot added the A-linter Area - Linter label Jun 27, 2024
@graphite-app
Copy link
Contributor

graphite-app bot commented Jun 27, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

@codspeed-hq
Copy link

codspeed-hq bot commented Jun 27, 2024

CodSpeed Performance Report

Merging #3946 will not alter performance

Comparing jelly:eslint-with-labels (c6f1c5f) with main (4e3e1a3)

Summary

✅ 28 untouched benchmarks

@DonIsaac DonIsaac added the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label Jun 27, 2024
@DonIsaac DonIsaac merged commit 1cca2a8 into oxc-project:main Jun 27, 2024
@jelly jelly deleted the eslint-with-labels branch June 27, 2024 19:18
DonIsaac pushed a commit that referenced this pull request Jun 27, 2024
@github-actions github-actions bot mentioned this pull request Jun 29, 2024
Boshen added a commit that referenced this pull request Jun 29, 2024
## [0.5.1] - 2024-06-29

### Features

- f64ad4b semantic: Make jsdoc building optional (turned off by default)
(#3955) (Boshen)

### Bug Fixes

- c26975a linter: Only show the filename for max-lines (#3966) (Boshen)
- 94329e4 linter: Handle useful but empty constructors in
no-useless-constructor (#3951) (DonIsaac)
- 6498a08 linter: No-useless-spread fixer with multiple spread elements
(#3950) (DonIsaac)
- 750cb43 oxlint: Gate custom allocators by feature flag (#3945) (Luca
Bruno)

### Refactor

- 1cca2a8 eslint: Convert with_labels to with_label where applicable
(#3946) (Jelle van der Waa)
- 2705df9 linter: Improve diagnostic labeling (#3960) (DonIsaac)

Co-authored-by: Boshen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants