[Bug]: Fixer of sort-prop-types
doesn’t respect noSortAlphabetically
#3591
Labels
sort-prop-types
doesn’t respect noSortAlphabetically
#3591
Is there an existing issue for this?
Description Overview
Unlike with
jsx-sort-props
, thesort-prop-types
rule doesn’t respect the{ noSortAlphabetically: true }
option passed when fixing the order of prop types.When
"react/sort-prop-types": ["warn", { callbacksLast: true, noSortAlphabetically: true }]
is set, the example below:Gets fixed as follows:
While the underlying
callbacksLast
issue is fixed, it appears thatnoSortAlphabetically
isn’t respected by the fixer, just as seen in the source:eslint-plugin-react/lib/rules/sort-prop-types.js
Lines 178 to 187 in ae64aa8
eslint-plugin-react/lib/rules/sort-prop-types.js
Lines 109 to 119 in ae64aa8
The
fixPropTypesSort
method doesn’t take anoSortAlphabetically
parameter.Expected Behavior
The correct fix for the snippet above would be:
Only
onClick
should be moved to the bottom, leaving the order of non-callback props intact.eslint-plugin-react version
7.32.2
eslint version
v8.43.0
node version
v16.20.0
The text was updated successfully, but these errors were encountered: