Skip to content

Commit 304590a

Browse files
authored
Merge pull request #2635 from ljharb/eslint7
[New] support eslint v7
2 parents d66f467 + 35030a0 commit 304590a

11 files changed

+157
-45
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ env:
2020
global:
2121
- TEST=true
2222
matrix:
23+
- ESLINT=7
2324
- ESLINT=6
2425
- ESLINT=5
2526
- ESLINT=4
@@ -39,5 +40,11 @@ matrix:
3940
env: ESLINT=6
4041
- node_js: '6'
4142
env: ESLINT=6
43+
- node_js: '4'
44+
env: ESLINT=7
45+
- node_js: '6'
46+
env: ESLINT=7
47+
- node_js: '8'
48+
env: ESLINT=7
4249
allow_failures:
4350
- node_js: '11'

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"@typescript-eslint/parser": "^2.24.0",
4848
"babel-eslint": "^8.2.6",
4949
"coveralls": "^3.0.9",
50-
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0",
50+
"eslint": "^3 || ^4 || ^5 || ^6 || ^7",
5151
"eslint-config-airbnb-base": "^13.2.0",
5252
"eslint-plugin-eslint-plugin": "^2.2.1",
5353
"eslint-plugin-import": "^2.20.1",
@@ -60,7 +60,7 @@
6060
"typescript-eslint-parser": "^20.1.1"
6161
},
6262
"peerDependencies": {
63-
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0"
63+
"eslint": "^3 || ^4 || ^5 || ^6 || ^7"
6464
},
6565
"engines": {
6666
"node": ">=4"

tests/lib/rules/forbid-prop-types.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,20 @@ ruleTester.run('forbid-prop-types', rule, {
572572
' preview: PropTypes.bool,',
573573
'}, componentApi, teaserListProps);'
574574
].join('\n')
575+
}, {
576+
code: [
577+
'var First = createReactClass({',
578+
' propTypes: {',
579+
' s: PropTypes.shape({',
580+
' o: PropTypes.object',
581+
' })',
582+
' },',
583+
' render: function() {',
584+
' return <div />;',
585+
' }',
586+
'});'
587+
].join('\n'),
588+
errors: 0 // TODO: fix #1673 and move this to "invalid"
575589
}],
576590

577591
invalid: [{
@@ -709,20 +723,6 @@ ruleTester.run('forbid-prop-types', rule, {
709723
'});'
710724
].join('\n'),
711725
errors: 2
712-
}, {
713-
code: [
714-
'var First = createReactClass({',
715-
' propTypes: {',
716-
' s: PropTypes.shape({,',
717-
' o: PropTypes.object',
718-
' })',
719-
' },',
720-
' render: function() {',
721-
' return <div />;',
722-
' }',
723-
'});'
724-
].join('\n'),
725-
errors: 1
726726
}, {
727727
code: [
728728
'var First = createReactClass({',

tests/lib/rules/jsx-closing-bracket-location.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ ruleTester.run('jsx-closing-bracket-location', rule, {
11611161
')'
11621162
].join('\n'),
11631163
options: [{location: 'line-aligned'}],
1164-
errors: [MESSAGE_AFTER_TAG]
1164+
errors: MESSAGE_AFTER_TAG
11651165
}, {
11661166
code: [
11671167
'<div className={[',
@@ -1664,7 +1664,7 @@ ruleTester.run('jsx-closing-bracket-location', rule, {
16641664
')'
16651665
].join('\n'),
16661666
options: [{location: 'line-aligned'}],
1667-
errors: [MESSAGE_AFTER_TAG]
1667+
errors: MESSAGE_AFTER_TAG
16681668
}, {
16691669
code: [
16701670
'<div className={[',

tests/lib/rules/jsx-curly-brace-presence.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,12 +655,14 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
655655
{
656656
code: `<App prop='foo &middot; bar' />`,
657657
errors: [{message: missingCurlyMessage}],
658-
options: [{props: 'always'}]
658+
options: [{props: 'always'}],
659+
output: `<App prop={"foo &middot; bar"} />`
659660
},
660661
{
661662
code: '<App>foo &middot; bar</App>',
662663
errors: [{message: missingCurlyMessage}],
663-
options: [{children: 'always'}]
664+
options: [{children: 'always'}],
665+
output: '<App>{"foo &middot; bar"}</App>'
664666
},
665667
{
666668
code: `<App>{'foo "bar"'}</App>`,
@@ -689,7 +691,18 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
689691
errors: [
690692
{message: missingCurlyMessage}, {message: missingCurlyMessage}
691693
],
692-
options: ['always']
694+
options: ['always'],
695+
output: [
696+
'<App prop=" ',
697+
' a ',
698+
' b c',
699+
' d',
700+
'">',
701+
' {"a"}',
702+
' {"b c "}',
703+
' {"d "}',
704+
'</App>'
705+
].join('\n')
693706
},
694707
{
695708
code: [
@@ -706,7 +719,18 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
706719
errors: [
707720
{message: missingCurlyMessage}, {message: missingCurlyMessage}
708721
],
709-
options: ['always']
722+
options: ['always'],
723+
output: [
724+
`<App prop=' `,
725+
' a ',
726+
' b c',
727+
' d',
728+
`'>`,
729+
' {"a"}',
730+
' {"b c "}',
731+
' {"d "}',
732+
'</App>'
733+
].join('\n')
710734
},
711735
{
712736
code: `

tests/lib/rules/jsx-indent.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,15 +1134,15 @@ const Component = () => (
11341134
// two lines following. I *think* because it incorrectly uses <App>'s indention
11351135
// as the baseline for the next two, instead of the realizing the entire three
11361136
// lines are wrong together. See #608
1137-
/* output: [
1137+
output: [
11381138
'function App() {',
11391139
' return (',
11401140
' <App>',
1141-
' <Foo />',
1142-
' </App>',
1141+
' <Foo />',
1142+
'</App>',
11431143
' );',
11441144
'}'
1145-
].join('\n'), */
1145+
].join('\n'),
11461146
options: [2],
11471147
errors: [{message: 'Expected indentation of 4 space characters but found 0.'}]
11481148
}, {
@@ -1781,7 +1781,14 @@ const Component = () => (
17811781
].join('\n'),
17821782
errors: [
17831783
{message: 'Expected indentation of 4 space characters but found 2.'}
1784-
]
1784+
],
1785+
output: [
1786+
'<p>',
1787+
' <div>',
1788+
' <SelfClosingTag />Text',
1789+
' </div>',
1790+
'</p>'
1791+
].join('\n')
17851792
}, {
17861793
code: `
17871794
const Component = () => (

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ ruleTester.run('jsx-sort-props', rule, {
401401
},
402402
{
403403
code: '<App a="a" onBar onFoo z x />;',
404-
errors: [shorthandAndCallbackLastArgs],
404+
errors: [expectedError],
405405
options: shorthandLastArgs,
406406
output: '<App a="a" onBar onFoo x z />;'
407407
},

tests/lib/rules/jsx-uses-vars.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,23 @@ ruleTester.run('prefer-const', rulePreferConst, {
215215
let App = <div />;
216216
<App />;
217217
`,
218-
errors: [{message: '\'App\' is never reassigned. Use \'const\' instead.'}]
218+
errors: [{message: '\'App\' is never reassigned. Use \'const\' instead.'}],
219+
output: `
220+
/* eslint jsx-uses-vars:1 */
221+
const App = <div />;
222+
<App />;
223+
`
219224
}, {
220225
code: `
221226
/* eslint jsx-uses-vars:1 */
222227
let filters = 'foo';
223228
<div>{filters}</div>;
224229
`,
225-
errors: [{message: '\'filters\' is never reassigned. Use \'const\' instead.'}]
230+
errors: [{message: '\'filters\' is never reassigned. Use \'const\' instead.'}],
231+
output: `
232+
/* eslint jsx-uses-vars:1 */
233+
const filters = 'foo';
234+
<div>{filters}</div>;
235+
`
226236
}]
227237
});

tests/lib/rules/no-typos.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ ruleTester.run('no-typos', rule, {
944944
type: 'MethodDefinition'
945945
}, {
946946
message: ERROR_MESSAGE_LIFECYCLE_METHOD('Render', 'render'),
947-
nodeType: 'MethodDefinition'
947+
type: 'MethodDefinition'
948948
}]
949949
}, {
950950
code: `
@@ -1616,7 +1616,7 @@ ruleTester.run('no-typos', rule, {
16161616
parserOptions,
16171617
errors: [{
16181618
message: ERROR_MESSAGE_STATIC('getDerivedStateFromProps'),
1619-
nodeType: 'MethodDefinition'
1619+
type: 'MethodDefinition'
16201620
}]
16211621
}, {
16221622
code: `
@@ -1628,10 +1628,10 @@ ruleTester.run('no-typos', rule, {
16281628
parserOptions,
16291629
errors: [{
16301630
message: ERROR_MESSAGE_STATIC('GetDerivedStateFromProps'),
1631-
nodeType: 'MethodDefinition'
1631+
type: 'MethodDefinition'
16321632
}, {
16331633
message: ERROR_MESSAGE_LIFECYCLE_METHOD('GetDerivedStateFromProps', 'getDerivedStateFromProps'),
1634-
nodeType: 'MethodDefinition'
1634+
type: 'MethodDefinition'
16351635
}]
16361636
}, {
16371637
code: `

tests/lib/rules/no-unknown-property.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,12 @@ ruleTester.run('no-unknown-property', rule, {
8585
errors: [{message: 'Unknown property \'clip-path\' found, use \'clipPath\' instead'}]
8686
}, {
8787
code: '<script crossorigin />',
88-
errors: [{message: 'Unknown property \'crossorigin\' found, use \'crossOrigin\' instead'}]
88+
errors: [{message: 'Unknown property \'crossorigin\' found, use \'crossOrigin\' instead'}],
89+
output: '<script crossOrigin />'
8990
}, {
9091
code: '<div crossorigin />',
91-
errors: [{message: 'Unknown property \'crossorigin\' found, use \'crossOrigin\' instead'}]
92+
errors: [{message: 'Unknown property \'crossorigin\' found, use \'crossOrigin\' instead'}],
93+
output: '<div crossOrigin />'
9294
}, {
9395
code: '<div crossOrigin />',
9496
errors: [{message: 'Invalid property \'crossOrigin\' found on tag \'div\', but it is only allowed on: script, img, video, audio, link'}]

0 commit comments

Comments
 (0)