diff --git a/crates/rome_diagnostics_categories/src/categories.rs b/crates/rome_diagnostics_categories/src/categories.rs index 84208087450..92cda8580a6 100644 --- a/crates/rome_diagnostics_categories/src/categories.rs +++ b/crates/rome_diagnostics_categories/src/categories.rs @@ -97,7 +97,7 @@ define_categories! { "lint/nursery/useLiteralKeys": "https://docs.rome.tools/lint/rules/useLiteralKeys", "lint/nursery/useSimpleNumberKeys": "https://docs.rome.tools/lint/rules/useSimpleNumberKeys", "lint/nursery/noStaticOnlyClass": "https://docs.rome.tools/lint/rules/noStaticOnlyClass", - "lint/nursery/noDuplicateKeys": "https://docs.rome.tools/lint/rules/noDuplicateKeys", + "lint/nursery/noDuplicateJsonKeys": "https://docs.rome.tools/lint/rules/noDuplicateJsonKeys", "lint/nursery/useNamingConvention": "https://docs.rome.tools/lint/rules/useNamingConvention", // Insert new nursery rule here diff --git a/crates/rome_json_analyze/src/analyzers/nursery.rs b/crates/rome_json_analyze/src/analyzers/nursery.rs index ee8a3dcc81e..a2adc2faec9 100644 --- a/crates/rome_json_analyze/src/analyzers/nursery.rs +++ b/crates/rome_json_analyze/src/analyzers/nursery.rs @@ -1,5 +1,5 @@ //! Generated file, do not edit by hand, see `xtask/codegen` use rome_analyze::declare_group; -pub(crate) mod no_duplicate_keys; -declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_duplicate_keys :: NoDuplicateKeys ,] } } +pub(crate) mod no_duplicate_json_keys; +declare_group! { pub (crate) Nursery { name : "nursery" , rules : [self :: no_duplicate_json_keys :: NoDuplicateJsonKeys ,] } } diff --git a/crates/rome_json_analyze/src/analyzers/nursery/no_duplicate_keys.rs b/crates/rome_json_analyze/src/analyzers/nursery/no_duplicate_json_keys.rs similarity index 96% rename from crates/rome_json_analyze/src/analyzers/nursery/no_duplicate_keys.rs rename to crates/rome_json_analyze/src/analyzers/nursery/no_duplicate_json_keys.rs index ffd90b39515..0953dcee895 100644 --- a/crates/rome_json_analyze/src/analyzers/nursery/no_duplicate_keys.rs +++ b/crates/rome_json_analyze/src/analyzers/nursery/no_duplicate_json_keys.rs @@ -26,9 +26,9 @@ declare_rule! { /// "secondTitle": "Second title" /// } /// ``` - pub(crate) NoDuplicateKeys { + pub(crate) NoDuplicateJsonKeys { version: "next", - name: "noDuplicateKeys", + name: "noDuplicateJsonKeys", recommended: true, } } @@ -40,7 +40,7 @@ pub(crate) struct DuplicatedKeys { duplicated_keys: Vec, } -impl Rule for NoDuplicateKeys { +impl Rule for NoDuplicateJsonKeys { type Query = Ast; type State = DuplicatedKeys; type Signals = Option; diff --git a/crates/rome_json_analyze/tests/specs/nursery/noDuplicateKeys/invalid.json b/crates/rome_json_analyze/tests/specs/nursery/noDuplicateJsonKeys/invalid.json similarity index 100% rename from crates/rome_json_analyze/tests/specs/nursery/noDuplicateKeys/invalid.json rename to crates/rome_json_analyze/tests/specs/nursery/noDuplicateJsonKeys/invalid.json diff --git a/crates/rome_json_analyze/tests/specs/nursery/noDuplicateKeys/invalid.json.snap b/crates/rome_json_analyze/tests/specs/nursery/noDuplicateJsonKeys/invalid.json.snap similarity index 87% rename from crates/rome_json_analyze/tests/specs/nursery/noDuplicateKeys/invalid.json.snap rename to crates/rome_json_analyze/tests/specs/nursery/noDuplicateJsonKeys/invalid.json.snap index 0249422f2a8..c1c2a2a9598 100644 --- a/crates/rome_json_analyze/tests/specs/nursery/noDuplicateKeys/invalid.json.snap +++ b/crates/rome_json_analyze/tests/specs/nursery/noDuplicateJsonKeys/invalid.json.snap @@ -15,7 +15,7 @@ expression: invalid.json # Diagnostics ``` -invalid.json:2:2 lint/nursery/noDuplicateKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ +invalid.json:2:2 lint/nursery/noDuplicateJsonKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ! The key foo was already declared. diff --git a/crates/rome_json_analyze/tests/specs/nursery/noDuplicateKeys/valid.json b/crates/rome_json_analyze/tests/specs/nursery/noDuplicateJsonKeys/valid.json similarity index 100% rename from crates/rome_json_analyze/tests/specs/nursery/noDuplicateKeys/valid.json rename to crates/rome_json_analyze/tests/specs/nursery/noDuplicateJsonKeys/valid.json diff --git a/crates/rome_json_analyze/tests/specs/nursery/noDuplicateKeys/valid.json.snap b/crates/rome_json_analyze/tests/specs/nursery/noDuplicateJsonKeys/valid.json.snap similarity index 100% rename from crates/rome_json_analyze/tests/specs/nursery/noDuplicateKeys/valid.json.snap rename to crates/rome_json_analyze/tests/specs/nursery/noDuplicateJsonKeys/valid.json.snap diff --git a/crates/rome_service/src/configuration/linter/rules.rs b/crates/rome_service/src/configuration/linter/rules.rs index 6ccbb48bd23..6cdaf8e5b26 100644 --- a/crates/rome_service/src/configuration/linter/rules.rs +++ b/crates/rome_service/src/configuration/linter/rules.rs @@ -1821,6 +1821,15 @@ pub struct Nursery { #[bpaf(long("no-constant-condition"), argument("on|off|warn"), optional, hide)] #[serde(skip_serializing_if = "Option::is_none")] pub no_constant_condition: Option, + #[doc = "Disallow two keys with the same name inside a JSON object."] + #[bpaf( + long("no-duplicate-json-keys"), + argument("on|off|warn"), + optional, + hide + )] + #[serde(skip_serializing_if = "Option::is_none")] + pub no_duplicate_json_keys: Option, #[doc = "Prevents JSX properties to be assigned multiple times."] #[bpaf( long("no-duplicate-jsx-props"), @@ -1830,10 +1839,6 @@ pub struct Nursery { )] #[serde(skip_serializing_if = "Option::is_none")] pub no_duplicate_jsx_props: Option, - #[doc = "Disallow two keys with the same name inside a JSON object."] - #[bpaf(long("no-duplicate-keys"), argument("on|off|warn"), optional, hide)] - #[serde(skip_serializing_if = "Option::is_none")] - pub no_duplicate_keys: Option, #[doc = "Prefer for...of statement instead of Array.forEach."] #[bpaf(long("no-for-each"), argument("on|off|warn"), optional, hide)] #[serde(skip_serializing_if = "Option::is_none")] @@ -1933,8 +1938,8 @@ impl Nursery { "noConfusingArrow", "noConsoleLog", "noConstantCondition", + "noDuplicateJsonKeys", "noDuplicateJsxProps", - "noDuplicateKeys", "noForEach", "noNoninteractiveTabindex", "noRedundantRoles", @@ -1956,8 +1961,8 @@ impl Nursery { "noAriaUnsupportedElements", "noBannedTypes", "noConstantCondition", + "noDuplicateJsonKeys", "noDuplicateJsxProps", - "noDuplicateKeys", "noRedundantRoles", "noSelfAssign", "noStaticOnlyClass", @@ -2047,12 +2052,12 @@ impl Nursery { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[5])); } } - if let Some(rule) = self.no_duplicate_jsx_props.as_ref() { + if let Some(rule) = self.no_duplicate_json_keys.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[6])); } } - if let Some(rule) = self.no_duplicate_keys.as_ref() { + if let Some(rule) = self.no_duplicate_jsx_props.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[7])); } @@ -2171,12 +2176,12 @@ impl Nursery { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[5])); } } - if let Some(rule) = self.no_duplicate_jsx_props.as_ref() { + if let Some(rule) = self.no_duplicate_json_keys.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[6])); } } - if let Some(rule) = self.no_duplicate_keys.as_ref() { + if let Some(rule) = self.no_duplicate_jsx_props.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[7])); } @@ -2299,8 +2304,8 @@ impl Nursery { "noConfusingArrow" => self.no_confusing_arrow.as_ref(), "noConsoleLog" => self.no_console_log.as_ref(), "noConstantCondition" => self.no_constant_condition.as_ref(), + "noDuplicateJsonKeys" => self.no_duplicate_json_keys.as_ref(), "noDuplicateJsxProps" => self.no_duplicate_jsx_props.as_ref(), - "noDuplicateKeys" => self.no_duplicate_keys.as_ref(), "noForEach" => self.no_for_each.as_ref(), "noNoninteractiveTabindex" => self.no_noninteractive_tabindex.as_ref(), "noRedundantRoles" => self.no_redundant_roles.as_ref(), diff --git a/crates/rome_service/src/configuration/parse/json/rules.rs b/crates/rome_service/src/configuration/parse/json/rules.rs index d2743e9732f..b78d96dfb94 100644 --- a/crates/rome_service/src/configuration/parse/json/rules.rs +++ b/crates/rome_service/src/configuration/parse/json/rules.rs @@ -1354,8 +1354,8 @@ impl VisitNode for Nursery { "noConfusingArrow", "noConsoleLog", "noConstantCondition", + "noDuplicateJsonKeys", "noDuplicateJsxProps", - "noDuplicateKeys", "noForEach", "noNoninteractiveTabindex", "noRedundantRoles", @@ -1499,16 +1499,16 @@ impl VisitNode for Nursery { )); } }, - "noDuplicateJsxProps" => match value { + "noDuplicateJsonKeys" => match value { AnyJsonValue::JsonStringValue(_) => { let mut configuration = RuleConfiguration::default(); self.map_to_known_string(&value, name_text, &mut configuration, diagnostics)?; - self.no_duplicate_jsx_props = Some(configuration); + self.no_duplicate_json_keys = Some(configuration); } AnyJsonValue::JsonObjectValue(_) => { let mut configuration = RuleConfiguration::default(); self.map_to_object(&value, name_text, &mut configuration, diagnostics)?; - self.no_duplicate_jsx_props = Some(configuration); + self.no_duplicate_json_keys = Some(configuration); } _ => { diagnostics.push(DeserializationDiagnostic::new_incorrect_type( @@ -1517,16 +1517,16 @@ impl VisitNode for Nursery { )); } }, - "noDuplicateKeys" => match value { + "noDuplicateJsxProps" => match value { AnyJsonValue::JsonStringValue(_) => { let mut configuration = RuleConfiguration::default(); self.map_to_known_string(&value, name_text, &mut configuration, diagnostics)?; - self.no_duplicate_keys = Some(configuration); + self.no_duplicate_jsx_props = Some(configuration); } AnyJsonValue::JsonObjectValue(_) => { let mut configuration = RuleConfiguration::default(); self.map_to_object(&value, name_text, &mut configuration, diagnostics)?; - self.no_duplicate_keys = Some(configuration); + self.no_duplicate_jsx_props = Some(configuration); } _ => { diagnostics.push(DeserializationDiagnostic::new_incorrect_type( diff --git a/editors/vscode/configuration_schema.json b/editors/vscode/configuration_schema.json index f5c3d371ff7..a18f78bb78f 100644 --- a/editors/vscode/configuration_schema.json +++ b/editors/vscode/configuration_schema.json @@ -778,15 +778,15 @@ { "type": "null" } ] }, - "noDuplicateJsxProps": { - "description": "Prevents JSX properties to be assigned multiple times.", + "noDuplicateJsonKeys": { + "description": "Disallow two keys with the same name inside a JSON object.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" }, { "type": "null" } ] }, - "noDuplicateKeys": { - "description": "Disallow two keys with the same name inside a JSON object.", + "noDuplicateJsxProps": { + "description": "Prevents JSX properties to be assigned multiple times.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" }, { "type": "null" } diff --git a/npm/backend-jsonrpc/src/workspace.ts b/npm/backend-jsonrpc/src/workspace.ts index 8e79b2f8e8b..803a93db3a2 100644 --- a/npm/backend-jsonrpc/src/workspace.ts +++ b/npm/backend-jsonrpc/src/workspace.ts @@ -526,13 +526,13 @@ export interface Nursery { */ noConstantCondition?: RuleConfiguration; /** - * Prevents JSX properties to be assigned multiple times. + * Disallow two keys with the same name inside a JSON object. */ - noDuplicateJsxProps?: RuleConfiguration; + noDuplicateJsonKeys?: RuleConfiguration; /** - * Disallow two keys with the same name inside a JSON object. + * Prevents JSX properties to be assigned multiple times. */ - noDuplicateKeys?: RuleConfiguration; + noDuplicateJsxProps?: RuleConfiguration; /** * Prefer for...of statement instead of Array.forEach. */ @@ -1105,7 +1105,7 @@ export type Category = | "lint/nursery/useLiteralKeys" | "lint/nursery/useSimpleNumberKeys" | "lint/nursery/noStaticOnlyClass" - | "lint/nursery/noDuplicateKeys" + | "lint/nursery/noDuplicateJsonKeys" | "lint/nursery/useNamingConvention" | "lint/performance/noDelete" | "lint/security/noDangerouslySetInnerHtml" diff --git a/npm/rome/configuration_schema.json b/npm/rome/configuration_schema.json index f5c3d371ff7..a18f78bb78f 100644 --- a/npm/rome/configuration_schema.json +++ b/npm/rome/configuration_schema.json @@ -778,15 +778,15 @@ { "type": "null" } ] }, - "noDuplicateJsxProps": { - "description": "Prevents JSX properties to be assigned multiple times.", + "noDuplicateJsonKeys": { + "description": "Disallow two keys with the same name inside a JSON object.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" }, { "type": "null" } ] }, - "noDuplicateKeys": { - "description": "Disallow two keys with the same name inside a JSON object.", + "noDuplicateJsxProps": { + "description": "Prevents JSX properties to be assigned multiple times.", "anyOf": [ { "$ref": "#/definitions/RuleConfiguration" }, { "type": "null" } diff --git a/website/src/pages/lint/rules/index.mdx b/website/src/pages/lint/rules/index.mdx index 6d84912222d..ff26fcd0848 100644 --- a/website/src/pages/lint/rules/index.mdx +++ b/website/src/pages/lint/rules/index.mdx @@ -933,16 +933,16 @@ Disallow the use of console.log Disallow constant expressions in conditions
-

- noDuplicateJsxProps +

+ noDuplicateJsonKeys

-Prevents JSX properties to be assigned multiple times. +Disallow two keys with the same name inside a JSON object.
-

- noDuplicateKeys +

+ noDuplicateJsxProps

-Disallow two keys with the same name inside a JSON object. +Prevents JSX properties to be assigned multiple times.

diff --git a/website/src/pages/lint/rules/noDuplicateKeys.md b/website/src/pages/lint/rules/noDuplicateJsonKeys.md similarity index 92% rename from website/src/pages/lint/rules/noDuplicateKeys.md rename to website/src/pages/lint/rules/noDuplicateJsonKeys.md index da2a70e9bb0..6f17d9a41e2 100644 --- a/website/src/pages/lint/rules/noDuplicateKeys.md +++ b/website/src/pages/lint/rules/noDuplicateJsonKeys.md @@ -1,9 +1,9 @@ --- -title: Lint Rule noDuplicateKeys +title: Lint Rule noDuplicateJsonKeys parent: lint/rules/index --- -# noDuplicateKeys (since vnext) +# noDuplicateJsonKeys (since vnext) Disallow two keys with the same name inside a JSON object. @@ -18,7 +18,7 @@ Disallow two keys with the same name inside a JSON object. } ``` -
nursery/noDuplicateKeys.js:2:3 lint/nursery/noDuplicateKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
nursery/noDuplicateJsonKeys.js:2:3 lint/nursery/noDuplicateJsonKeys ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
    The key title was already declared.