From a27a105ad6ed5b0972764d9ab9d119a7ad7f41ad Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Wed, 16 Sep 2020 10:08:05 +0300 Subject: [PATCH] fix: resolve CI build failure (#9640) --- packages/eslint-config-react-app/README.md | 4 +- packages/eslint-config-react-app/base.js | 47 +++++++++++++++++++ packages/eslint-config-react-app/index.js | 30 +----------- packages/eslint-config-react-app/package.json | 4 +- .../react-scripts/config/webpack.config.js | 3 ++ 5 files changed, 57 insertions(+), 31 deletions(-) create mode 100644 packages/eslint-config-react-app/base.js diff --git a/packages/eslint-config-react-app/README.md b/packages/eslint-config-react-app/README.md index ac49d2b738a..7467c3a1d68 100644 --- a/packages/eslint-config-react-app/README.md +++ b/packages/eslint-config-react-app/README.md @@ -36,10 +36,10 @@ That's it! You can override the settings from `eslint-config-react-app` by editi This config also ships with optional Jest rules for ESLint (based on [`eslint-plugin-jest`](https://github.com/jest-community/eslint-plugin-jest)). -You'll first need to add the plugin. +You'll first need to add the ESLint plugin for Jest (if you don't already have it installed). ```sh -npm install --save-dev eslint-plugin-jest@24.x +npm install --save-dev eslint-plugin-jest@^24.0.0 ``` You can then enable these rules by adding the Jest config to the `extends` array in your ESLint config. diff --git a/packages/eslint-config-react-app/base.js b/packages/eslint-config-react-app/base.js new file mode 100644 index 00000000000..eef8973af55 --- /dev/null +++ b/packages/eslint-config-react-app/base.js @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +// This file contains the minimum ESLint configuration required for Create +// React App support, and is used as the `baseConfig` for `eslint-loader` +// to ensure that user-provided configs don't need this boilerplate. + +module.exports = { + root: true, + + parser: 'babel-eslint', + + plugins: ['react'], + + env: { + browser: true, + commonjs: true, + es6: true, + jest: true, + node: true, + }, + + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + ecmaFeatures: { + jsx: true, + }, + }, + + settings: { + react: { + version: 'detect', + }, + }, + + rules: { + 'react/jsx-uses-react': 'warn', + 'react/jsx-uses-vars': 'warn', + }, +}; diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js index 36538fb736f..aca8e76ec04 100644 --- a/packages/eslint-config-react-app/index.js +++ b/packages/eslint-config-react-app/index.js @@ -24,33 +24,9 @@ const restrictedGlobals = require('confusing-browser-globals'); module.exports = { - root: true, + extends: [require.resolve('./base')], - parser: 'babel-eslint', - - plugins: ['import', 'flowtype', 'jsx-a11y', 'react', 'react-hooks'], - - env: { - browser: true, - commonjs: true, - es6: true, - jest: true, - node: true, - }, - - parserOptions: { - ecmaVersion: 2018, - sourceType: 'module', - ecmaFeatures: { - jsx: true, - }, - }, - - settings: { - react: { - version: 'detect', - }, - }, + plugins: ['import', 'flowtype', 'jsx-a11y', 'react-hooks'], overrides: [ { @@ -269,8 +245,6 @@ module.exports = { ignore: [], }, ], - 'react/jsx-uses-react': 'warn', - 'react/jsx-uses-vars': 'warn', 'react/no-danger-with-children': 'warn', // Disabled because of undesirable warnings // See https://github.com/facebook/create-react-app/issues/5204 for diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json index 4f68416e971..f0964ed72de 100644 --- a/packages/eslint-config-react-app/package.json +++ b/packages/eslint-config-react-app/package.json @@ -12,7 +12,9 @@ "url": "https://github.com/facebook/create-react-app/issues" }, "files": [ - "index.js" + "base.js", + "index.js", + "jest.js" ], "peerDependencies": { "@typescript-eslint/eslint-plugin": "^4.0.0", diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index 0c8dbae85e1..b039654e4d7 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -362,6 +362,9 @@ module.exports = function (webpackEnv) { formatter: require.resolve('react-dev-utils/eslintFormatter'), eslintPath: require.resolve('eslint'), resolvePluginsRelativeTo: __dirname, + baseConfig: { + extends: [require.resolve('eslint-config-react-app/base')], + }, }, loader: require.resolve('eslint-loader'), },