diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js index a3ff43ab4e..ccb7cec206 100644 --- a/lib/rules/jsx-sort-props.js +++ b/lib/rules/jsx-sort-props.js @@ -290,7 +290,7 @@ module.exports = { } if (!previousIsReserved && currentIsReserved) { context.report({ - node: decl, + node: decl.name, message: 'Reserved props must be listed before all other props', fix: generateFixerFunction(node, context, reservedList) }); @@ -306,7 +306,7 @@ module.exports = { if (previousIsCallback && !currentIsCallback) { // Encountered a non-callback prop after a callback prop context.report({ - node: memo, + node: memo.name, message: 'Callbacks must be listed after all other props', fix: generateFixerFunction(node, context, reservedList) }); @@ -320,7 +320,7 @@ module.exports = { } if (!currentValue && previousValue) { context.report({ - node: memo, + node: memo.name, message: 'Shorthand props must be listed before all other props', fix: generateFixerFunction(node, context, reservedList) }); @@ -334,7 +334,7 @@ module.exports = { } if (currentValue && !previousValue) { context.report({ - node: memo, + node: memo.name, message: 'Shorthand props must be listed after all other props', fix: generateFixerFunction(node, context, reservedList) }); @@ -344,7 +344,7 @@ module.exports = { if (!noSortAlphabetically && currentPropName < previousPropName) { context.report({ - node: decl, + node: decl.name, message: 'Props should be sorted alphabetically', fix: generateFixerFunction(node, context, reservedList) }); diff --git a/tests/lib/rules/jsx-sort-props.js b/tests/lib/rules/jsx-sort-props.js index bcd525982f..f044557b0e 100644 --- a/tests/lib/rules/jsx-sort-props.js +++ b/tests/lib/rules/jsx-sort-props.js @@ -28,23 +28,23 @@ const ruleTester = new RuleTester({parserOptions}); const expectedError = { message: 'Props should be sorted alphabetically', - type: 'JSXAttribute' + type: 'JSXIdentifier' }; const expectedCallbackError = { message: 'Callbacks must be listed after all other props', - type: 'JSXAttribute' + type: 'JSXIdentifier' }; const expectedShorthandFirstError = { message: 'Shorthand props must be listed before all other props', - type: 'JSXAttribute' + type: 'JSXIdentifier' }; const expectedShorthandLastError = { message: 'Shorthand props must be listed after all other props', - type: 'JSXAttribute' + type: 'JSXIdentifier' }; const expectedReservedFirstError = { message: 'Reserved props must be listed before all other props', - type: 'JSXAttribute' + type: 'JSXIdentifier' }; const expectedEmptyReservedFirstError = { message: 'A customized reserved first list must not be empty'