Skip to content

Commit 1e102f0

Browse files
committed
Change reported range to only the identifier
1 parent e6b4c33 commit 1e102f0

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/rules/jsx-sort-props.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ module.exports = {
290290
}
291291
if (!previousIsReserved && currentIsReserved) {
292292
context.report({
293-
node: decl,
293+
node: decl.name,
294294
message: 'Reserved props must be listed before all other props',
295295
fix: generateFixerFunction(node, context, reservedList)
296296
});
@@ -306,7 +306,7 @@ module.exports = {
306306
if (previousIsCallback && !currentIsCallback) {
307307
// Encountered a non-callback prop after a callback prop
308308
context.report({
309-
node: memo,
309+
node: memo.name,
310310
message: 'Callbacks must be listed after all other props',
311311
fix: generateFixerFunction(node, context, reservedList)
312312
});
@@ -320,7 +320,7 @@ module.exports = {
320320
}
321321
if (!currentValue && previousValue) {
322322
context.report({
323-
node: memo,
323+
node: memo.name,
324324
message: 'Shorthand props must be listed before all other props',
325325
fix: generateFixerFunction(node, context, reservedList)
326326
});
@@ -334,7 +334,7 @@ module.exports = {
334334
}
335335
if (currentValue && !previousValue) {
336336
context.report({
337-
node: memo,
337+
node: memo.name,
338338
message: 'Shorthand props must be listed after all other props',
339339
fix: generateFixerFunction(node, context, reservedList)
340340
});
@@ -344,7 +344,7 @@ module.exports = {
344344

345345
if (!noSortAlphabetically && currentPropName < previousPropName) {
346346
context.report({
347-
node: decl,
347+
node: decl.name,
348348
message: 'Props should be sorted alphabetically',
349349
fix: generateFixerFunction(node, context, reservedList)
350350
});

tests/lib/rules/jsx-sort-props.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@ const ruleTester = new RuleTester({parserOptions});
2828

2929
const expectedError = {
3030
message: 'Props should be sorted alphabetically',
31-
type: 'JSXAttribute'
31+
type: 'JSXIdentifier'
3232
};
3333
const expectedCallbackError = {
3434
message: 'Callbacks must be listed after all other props',
35-
type: 'JSXAttribute'
35+
type: 'JSXIdentifier'
3636
};
3737
const expectedShorthandFirstError = {
3838
message: 'Shorthand props must be listed before all other props',
39-
type: 'JSXAttribute'
39+
type: 'JSXIdentifier'
4040
};
4141
const expectedShorthandLastError = {
4242
message: 'Shorthand props must be listed after all other props',
43-
type: 'JSXAttribute'
43+
type: 'JSXIdentifier'
4444
};
4545
const expectedReservedFirstError = {
4646
message: 'Reserved props must be listed before all other props',
47-
type: 'JSXAttribute'
47+
type: 'JSXIdentifier'
4848
};
4949
const expectedEmptyReservedFirstError = {
5050
message: 'A customized reserved first list must not be empty'

0 commit comments

Comments
 (0)