Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lint): options for noLabelWithoutControl are optional #4138

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ematipico
Copy link
Member

@ematipico ematipico commented Sep 30, 2024

Summary

Closes #4125

I updated the contribution guide too. I took the opportunity to do some small refactor, and move functions inside the options struct, so we don't pass around the same object.

Test Plan

CI should pass. I checked the code generated files manually.

@ematipico ematipico requested review from a team September 30, 2024 12:10
@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages A-Changelog Area: changelog labels Sep 30, 2024
Copy link

codspeed-hq bot commented Sep 30, 2024

CodSpeed Performance Report

Merging #4138 will degrade performances by 6.34%

Comparing fix/no-label-without-control (ee2ba26) with main (53f1420)

Summary

❌ 1 regressions
✅ 100 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main fix/no-label-without-control Change
db_17847247775464589309.json[cached] 12.8 ms 13.6 ms -6.34%

@@ -159,14 +152,124 @@ impl Rule for NoLabelWithoutControl {

#[derive(Clone, Debug, Default, Deserialize, Deserializable, Eq, PartialEq, Serialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
Copy link
Member

@Conaclos Conaclos Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the serde(default) attribute should be enough to make optional the fields.
Is there an interest to have both Option<> and serde(default)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed it might make more sense to use plain Vecs only. It uses less memory, and makes consuming code easier. The only exception should be when an empty vector and None are semantically different.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try the serde(default), but the issue is the schema, not the default values.

CHANGELOG.md Outdated Show resolved Hide resolved
@@ -161,16 +161,16 @@ We would like to set the options in the `biome.json` configuration file:
}
```

The first step is to create the Rust data representation of the rule's options.
The first step is to create the Rust data representation of the rule's options. Each option must be wrapped in a `Option`, this is required so the configuration schema won't mark them as required.
Copy link
Contributor

@arendjr arendjr Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And then I see this as motivation for the Option wrappers :) Could we make the configuration schema respect the default annotations in addition to only Option?

Co-authored-by: Arend van Beelen jr. <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Changelog Area: changelog A-Linter Area: linter L-JavaScript Language: JavaScript and super languages
Projects
None yet
3 participants