Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New] support eslint v7 #2635

Merged
merged 2 commits into from May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .travis.yml
Expand Up @@ -20,6 +20,7 @@ env:
global:
- TEST=true
matrix:
- ESLINT=7
- ESLINT=6
- ESLINT=5
- ESLINT=4
Expand All @@ -39,5 +40,11 @@ matrix:
env: ESLINT=6
- node_js: '6'
env: ESLINT=6
- node_js: '4'
env: ESLINT=7
- node_js: '6'
env: ESLINT=7
- node_js: '8'
env: ESLINT=7
allow_failures:
- node_js: '11'
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -47,7 +47,7 @@
"@typescript-eslint/parser": "^2.24.0",
"babel-eslint": "^8.2.6",
"coveralls": "^3.0.9",
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0",
"eslint": "^3 || ^4 || ^5 || ^6 || ^7",
"eslint-config-airbnb-base": "^13.2.0",
"eslint-plugin-eslint-plugin": "^2.2.1",
"eslint-plugin-import": "^2.20.1",
Expand All @@ -60,7 +60,7 @@
"typescript-eslint-parser": "^20.1.1"
},
"peerDependencies": {
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0"
"eslint": "^3 || ^4 || ^5 || ^6 || ^7"
},
"engines": {
"node": ">=4"
Expand Down
28 changes: 14 additions & 14 deletions tests/lib/rules/forbid-prop-types.js
Expand Up @@ -572,6 +572,20 @@ ruleTester.run('forbid-prop-types', rule, {
' preview: PropTypes.bool,',
'}, componentApi, teaserListProps);'
].join('\n')
}, {
code: [
'var First = createReactClass({',
' propTypes: {',
' s: PropTypes.shape({',
' o: PropTypes.object',
' })',
' },',
' render: function() {',
' return <div />;',
' }',
'});'
].join('\n'),
errors: 0 // TODO: fix #1673 and move this to "invalid"
}],

invalid: [{
Expand Down Expand Up @@ -709,20 +723,6 @@ ruleTester.run('forbid-prop-types', rule, {
'});'
].join('\n'),
errors: 2
}, {
code: [
'var First = createReactClass({',
' propTypes: {',
' s: PropTypes.shape({,',
' o: PropTypes.object',
' })',
' },',
' render: function() {',
' return <div />;',
' }',
'});'
].join('\n'),
errors: 1
}, {
code: [
'var First = createReactClass({',
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/rules/jsx-closing-bracket-location.js
Expand Up @@ -1161,7 +1161,7 @@ ruleTester.run('jsx-closing-bracket-location', rule, {
')'
].join('\n'),
options: [{location: 'line-aligned'}],
errors: [MESSAGE_AFTER_TAG]
errors: MESSAGE_AFTER_TAG
}, {
code: [
'<div className={[',
Expand Down Expand Up @@ -1664,7 +1664,7 @@ ruleTester.run('jsx-closing-bracket-location', rule, {
')'
].join('\n'),
options: [{location: 'line-aligned'}],
errors: [MESSAGE_AFTER_TAG]
errors: MESSAGE_AFTER_TAG
}, {
code: [
'<div className={[',
Expand Down
32 changes: 28 additions & 4 deletions tests/lib/rules/jsx-curly-brace-presence.js
Expand Up @@ -655,12 +655,14 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
{
code: `<App prop='foo &middot; bar' />`,
errors: [{message: missingCurlyMessage}],
options: [{props: 'always'}]
options: [{props: 'always'}],
output: `<App prop={"foo &middot; bar"} />`
},
{
code: '<App>foo &middot; bar</App>',
errors: [{message: missingCurlyMessage}],
options: [{children: 'always'}]
options: [{children: 'always'}],
output: '<App>{"foo &middot; bar"}</App>'
},
{
code: `<App>{'foo "bar"'}</App>`,
Expand Down Expand Up @@ -689,7 +691,18 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
errors: [
{message: missingCurlyMessage}, {message: missingCurlyMessage}
],
options: ['always']
options: ['always'],
output: [
'<App prop=" ',
' a ',
' b c',
' d',
'">',
' {"a"}',
' {"b c "}',
' {"d "}',
'</App>'
].join('\n')
},
{
code: [
Expand All @@ -706,7 +719,18 @@ ruleTester.run('jsx-curly-brace-presence', rule, {
errors: [
{message: missingCurlyMessage}, {message: missingCurlyMessage}
],
options: ['always']
options: ['always'],
output: [
`<App prop=' `,
' a ',
' b c',
' d',
`'>`,
' {"a"}',
' {"b c "}',
' {"d "}',
'</App>'
].join('\n')
},
{
code: `
Expand Down
17 changes: 12 additions & 5 deletions tests/lib/rules/jsx-indent.js
Expand Up @@ -1134,15 +1134,15 @@ const Component = () => (
// two lines following. I *think* because it incorrectly uses <App>'s indention
// as the baseline for the next two, instead of the realizing the entire three
// lines are wrong together. See #608
/* output: [
output: [
'function App() {',
' return (',
' <App>',
' <Foo />',
' </App>',
' <Foo />',
'</App>',
' );',
'}'
].join('\n'), */
].join('\n'),
options: [2],
errors: [{message: 'Expected indentation of 4 space characters but found 0.'}]
}, {
Expand Down Expand Up @@ -1781,7 +1781,14 @@ const Component = () => (
].join('\n'),
errors: [
{message: 'Expected indentation of 4 space characters but found 2.'}
]
],
output: [
'<p>',
' <div>',
' <SelfClosingTag />Text',
' </div>',
'</p>'
].join('\n')
}, {
code: `
const Component = () => (
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/rules/jsx-sort-props.js
Expand Up @@ -401,7 +401,7 @@ ruleTester.run('jsx-sort-props', rule, {
},
{
code: '<App a="a" onBar onFoo z x />;',
errors: [shorthandAndCallbackLastArgs],
errors: [expectedError],
options: shorthandLastArgs,
output: '<App a="a" onBar onFoo x z />;'
},
Expand Down
14 changes: 12 additions & 2 deletions tests/lib/rules/jsx-uses-vars.js
Expand Up @@ -215,13 +215,23 @@ ruleTester.run('prefer-const', rulePreferConst, {
let App = <div />;
<App />;
`,
errors: [{message: '\'App\' is never reassigned. Use \'const\' instead.'}]
errors: [{message: '\'App\' is never reassigned. Use \'const\' instead.'}],
output: `
/* eslint jsx-uses-vars:1 */
const App = <div />;
<App />;
`
}, {
code: `
/* eslint jsx-uses-vars:1 */
let filters = 'foo';
<div>{filters}</div>;
`,
errors: [{message: '\'filters\' is never reassigned. Use \'const\' instead.'}]
errors: [{message: '\'filters\' is never reassigned. Use \'const\' instead.'}],
output: `
/* eslint jsx-uses-vars:1 */
const filters = 'foo';
<div>{filters}</div>;
`
}]
});
8 changes: 4 additions & 4 deletions tests/lib/rules/no-typos.js
Expand Up @@ -944,7 +944,7 @@ ruleTester.run('no-typos', rule, {
type: 'MethodDefinition'
}, {
message: ERROR_MESSAGE_LIFECYCLE_METHOD('Render', 'render'),
nodeType: 'MethodDefinition'
type: 'MethodDefinition'
}]
}, {
code: `
Expand Down Expand Up @@ -1616,7 +1616,7 @@ ruleTester.run('no-typos', rule, {
parserOptions,
errors: [{
message: ERROR_MESSAGE_STATIC('getDerivedStateFromProps'),
nodeType: 'MethodDefinition'
type: 'MethodDefinition'
}]
}, {
code: `
Expand All @@ -1628,10 +1628,10 @@ ruleTester.run('no-typos', rule, {
parserOptions,
errors: [{
message: ERROR_MESSAGE_STATIC('GetDerivedStateFromProps'),
nodeType: 'MethodDefinition'
type: 'MethodDefinition'
}, {
message: ERROR_MESSAGE_LIFECYCLE_METHOD('GetDerivedStateFromProps', 'getDerivedStateFromProps'),
nodeType: 'MethodDefinition'
type: 'MethodDefinition'
}]
}, {
code: `
Expand Down
6 changes: 4 additions & 2 deletions tests/lib/rules/no-unknown-property.js
Expand Up @@ -85,10 +85,12 @@ ruleTester.run('no-unknown-property', rule, {
errors: [{message: 'Unknown property \'clip-path\' found, use \'clipPath\' instead'}]
}, {
code: '<script crossorigin />',
errors: [{message: 'Unknown property \'crossorigin\' found, use \'crossOrigin\' instead'}]
errors: [{message: 'Unknown property \'crossorigin\' found, use \'crossOrigin\' instead'}],
output: '<script crossOrigin />'
}, {
code: '<div crossorigin />',
errors: [{message: 'Unknown property \'crossorigin\' found, use \'crossOrigin\' instead'}]
errors: [{message: 'Unknown property \'crossorigin\' found, use \'crossOrigin\' instead'}],
output: '<div crossOrigin />'
}, {
code: '<div crossOrigin />',
errors: [{message: 'Invalid property \'crossOrigin\' found on tag \'div\', but it is only allowed on: script, img, video, audio, link'}]
Expand Down