From 1608298726a42a1cb691fe7d1baabb6a9c5b4b96 Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Thu, 4 Feb 2021 11:06:19 +0200 Subject: [PATCH 1/2] Remove ESLint verification when opting-out --- .../react-scripts/scripts/utils/verifyPackageTree.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/react-scripts/scripts/utils/verifyPackageTree.js b/packages/react-scripts/scripts/utils/verifyPackageTree.js index 210043ff7c4..0de4fab9cf7 100644 --- a/packages/react-scripts/scripts/utils/verifyPackageTree.js +++ b/packages/react-scripts/scripts/utils/verifyPackageTree.js @@ -13,22 +13,27 @@ const fs = require('fs'); const semver = require('semver'); const path = require('path'); +const isESLintPluginEnabled = process.env.DISABLE_ESLINT_PLUGIN !== 'true'; + // We assume that having wrong versions of these // in the tree will likely break your setup. // This is a relatively low-effort way to find common issues. function verifyPackageTree() { - const depsToCheck = [ + let depsToCheck = [ // These are packages most likely to break in practice. // See https://github.com/facebook/create-react-app/issues/1795 for reasons why. // I have not included Babel here because plugins typically don't import Babel (so it's not affected). - 'babel-eslint', 'babel-jest', 'babel-loader', - 'eslint', 'jest', 'webpack', 'webpack-dev-server', ]; + + if (isESLintPluginEnabled) { + depsToCheck = [...depsToCheck, 'babel-eslint', 'eslint']; + } + // Inlined from semver-regex, MIT license. // Don't want to make this a dependency after ejecting. const getSemverRegex = () => From 2a7c931191459b8594503b4f0e4518f3a97da1f6 Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Sun, 30 May 2021 12:43:42 +0300 Subject: [PATCH 2/2] Use filter instead of if statement --- .../react-scripts/scripts/utils/verifyPackageTree.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/react-scripts/scripts/utils/verifyPackageTree.js b/packages/react-scripts/scripts/utils/verifyPackageTree.js index 0de4fab9cf7..d23d8c54265 100644 --- a/packages/react-scripts/scripts/utils/verifyPackageTree.js +++ b/packages/react-scripts/scripts/utils/verifyPackageTree.js @@ -19,7 +19,7 @@ const isESLintPluginEnabled = process.env.DISABLE_ESLINT_PLUGIN !== 'true'; // in the tree will likely break your setup. // This is a relatively low-effort way to find common issues. function verifyPackageTree() { - let depsToCheck = [ + const depsToCheck = [ // These are packages most likely to break in practice. // See https://github.com/facebook/create-react-app/issues/1795 for reasons why. // I have not included Babel here because plugins typically don't import Babel (so it's not affected). @@ -28,11 +28,9 @@ function verifyPackageTree() { 'jest', 'webpack', 'webpack-dev-server', - ]; - - if (isESLintPluginEnabled) { - depsToCheck = [...depsToCheck, 'babel-eslint', 'eslint']; - } + isESLintPluginEnabled && 'babel-eslint', + isESLintPluginEnabled && 'eslint', + ].filter(Boolean); // Inlined from semver-regex, MIT license. // Don't want to make this a dependency after ejecting.