Skip to content

[Bug]: Support custom reserved words in jsx-sort-props #3639

Open
@hisuwh

Description

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
  • My issue appears in the command-line and not only in the text editor

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

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions