From 6e551ae8827d064680c1344074db9fb3093967e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Thu, 4 Mar 2021 21:13:19 +0100 Subject: [PATCH] Suggest using `babel.config.json` when linting dependencies (#12956) --- eslint/babel-eslint-parser/src/configuration.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/eslint/babel-eslint-parser/src/configuration.js b/eslint/babel-eslint-parser/src/configuration.js index cef371cf526b..f935590de4f5 100644 --- a/eslint/babel-eslint-parser/src/configuration.js +++ b/eslint/babel-eslint-parser/src/configuration.js @@ -66,9 +66,13 @@ export function normalizeBabelParseConfig(options) { if (config !== null) { if (!config.hasFilesystemConfig()) { - throw new Error( - `No Babel config file detected for ${config.options.filename}. Either disable config file checking with requireConfigFile: false, or configure Babel so that it can find the config files.`, - ); + let error = `No Babel config file detected for ${config.options.filename}. Either disable config file checking with requireConfigFile: false, or configure Babel so that it can find the config files.`; + + if (config.options.filename.includes("node_modules")) { + error += `\nIf you have a .babelrc.js file or use package.json#babel, keep in mind that it's not used when parsing dependencies. If you want your config to be applied to your whole app, consider using babel.config.js or babel.config.json instead.`; + } + + throw new Error(error); } return config.options;