From 35a33f10f38600141ff53ee9b81383b201ebd38d Mon Sep 17 00:00:00 2001 From: Simon Kataev Date: Fri, 15 Nov 2024 10:02:00 +0100 Subject: [PATCH] [New] `jsx-sort-props`: add `className` to `RESERVED_PROPS_LIST` --- docs/rules/jsx-sort-props.md | 4 ++-- lib/rules/jsx-sort-props.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/rules/jsx-sort-props.md b/docs/rules/jsx-sort-props.md index b51209f32e..4a357a2fbb 100644 --- a/docs/rules/jsx-sort-props.md +++ b/docs/rules/jsx-sort-props.md @@ -122,7 +122,7 @@ When `true`, alphabetical order is **not** enforced: This can be a boolean or an array option. -When `reservedFirst` is defined, React reserved props (`children`, `dangerouslySetInnerHTML` - **only for DOM components**, `key`, and `ref`) must be listed before all other props, but still respecting the alphabetical order: +When `reservedFirst` is defined, React reserved props (`children`, `dangerouslySetInnerHTML` - **only for DOM components**, `key`, and `ref`) or `className` must be listed before all other props, but still respecting the alphabetical order: ```jsx @@ -130,7 +130,7 @@ When `reservedFirst` is defined, React reserved props (`children`, `dangerouslyS ``` -If given as an array, the array's values will override the default list of reserved props. **Note**: the values in the array may only be a **subset** of React reserved props. +If given as an array, the array's values will override the default list of reserved props. **Note**: the values in the array may only be a **subset** of React reserved props or `className`. With `reservedFirst: ["key"]`, the following will **not** warn: diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js index ec9d869b74..e8135aed6c 100644 --- a/lib/rules/jsx-sort-props.js +++ b/lib/rules/jsx-sort-props.js @@ -43,6 +43,7 @@ const RESERVED_PROPS_LIST = [ 'dangerouslySetInnerHTML', 'key', 'ref', + 'className', ]; function isReservedPropName(name, list) {