From f8c5be68c3ecd0378ee7a8b6b804943c3ccb2502 Mon Sep 17 00:00:00 2001 From: Adam Vigneaux Date: Wed, 20 Aug 2025 14:16:29 -0500 Subject: [PATCH 1/2] Mention priority ordering in `sort-attrs` documentation A coworker expressed confusion about why `type` would be sorted before `class` when the rule's error message says "Attributes should be sorted alphabetically." Updating the rule's error message and documentation to mention the priority sorting behavior should avoid future confusion. --- docs/rules/sort-attrs.md | 2 +- packages/eslint-plugin/lib/rules/sort-attrs.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/rules/sort-attrs.md b/docs/rules/sort-attrs.md index f2fb7ced..a599b50c 100644 --- a/docs/rules/sort-attrs.md +++ b/docs/rules/sort-attrs.md @@ -1,6 +1,6 @@ # sort-attrs -This rule enforces alphabetical sorting of attributes. +This rule enforces priority-based and alphabetical sorting of attributes. ## How to use diff --git a/packages/eslint-plugin/lib/rules/sort-attrs.js b/packages/eslint-plugin/lib/rules/sort-attrs.js index ca3edb9b..e78e6f85 100644 --- a/packages/eslint-plugin/lib/rules/sort-attrs.js +++ b/packages/eslint-plugin/lib/rules/sort-attrs.js @@ -24,7 +24,7 @@ module.exports = { type: "code", docs: { - description: "Enforce attributes alphabetical sorting", + description: "Enforce priority and alphabetical sorting of attributes", category: RULE_CATEGORY.STYLE, recommended: false, url: getRuleUrl("sort-attrs"), @@ -60,7 +60,7 @@ module.exports = { }, ], messages: { - [MESSAGE_IDS.UNSORTED]: "Attributes should be sorted alphabetically", + [MESSAGE_IDS.UNSORTED]: "Attributes should be sorted by priority and alphabetically", }, }, create(context) { From adff639db2899a936e63cd13f986e77f50c56633 Mon Sep 17 00:00:00 2001 From: YeonJuan Date: Fri, 22 Aug 2025 00:46:04 +0900 Subject: [PATCH 2/2] Update packages/eslint-plugin/lib/rules/sort-attrs.js --- packages/eslint-plugin/lib/rules/sort-attrs.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/eslint-plugin/lib/rules/sort-attrs.js b/packages/eslint-plugin/lib/rules/sort-attrs.js index e78e6f85..3ec56b43 100644 --- a/packages/eslint-plugin/lib/rules/sort-attrs.js +++ b/packages/eslint-plugin/lib/rules/sort-attrs.js @@ -60,7 +60,8 @@ module.exports = { }, ], messages: { - [MESSAGE_IDS.UNSORTED]: "Attributes should be sorted by priority and alphabetically", + [MESSAGE_IDS.UNSORTED]: + "Attributes should be sorted by priority and alphabetically", }, }, create(context) {