-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
Description
Is there an existing issue for this?
- I have searched the existing issues and my issue is uniqueMy issue appears in the command-line and not only in the text editorTo pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Description Overview
eslint-plugin-react
seems to be the go to linting plugin for any jsx/tsx, and indeed supports other frameworks than react by specifying the pragma setting.
However, the jsx-sort-props
rule does not allow you to specify non react keywords in the reservedFirst
option:
A customized reserved first list must only contain a subset of React reserved props
I'm using Vue which has a convention where their pseudo two-way binding prop v-model
is always the first prop passed to a component - I wish to be able to enforce that for my tsx files.
"react/jsx-sort-props": [
"error",
{
"reservedFirst": ["v-model", "key", "ref"],
"multiline": "last",
"shorthandLast": true,
"callbacksLast": true
}
],
Expected Behavior
jsx-sort-props
rule reservedFirst
prop should allow non-react keywords
eslint-plugin-react version
v7.33.2
eslint version
v8.50.0
node version
v18.12.1
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
ljharb commentedon Oct 5, 2023
The only acceptable way to manage this would likely be to add a new
settings.react
config that lets you define, for the whole plugin, what the reserved prop names are, that would default to:However, for anyone who's not using vue, this seems like it has the potential to cause a lot of bugs and confusion, since some may change it for aesthetic reasons, not realizing it must only match the renderer's reserved props.
hisuwh commentedon Oct 6, 2023
@ljharb what's the reason for this?
ljharb commentedon Oct 8, 2023
Because miscategorizing reserved props can lead to user confusion and bugs.
jsx-sort-props
: addclassName
toRESERVED_PROPS_LIST
#3851jsx-sort-props
: addcustomPropsFirst
to support custom props list for sorting #3853mesqueeb commentedon Jul 31, 2025
@ljharb we use custom react directives like
x-if
andx-else
andx-for
, we want those custom directives to always be the first. How can we set custom directives like those inreservedFirst
? It would be a lot easier ifreservedFirst
could just allow any attr.Please note, we're not using Vue but React.