From 906b474cb52879c52974610ee5a133a125e62f09 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 7 May 2020 15:09:40 -0700 Subject: [PATCH 1/2] [New] support eslint v7 --- .travis.yml | 7 +++++++ package.json | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a7d00fe10a..d7637abed9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ env: global: - TEST=true matrix: + - ESLINT=7 - ESLINT=6 - ESLINT=5 - ESLINT=4 @@ -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' diff --git a/package.json b/package.json index 77be18cf50..acf6a24f0d 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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" From 35030a0819f49ff2eb95b291959e349026afe19b Mon Sep 17 00:00:00 2001 From: toshi-toma Date: Sat, 9 May 2020 12:10:09 +0900 Subject: [PATCH 2/2] [Tests] fix mistaken error property and add output property --- tests/lib/rules/forbid-prop-types.js | 28 +++---- .../lib/rules/jsx-closing-bracket-location.js | 4 +- tests/lib/rules/jsx-curly-brace-presence.js | 32 +++++++- tests/lib/rules/jsx-indent.js | 17 ++-- tests/lib/rules/jsx-sort-props.js | 2 +- tests/lib/rules/jsx-uses-vars.js | 14 +++- tests/lib/rules/no-typos.js | 8 +- tests/lib/rules/no-unknown-property.js | 6 +- tests/lib/rules/prefer-read-only-props.js | 80 ++++++++++++++++--- 9 files changed, 148 insertions(+), 43 deletions(-) diff --git a/tests/lib/rules/forbid-prop-types.js b/tests/lib/rules/forbid-prop-types.js index 63eff5087a..aa48f1401a 100644 --- a/tests/lib/rules/forbid-prop-types.js +++ b/tests/lib/rules/forbid-prop-types.js @@ -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
;', + ' }', + '});' + ].join('\n'), + errors: 0 // TODO: fix #1673 and move this to "invalid" }], invalid: [{ @@ -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
;', - ' }', - '});' - ].join('\n'), - errors: 1 }, { code: [ 'var First = createReactClass({', diff --git a/tests/lib/rules/jsx-closing-bracket-location.js b/tests/lib/rules/jsx-closing-bracket-location.js index 1127af8d89..cafcd9ebfd 100644 --- a/tests/lib/rules/jsx-closing-bracket-location.js +++ b/tests/lib/rules/jsx-closing-bracket-location.js @@ -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: [ '
`, errors: [{message: missingCurlyMessage}], - options: [{props: 'always'}] + options: [{props: 'always'}], + output: `` }, { code: 'foo · bar', errors: [{message: missingCurlyMessage}], - options: [{children: 'always'}] + options: [{children: 'always'}], + output: '{"foo · bar"}' }, { code: `{'foo "bar"'}`, @@ -689,7 +691,18 @@ ruleTester.run('jsx-curly-brace-presence', rule, { errors: [ {message: missingCurlyMessage}, {message: missingCurlyMessage} ], - options: ['always'] + options: ['always'], + output: [ + '', + ' {"a"}', + ' {"b c "}', + ' {"d "}', + '' + ].join('\n') }, { code: [ @@ -706,7 +719,18 @@ ruleTester.run('jsx-curly-brace-presence', rule, { errors: [ {message: missingCurlyMessage}, {message: missingCurlyMessage} ], - options: ['always'] + options: ['always'], + output: [ + ``, + ' {"a"}', + ' {"b c "}', + ' {"d "}', + '' + ].join('\n') }, { code: ` diff --git a/tests/lib/rules/jsx-indent.js b/tests/lib/rules/jsx-indent.js index 5969c1a3aa..6a341ade0f 100644 --- a/tests/lib/rules/jsx-indent.js +++ b/tests/lib/rules/jsx-indent.js @@ -1134,15 +1134,15 @@ const Component = () => ( // two lines following. I *think* because it incorrectly uses '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 (', ' ', - ' ', - ' ', + ' ', + '', ' );', '}' - ].join('\n'), */ + ].join('\n'), options: [2], errors: [{message: 'Expected indentation of 4 space characters but found 0.'}] }, { @@ -1781,7 +1781,14 @@ const Component = () => ( ].join('\n'), errors: [ {message: 'Expected indentation of 4 space characters but found 2.'} - ] + ], + output: [ + '

', + '

', + ' Text', + '
', + '

' + ].join('\n') }, { code: ` const Component = () => ( diff --git a/tests/lib/rules/jsx-sort-props.js b/tests/lib/rules/jsx-sort-props.js index 4a58b1ca43..3d64788e3a 100644 --- a/tests/lib/rules/jsx-sort-props.js +++ b/tests/lib/rules/jsx-sort-props.js @@ -401,7 +401,7 @@ ruleTester.run('jsx-sort-props', rule, { }, { code: ';', - errors: [shorthandAndCallbackLastArgs], + errors: [expectedError], options: shorthandLastArgs, output: ';' }, diff --git a/tests/lib/rules/jsx-uses-vars.js b/tests/lib/rules/jsx-uses-vars.js index efac09331b..b93e7c3547 100644 --- a/tests/lib/rules/jsx-uses-vars.js +++ b/tests/lib/rules/jsx-uses-vars.js @@ -215,13 +215,23 @@ ruleTester.run('prefer-const', rulePreferConst, { let 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 =
; + ; + ` }, { code: ` /* eslint jsx-uses-vars:1 */ let filters = 'foo';
{filters}
; `, - 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'; +
{filters}
; + ` }] }); diff --git a/tests/lib/rules/no-typos.js b/tests/lib/rules/no-typos.js index 9a7b6f751c..62c156e125 100644 --- a/tests/lib/rules/no-typos.js +++ b/tests/lib/rules/no-typos.js @@ -944,7 +944,7 @@ ruleTester.run('no-typos', rule, { type: 'MethodDefinition' }, { message: ERROR_MESSAGE_LIFECYCLE_METHOD('Render', 'render'), - nodeType: 'MethodDefinition' + type: 'MethodDefinition' }] }, { code: ` @@ -1616,7 +1616,7 @@ ruleTester.run('no-typos', rule, { parserOptions, errors: [{ message: ERROR_MESSAGE_STATIC('getDerivedStateFromProps'), - nodeType: 'MethodDefinition' + type: 'MethodDefinition' }] }, { code: ` @@ -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: ` diff --git a/tests/lib/rules/no-unknown-property.js b/tests/lib/rules/no-unknown-property.js index 8bfdd9d61a..21197a4e06 100644 --- a/tests/lib/rules/no-unknown-property.js +++ b/tests/lib/rules/no-unknown-property.js @@ -85,10 +85,12 @@ ruleTester.run('no-unknown-property', rule, { errors: [{message: 'Unknown property \'clip-path\' found, use \'clipPath\' instead'}] }, { code: '