diff --git a/crates/biome_configuration/src/analyzer/assists/actions.rs b/crates/biome_configuration/src/analyzer/assists/actions.rs index 196c0068d891..95a41419e479 100644 --- a/crates/biome_configuration/src/analyzer/assists/actions.rs +++ b/crates/biome_configuration/src/analyzer/assists/actions.rs @@ -99,19 +99,20 @@ impl Actions { #[serde(rename_all = "camelCase", default, deny_unknown_fields)] #[doc = r" A list of rules that belong to this group"] pub struct Source { - #[doc = "Enforce props sorting in JSX elements."] + #[doc = "Enforce attribute sorting in JSX elements."] #[serde(skip_serializing_if = "Option::is_none")] - pub sort_jsx_props: Option, + pub use_sorted_attributes: Option, #[doc = "Sorts the keys of a JSON object in natural order"] #[serde(skip_serializing_if = "Option::is_none")] pub use_sorted_keys: Option, } impl Source { const GROUP_NAME: &'static str = "source"; - pub(crate) const GROUP_RULES: &'static [&'static str] = &["sortJsxProps", "useSortedKeys"]; + pub(crate) const GROUP_RULES: &'static [&'static str] = + &["useSortedAttributes", "useSortedKeys"]; pub(crate) fn get_enabled_rules(&self) -> FxHashSet> { let mut index_set = FxHashSet::default(); - if let Some(rule) = self.sort_jsx_props.as_ref() { + if let Some(rule) = self.use_sorted_attributes.as_ref() { if rule.is_enabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[0])); } @@ -125,7 +126,7 @@ impl Source { } pub(crate) fn get_disabled_rules(&self) -> FxHashSet> { let mut index_set = FxHashSet::default(); - if let Some(rule) = self.sort_jsx_props.as_ref() { + if let Some(rule) = self.use_sorted_attributes.as_ref() { if rule.is_disabled() { index_set.insert(RuleFilter::Rule(Self::GROUP_NAME, Self::GROUP_RULES[0])); } @@ -146,7 +147,7 @@ impl Source { rule_name: &str, ) -> Option { match rule_name { - "sortJsxProps" => self.sort_jsx_props.as_ref().copied(), + "useSortedAttributes" => self.use_sorted_attributes.as_ref().copied(), "useSortedKeys" => self.use_sorted_keys.as_ref().copied(), _ => None, } diff --git a/crates/biome_js_analyze/src/assists/source.rs b/crates/biome_js_analyze/src/assists/source.rs index bcd993b8f8fa..56815c1e5c1f 100644 --- a/crates/biome_js_analyze/src/assists/source.rs +++ b/crates/biome_js_analyze/src/assists/source.rs @@ -3,14 +3,14 @@ use biome_analyze::declare_assists_group; pub mod organize_imports; -pub mod sort_jsx_props; +pub mod use_sorted_attributes; declare_assists_group! { pub Source { name : "source" , rules : [ self :: organize_imports :: OrganizeImports , - self :: sort_jsx_props :: SortJsxProps , + self :: use_sorted_attributes :: UseSortedAttributes , ] } } diff --git a/crates/biome_js_analyze/src/assists/source/sort_jsx_props.rs b/crates/biome_js_analyze/src/assists/source/use_sorted_attributes.rs similarity index 94% rename from crates/biome_js_analyze/src/assists/source/sort_jsx_props.rs rename to crates/biome_js_analyze/src/assists/source/use_sorted_attributes.rs index 5c85875e4955..32e86e8713bf 100644 --- a/crates/biome_js_analyze/src/assists/source/sort_jsx_props.rs +++ b/crates/biome_js_analyze/src/assists/source/use_sorted_attributes.rs @@ -12,7 +12,7 @@ use biome_rowan::{AstNode, BatchMutationExt}; use crate::JsRuleAction; declare_source_rule! { - /// Enforce props sorting in JSX elements. + /// Enforce attribute sorting in JSX elements. /// /// This rule checks if the JSX props are sorted in a consistent way. /// Props are sorted alphabetically. @@ -33,17 +33,17 @@ declare_source_rule! { /// ; /// ``` /// - pub SortJsxProps { - version: "1.9.0", - name: "sortJsxProps", - language: "js", + pub UseSortedAttributes { + version: "2.0.0", + name: "useSortedAttributes", + language: "jsx", recommended: false, sources: &[RuleSource::EslintReact("jsx-sort-props")], source_kind: RuleSourceKind::SameLogic, } } -impl Rule for SortJsxProps { +impl Rule for UseSortedAttributes { type Query = Ast; type State = PropGroup; type Signals = Box<[Self::State]>; diff --git a/crates/biome_js_analyze/src/options.rs b/crates/biome_js_analyze/src/options.rs index 711f34fc7b5f..77013c5f1616 100644 --- a/crates/biome_js_analyze/src/options.rs +++ b/crates/biome_js_analyze/src/options.rs @@ -280,8 +280,6 @@ pub type NoYodaExpression = ::Options; pub type OrganizeImports = ::Options; -pub type SortJsxProps = - ::Options; pub type UseAdjacentOverloadSignatures = < lint :: nursery :: use_adjacent_overload_signatures :: UseAdjacentOverloadSignatures as biome_analyze :: Rule > :: Options ; pub type UseAltText = ::Options; pub type UseAnchorContent = @@ -395,6 +393,8 @@ pub type UseSimpleNumberKeys = pub type UseSimplifiedLogicExpression = < lint :: complexity :: use_simplified_logic_expression :: UseSimplifiedLogicExpression as biome_analyze :: Rule > :: Options ; pub type UseSingleCaseStatement = < lint :: style :: use_single_case_statement :: UseSingleCaseStatement as biome_analyze :: Rule > :: Options ; pub type UseSingleVarDeclarator = < lint :: style :: use_single_var_declarator :: UseSingleVarDeclarator as biome_analyze :: Rule > :: Options ; +pub type UseSortedAttributes = + ::Options; pub type UseSortedClasses = ::Options; pub type UseStrictMode = diff --git a/crates/biome_js_analyze/tests/specs/source/sortJsxProps/sorted.jsx b/crates/biome_js_analyze/tests/specs/source/useSortedAttributes/sorted.jsx similarity index 100% rename from crates/biome_js_analyze/tests/specs/source/sortJsxProps/sorted.jsx rename to crates/biome_js_analyze/tests/specs/source/useSortedAttributes/sorted.jsx diff --git a/crates/biome_js_analyze/tests/specs/source/sortJsxProps/sorted.jsx.snap b/crates/biome_js_analyze/tests/specs/source/useSortedAttributes/sorted.jsx.snap similarity index 100% rename from crates/biome_js_analyze/tests/specs/source/sortJsxProps/sorted.jsx.snap rename to crates/biome_js_analyze/tests/specs/source/useSortedAttributes/sorted.jsx.snap diff --git a/crates/biome_js_analyze/tests/specs/source/sortJsxProps/unsorted.jsx b/crates/biome_js_analyze/tests/specs/source/useSortedAttributes/unsorted.jsx similarity index 100% rename from crates/biome_js_analyze/tests/specs/source/sortJsxProps/unsorted.jsx rename to crates/biome_js_analyze/tests/specs/source/useSortedAttributes/unsorted.jsx diff --git a/crates/biome_js_analyze/tests/specs/source/sortJsxProps/unsorted.jsx.snap b/crates/biome_js_analyze/tests/specs/source/useSortedAttributes/unsorted.jsx.snap similarity index 100% rename from crates/biome_js_analyze/tests/specs/source/sortJsxProps/unsorted.jsx.snap rename to crates/biome_js_analyze/tests/specs/source/useSortedAttributes/unsorted.jsx.snap diff --git a/packages/@biomejs/backend-jsonrpc/src/workspace.ts b/packages/@biomejs/backend-jsonrpc/src/workspace.ts index 70664377c426..876111045cb5 100644 --- a/packages/@biomejs/backend-jsonrpc/src/workspace.ts +++ b/packages/@biomejs/backend-jsonrpc/src/workspace.ts @@ -682,9 +682,9 @@ export type VcsClientKind = "git"; */ export interface Source { /** - * Enforce props sorting in JSX elements. + * Enforce attribute sorting in JSX elements. */ - sortJsxProps?: RuleAssistConfiguration; + useSortedAttributes?: RuleAssistConfiguration; /** * Sorts the keys of a JSON object in natural order */ diff --git a/packages/@biomejs/biome/configuration_schema.json b/packages/@biomejs/biome/configuration_schema.json index 8c619a51b3f1..e9dae303ae67 100644 --- a/packages/@biomejs/biome/configuration_schema.json +++ b/packages/@biomejs/biome/configuration_schema.json @@ -3203,8 +3203,8 @@ "description": "A list of rules that belong to this group", "type": "object", "properties": { - "sortJsxProps": { - "description": "Enforce props sorting in JSX elements.", + "useSortedAttributes": { + "description": "Enforce attribute sorting in JSX elements.", "anyOf": [ { "$ref": "#/definitions/RuleAssistConfiguration" }, { "type": "null" }