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(configuration): lint rules options are optional #4160

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,28 @@ New entries must be placed in a section entitled `Unreleased`.
Read
our [guidelines for writing a good changelog entry](https://github.com/biomejs/biome/blob/main/CONTRIBUTING.md#changelog).

## Unreleased

### Analyzer

### CLI

### Configuration

#### Bug fixes

- Fix an issue where the JSON schema marked lint rules options as mandatory. Contributed by @ematipico

### Editors

### Formatter

### JavaScript APIs

### Linter

### Parser

## v1.9.3 (2024-10-01)

### CLI
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_js_analyze/src/lint/a11y/no_blank_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl Rule for NoBlankTarget {

#[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)]
pub struct AllowDomainOptions {
#[serde(skip_serializing_if = "Vec::is_empty")]
/// List of domains to allow `target="_blank"` without `rel="noreferrer"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ declare_lint_rule! {

#[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)]
pub struct ValidAriaRoleOptions {
pub allow_invalid_roles: Vec<String>,
pub ignore_non_dom: bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ pub struct ComplexityScore {
/// Options for the rule `noExcessiveCognitiveComplexity`.
#[derive(Clone, Debug, Deserialize, Deserializable, Eq, PartialEq, Serialize)]
#[cfg_attr(feature = "schema", derive(JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
pub struct ComplexityOptions {
/// The maximum complexity score that we allow. Anything higher is considered excessive.
pub max_allowed_complexity: NonZeroU8,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ impl Default for HookConfigMaps {
/// Options for the rule `useExhaustiveDependencies`
#[derive(Clone, Debug, Deserialize, Deserializable, Eq, PartialEq, Serialize)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
pub struct UseExhaustiveDependenciesOptions {
/// Whether to report an error when a dependency is listed in the dependencies array but isn't used. Defaults to true.
#[serde(default = "report_unnecessary_dependencies_default")]
Expand All @@ -318,7 +318,7 @@ fn report_unnecessary_dependencies_default() -> bool {

#[derive(Clone, Debug, Default, Deserialize, Deserializable, Eq, PartialEq, Serialize)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
#[deserializable(with_validator)]
pub struct Hook {
/// The name of the hook.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ impl Rule for UseHookAtTopLevel {
/// hook.
#[derive(Default, Deserialize, Serialize, Eq, PartialEq, Debug, Clone)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
pub struct DeprecatedHooksOptions {}

impl Deserializable for DeprecatedHooksOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ declare_lint_rule! {

#[derive(Clone, Debug, Default, Deserializable, Deserialize, Serialize, Eq, PartialEq)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
pub struct UseImportExtensionsOptions {
/// A map of custom import extension mappings, where the key is the inspected file extension,
/// and the value is a pair of `module` extension and `component` import extension
Expand All @@ -135,7 +135,7 @@ pub struct UseImportExtensionsOptions {

#[derive(Debug, Clone, Default, Deserializable, Deserialize, Serialize, Eq, PartialEq)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
pub struct SuggestedExtensionMapping {
/// Extension that should be used for module imports
pub module: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ declare_lint_rule! {
/// Options for the rule `noRestrictedImports`.
#[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)]
pub struct RestrictedImportsOptions {
/// A list of names that should trigger the rule
#[serde(skip_serializing_if = "FxHashMap::is_empty")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl Rule for NoRestrictedTypes {
PartialEq,
)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
pub struct NoRestrictedTypesOptions {
types: FxHashMap<String, CustomRestrictedType>,
}
Expand All @@ -140,7 +140,7 @@ pub struct NoRestrictedTypesOptions {
PartialEq,
)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
pub struct CustomRestrictedTypeOptions {
message: String,
#[serde(rename = "use")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ declare_lint_rule! {

#[derive(Debug, Clone, Deserialize, Deserializable, Eq, PartialEq, Serialize, Default)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
pub struct UseComponentExportOnlyModulesOptions {
/// Allows the export of constants. This option is for environments that support it, such as [Vite](https://vitejs.dev/)
#[serde(default)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ declare_lint_rule! {

#[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)]
pub struct ConsistentMemberAccessibilityOptions {
pub accessibility: Accessibility,
}
Expand All @@ -247,7 +247,8 @@ impl Rule for UseConsistentMemberAccessibility {
fn run(ctx: &RuleContext<Self>) -> Self::Signals {
let node = ctx.query();
let accessibility = node.accessibility_modifier();
match ctx.options().accessibility {
let options = ctx.options();
match &options.accessibility {
Accessibility::NoPublic => accessibility
.filter(|accessibility| accessibility.is_public())
.map(|accessibility| accessibility.range()),
Expand All @@ -257,7 +258,12 @@ impl Rule for UseConsistentMemberAccessibility {
}

fn diagnostic(ctx: &RuleContext<Self>, range: &Self::State) -> Option<RuleDiagnostic> {
let (diag_msg, note_msg) = match ctx.options().accessibility {
let options = ctx.options();
// let accessibility_option = match &options.accessibility {
// None => &Accessibility::default(),
// Some(option) => option,
// };
let (diag_msg, note_msg) = match &options.accessibility {
Accessibility::NoPublic => (
markup! {
"The "<Emphasis>"public"</Emphasis>" modifier is disallowed."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const CLASS_ATTRIBUTES: [&str; 2] = ["class", "className"];

#[derive(Deserialize, Serialize, Eq, PartialEq, Debug, Clone)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
pub struct UtilityClassSortingOptions {
/// Additional attributes that will be sorted.
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const BILLING_AND_SHIPPING_ADDRESS: &[&str; 11] = &[

#[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)]
pub struct UseValidAutocompleteOptions {
/// `input` like custom components that should be checked.
pub input_components: Vec<String>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const RESTRICTED_GLOBALS: [&str; 2] = ["event", "error"];
/// Options for the rule `noRestrictedGlobals`.
#[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)]
pub struct RestrictedGlobalsOptions {
/// A list of names that should trigger the rule
#[serde(skip_serializing_if = "Vec::is_empty")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ where

#[derive(Clone, Debug, Default, Deserialize, Deserializable, Eq, PartialEq, Serialize)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
pub struct ConsistentArrayTypeOptions {
pub syntax: ConsistentArrayType,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ pub enum FileNamingConventionState {
/// Rule's options.
#[derive(Clone, Debug, Deserialize, Deserializable, Eq, PartialEq, Serialize)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
ematipico marked this conversation as resolved.
Show resolved Hide resolved
pub struct FilenamingConventionOptions {
/// If `false`, then consecutive uppercase are allowed in _camel_ and _pascal_ cases.
/// This does not affect other [Case].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ fn renamable(
/// Rule's options.
#[derive(Debug, Clone, Deserializable, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
ematipico marked this conversation as resolved.
Show resolved Hide resolved
pub struct NamingConventionOptions {
/// If `false`, then consecutive uppercase are allowed in _camel_ and _pascal_ cases.
/// This does not affect other [Case].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl Rule for NoDoubleEquals {
/// Rule's options
#[derive(Clone, Debug, Deserializable, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
#[serde(rename_all = "camelCase", deny_unknown_fields, default)]
ematipico marked this conversation as resolved.
Show resolved Hide resolved
pub struct NoDoubleEqualsOptions {
/// If `true`, an exception is made when comparing with `null`, as it's often relied on to check
/// both for `null` or `undefined`.
Expand Down
18 changes: 9 additions & 9 deletions packages/@biomejs/backend-jsonrpc/src/workspace.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading