From a78d4aa1cb59874afaf2a02702e925d876091853 Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Tue, 23 Jul 2019 20:37:59 +0300 Subject: [PATCH 1/2] Add ESLint 6 support --- package.json | 2 +- packages/eslint-config-react-app/index.js | 4 +++- packages/eslint-config-react-app/package.json | 4 ++-- packages/react-error-overlay/package.json | 12 +++++------ packages/react-scripts/package.json | 20 +++++++++---------- .../scripts/utils/createJestConfig.js | 12 +++++------ 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index 9763ceec6a6..081973184bb 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "compile:lockfile": "node tasks/compile-lockfile.js" }, "devDependencies": { - "eslint": "5.16.0", + "eslint": "6.1.0", "execa": "1.0.0", "fs-extra": "^7.0.1", "get-port": "^4.2.0", diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js index c4b0289e1fb..bc5ff12f4c3 100644 --- a/packages/eslint-config-react-app/index.js +++ b/packages/eslint-config-react-app/index.js @@ -163,7 +163,9 @@ module.exports = { 'no-obj-calls': 'warn', 'no-octal': 'warn', 'no-octal-escape': 'warn', - 'no-redeclare': 'warn', + // TODO: Remove this option in the next major release of CRA. + // https://eslint.org/docs/user-guide/migrating-to-6.0.0#-the-no-redeclare-rule-is-now-more-strict-by-default + 'no-redeclare': ['warn', { builtinGlobals: false }], 'no-regex-spaces': 'warn', 'no-restricted-syntax': ['warn', 'WithStatement'], 'no-script-url': 'warn', diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json index 43f700771d2..b752f4937a6 100644 --- a/packages/eslint-config-react-app/package.json +++ b/packages/eslint-config-react-app/package.json @@ -18,8 +18,8 @@ "@typescript-eslint/eslint-plugin": "1.x", "@typescript-eslint/parser": "1.x", "babel-eslint": "10.x", - "eslint": "5.x", - "eslint-plugin-flowtype": "2.x", + "eslint": "6.x", + "eslint-plugin-flowtype": "3.x", "eslint-plugin-import": "2.x", "eslint-plugin-jsx-a11y": "6.x", "eslint-plugin-react": "7.x", diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 985a1e9b5dd..356defb8a98 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -37,19 +37,19 @@ "@babel/code-frame": "7.0.0", "@babel/core": "7.4.3", "anser": "1.4.8", - "babel-eslint": "10.0.1", + "babel-eslint": "10.0.2", "babel-jest": "^24.8.0", "babel-loader": "8.0.5", "babel-preset-react-app": "^9.0.0", "chalk": "^2.4.2", "chokidar": "^2.1.2", "cross-env": "5.2.0", - "eslint": "^5.16.0", + "eslint": "^6.1.0", "eslint-config-react-app": "^4.0.1", - "eslint-plugin-flowtype": "2.50.1", - "eslint-plugin-import": "2.16.0", - "eslint-plugin-jsx-a11y": "6.2.1", - "eslint-plugin-react": "7.12.4", + "eslint-plugin-flowtype": "3.12.1", + "eslint-plugin-import": "2.18.2", + "eslint-plugin-jsx-a11y": "6.2.3", + "eslint-plugin-react": "7.14.3", "flow-bin": "^0.63.1", "html-entities": "1.2.1", "jest": "24.7.1", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 3586204650a..269a93ddf5e 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -30,9 +30,9 @@ "dependencies": { "@babel/core": "7.4.3", "@svgr/webpack": "4.3.1", - "@typescript-eslint/eslint-plugin": "1.10.2", - "@typescript-eslint/parser": "1.10.2", - "babel-eslint": "10.0.1", + "@typescript-eslint/eslint-plugin": "1.13.0", + "@typescript-eslint/parser": "1.13.0", + "babel-eslint": "10.0.2", "babel-jest": "^24.8.0", "babel-loader": "8.0.5", "babel-plugin-named-asset-import": "^0.3.2", @@ -42,14 +42,14 @@ "css-loader": "2.1.1", "dotenv": "6.2.0", "dotenv-expand": "4.2.0", - "eslint": "^5.16.0", + "eslint": "^6.1.0", "eslint-config-react-app": "^4.0.1", - "eslint-loader": "2.1.2", - "eslint-plugin-flowtype": "2.50.1", - "eslint-plugin-import": "2.16.0", - "eslint-plugin-jsx-a11y": "6.2.1", - "eslint-plugin-react": "7.12.4", - "eslint-plugin-react-hooks": "^1.5.0", + "eslint-loader": "2.2.1", + "eslint-plugin-flowtype": "3.12.1", + "eslint-plugin-import": "2.18.2", + "eslint-plugin-jsx-a11y": "6.2.3", + "eslint-plugin-react": "7.14.3", + "eslint-plugin-react-hooks": "^1.6.1", "file-loader": "3.0.1", "fs-extra": "7.0.1", "html-webpack-plugin": "4.0.0-beta.5", diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index 8d37500d1ab..2ce0e5856f8 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -84,15 +84,15 @@ module.exports = (resolve, rootDir, isEjecting) => { ]; if (overrides) { supportedKeys.forEach(key => { - if (overrides.hasOwnProperty(key)) { - if (Array.isArray(config[key]) || typeof config[key] !== 'object') { + if (Object.prototype.hasOwnProperty.call(overrides, key)) { + if (Array.isArray(config[key]) || typeof config[key] !== 'object') { // for arrays or primitive types, directly override the config key - config[key] = overrides[key]; + config[key] = overrides[key]; } else { // for object types, extend gracefully - config[key] = Object.assign({}, config[key], overrides[key]); - } - + config[key] = Object.assign({}, config[key], overrides[key]); + } + delete overrides[key]; } }); From 96d91f03a135c1c15047e324008299c3ac8843b6 Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Thu, 25 Jul 2019 11:08:44 +0300 Subject: [PATCH 2/2] Fix plugin resolution issue --- packages/react-scripts/config/webpack.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index 03fd965370a..4b62f3d8a28 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -323,6 +323,7 @@ module.exports = function(webpackEnv) { options: { formatter: require.resolve('react-dev-utils/eslintFormatter'), eslintPath: require.resolve('eslint'), + resolvePluginsRelativeTo: __dirname, // @remove-on-eject-begin baseConfig: (() => { const eslintCli = new eslint.CLIEngine();