Skip to content

Getting an error when explicitly turning off reservedFirst or noSortAlphabetically on jsx-sort-props #1267

@cjhoward92

Description

@cjhoward92

versions:

"eslint-plugin-react": "7.1.0"
"babel-eslint": "7.2.2"
"eslint": "3.19.0"

When I try to run the following config I get two errors:

"react/jsx-sort-props": [2, { "reservedFirst": false, "noSortAlphabetically": false }]

Error:

Configuration for rule "react/jsx-sort-props" is invalid:
 Value "data["0"].reservedFirst" has additional properties.
 Value "data["0"].noSortAlphabetically" has additional properties.

at validateRuleOptions (C:\Dev\MyProject\build\node_modules\eslint\lib\config\config-validator.js:115:15)
at Object.keys.forEach.id (C:\Dev\MyProject\build\node_modules\eslint\lib\config\config-validator.js:162:13)
at Array.forEach (native)
at Object.validate (C:\Dev\MyProject\build\node_modules\eslint\lib\config\config-validator.js:161:35)
at Object.load (C:\Dev\MyProject\build\node_modules\eslint\lib\config\config-file.js:522:19)
at loadConfig (C:\Dev\MyProject\build\node_modules\eslint\lib\config.js:63:33)
at getLocalConfig (C:\Dev\MyProject\build\node_modules\eslint\lib\config.js:130:29)
at Config.getConfig (C:\Dev\MyProject\build\node_modules\eslint\lib\config.js:256:22)
at hashOfConfigFor (C:\Dev\MyProject\build\node_modules\eslint\lib\cli-engine.js:599:41)
at executeOnFile (C:\Dev\MyProject\build\node_modules\eslint\lib\cli-engine.js:648:32)

I have tried many different configurations, like:

"react/jsx-sort-props": [2, { "reservedFirst": [0, []] }]
"react/jsx-sort-props": [2, { "reservedFirst": [0, false] }]
"react/jsx-sort-props": [2, { "reservedFirst": [2, []] }]

The reason I am explicitly setting the rule is because it appears that reservedFirst breaks the default rules. We used to have our config set to

"react/jsx-sort-props": 2

for alphabetical sorting, but with this new option it appears that reserved props are always taken into account, and our linter is throwing errors because of it. The linter always looks for the following props

var RESERVED_PROPS_LIST = [
  'children',
  'dangerouslySetInnerHTML',
  'key',
  'ref'
];

Let me know if you need more info.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions