Skip to content

Commit 80323a5

Browse files
ROSSROSALESljharb
authored andcommitted
to satisfy ESLint version > 3
1 parent 15f89e2 commit 80323a5

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

lib/rules/jsx-sort-props.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,8 @@ function getGroupsOfSortableAttributes(attributes, context) {
153153
const attribute = attributes[i];
154154
const nextAttribute = attributes[i + 1];
155155
const attributeline = attribute.loc.start.line;
156-
const comment = sourceCode.getCommentsAfter(attribute);
156+
const comment = sourceCode.getCommentsAfter(attribute) ? sourceCode.getCommentsAfter(attribute) : [];
157157
const lastAttr = attributes[i - 1];
158-
159158
const attrIsSpread = attribute.type === 'JSXSpreadAttribute';
160159

161160
// If we have no groups or if the last attribute was JSXSpreadAttribute

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

+11-10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
const RuleTester = require('eslint').RuleTester;
1313
const semver = require('semver');
14+
const eslintPkg = require('eslint/package.json');
1415
const rule = require('../../../lib/rules/jsx-sort-props');
1516

1617
const parsers = require('../../helpers/parsers');
@@ -821,7 +822,7 @@ ruleTester.run('jsx-sort-props', rule, {
821822
},
822823
],
823824
},
824-
{
825+
semver.satisfies(eslintPkg.version, '> 3') ? {
825826
code: `
826827
<foo
827828
m={0}
@@ -870,8 +871,8 @@ ruleTester.run('jsx-sort-props', rule, {
870871
line: 11,
871872
},
872873
],
873-
},
874-
{
874+
} : [],
875+
semver.satisfies(eslintPkg.version, '> 3') ? {
875876
code: `
876877
<foo
877878
m={0}
@@ -924,8 +925,8 @@ ruleTester.run('jsx-sort-props', rule, {
924925
line: 11,
925926
},
926927
],
927-
},
928-
{
928+
} : [],
929+
semver.satisfies(eslintPkg.version, '> 3') ? {
929930
code: `
930931
<foo
931932
a1={0}
@@ -980,8 +981,8 @@ ruleTester.run('jsx-sort-props', rule, {
980981
line: 12,
981982
},
982983
],
983-
},
984-
{
984+
} : [],
985+
semver.satisfies(eslintPkg.version, '> 3') ? {
985986
code: `
986987
<foo
987988
a1={0}
@@ -1028,8 +1029,8 @@ ruleTester.run('jsx-sort-props', rule, {
10281029
line: 12,
10291030
},
10301031
],
1031-
},
1032-
{
1032+
} : [],
1033+
semver.satisfies(eslintPkg.version, '> 3') ? {
10331034
code: `
10341035
<foo a={0} b={1} /* comment for b and ab */ ab={1} aa={0} />
10351036
`,
@@ -1046,6 +1047,6 @@ ruleTester.run('jsx-sort-props', rule, {
10461047
line: 2,
10471048
},
10481049
],
1049-
},
1050+
} : [],
10501051
]),
10511052
});

0 commit comments

Comments
 (0)