Skip to content

Commit

Permalink
[New] jsx-sort-props: Change reported range to only the identifier
Browse files Browse the repository at this point in the history
Merge pull request #2314 from MrHen/feature/2312-jsx-sort-props
  • Loading branch information
ljharb committed Jun 21, 2019
2 parents e6b4c33 + 1e102f0 commit 7d449a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions lib/rules/jsx-sort-props.js
Expand Up @@ -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)
});
Expand All @@ -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)
});
Expand All @@ -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)
});
Expand All @@ -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)
});
Expand All @@ -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)
});
Expand Down
10 changes: 5 additions & 5 deletions tests/lib/rules/jsx-sort-props.js
Expand Up @@ -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'
Expand Down

0 comments on commit 7d449a9

Please sign in to comment.