Skip to content

Commit

Permalink
Issue#2366 sorted attributes respects comments, cleaned up syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
ROSSROSALES committed Aug 16, 2022
1 parent 51ed373 commit 5c690e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
8 changes: 3 additions & 5 deletions lib/rules/jsx-sort-props.js
Expand Up @@ -6,7 +6,6 @@
'use strict';

const propName = require('jsx-ast-utils/propName');
//const astUtils = require(".node_modules\eslint\lib\rules\utils\ast-utils.js");
const includes = require('array-includes');
const docsUrl = require('../util/docsUrl');
const jsxUtil = require('../util/jsx');
Expand All @@ -29,7 +28,7 @@ const messages = {
listIsEmpty: 'A customized reserved first list must not be empty',
listReservedPropsFirst: 'Reserved props must be listed before all other props',
listCallbacksLast: 'Callbacks must be listed after all other props',
listShorthandFirst: 'S horthand props must be listed before all other props',
listShorthandFirst: 'Shorthand props must be listed before all other props',
listShorthandLast: 'Shorthand props must be listed after all other props',
listMultilineFirst: 'Multiline props must be listed before all other props',
listMultilineLast: 'Multiline props must be listed after all other props',
Expand Down Expand Up @@ -236,7 +235,7 @@ const generateFixerFunction = (node, context, reservedList) => {
const sortableAttributeGroups = getGroupsOfSortableAttributes(attributes, context);
const sortedAttributeGroups = sortableAttributeGroups
.slice(0)
.map((group) => group.slice(0).sort((a, b) => contextCompare(a, b, options) ));
.map((group) => group.slice(0).sort((a, b) => contextCompare(a, b, options)));

return function fixFunction(fixer) {
const fixers = [];
Expand All @@ -257,7 +256,7 @@ const generateFixerFunction = (node, context, reservedList) => {
fixers.sort((a, b) => b.range[0] - a.range[0]);

const rangeStart = fixers[fixers.length - 1].range[0];
const rangeEnd = fixers[0].range[1];
const rangeEnd = fixers[0].range[1];

fixers.forEach((fix) => {
source = `${source.substr(0, fix.range[0])}${fix.text}${source.substr(fix.range[1])}`;
Expand Down Expand Up @@ -329,7 +328,6 @@ function reportNodeAttribute(nodeAttribute, errorType, node, context, reservedLi
report(context, messages[errorType], errorType, {
node: nodeAttribute.name,
fix: generateFixerFunction(node, context, reservedList),

});
}

Expand Down
1 change: 0 additions & 1 deletion tests/lib/rules/jsx-sort-props.js
Expand Up @@ -119,7 +119,6 @@ const multilineAndShorthandAndCallbackLastArgs = [
callbacksLast: true,
},
];
//const commentbetween = [{ commentbetween: true }];

ruleTester.run('jsx-sort-props', rule, {
valid: parsers.all([].concat(
Expand Down

0 comments on commit 5c690e0

Please sign in to comment.