From 476d58a584d5d2db003c4c22ffee90e63566164d Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Fri, 20 Oct 2023 13:19:22 -0400 Subject: [PATCH] docs: Add note about invalid CLI flags when using flat config. (#17664) * fix: Add note about invalid CLI flags when using flat config. Fixes #17652 * Update docs/src/use/command-line-interface.md Co-authored-by: Milos Djermanovic * Upgrade config-array * Move error message --------- Co-authored-by: Milos Djermanovic --- docs/src/use/command-line-interface.md | 10 +++++----- lib/cli.js | 9 ++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/src/use/command-line-interface.md b/docs/src/use/command-line-interface.md index 6087aae4fcc..4749b7c19ec 100644 --- a/docs/src/use/command-line-interface.md +++ b/docs/src/use/command-line-interface.md @@ -121,7 +121,7 @@ Miscellaneous: #### `--no-eslintrc` -Disables use of configuration from `.eslintrc.*` and `package.json` files. +**eslintrc Mode Only.** Disables use of configuration from `.eslintrc.*` and `package.json` files. For flat config mode, use `--no-config-lookup` instead. * **Argument Type**: No argument. @@ -150,7 +150,7 @@ If `.eslintrc.*` and/or `package.json` files are also used for configuration (i. #### `--env` -This option enables specific environments. +**eslintrc Mode Only.** This option enables specific environments. * **Argument Type**: String. One of the available environments. * **Multiple Arguments**: Yes @@ -166,7 +166,7 @@ npx eslint --env browser --env node file.js #### `--ext` -This option allows you to specify which file extensions ESLint uses when searching for target files in the directories you specify. +**eslintrc Mode Only.** This option allows you to specify which file extensions ESLint uses when searching for target files in the directories you specify. * **Argument Type**: String. File extension. * **Multiple Arguments**: Yes @@ -232,7 +232,7 @@ echo '3 ** 4' | npx eslint --stdin --parser-options ecmaVersion:7 # succeeds, ya #### `--resolve-plugins-relative-to` -Changes the directory where plugins are resolved from. +**eslintrc Mode Only.** Changes the directory where plugins are resolved from. * **Argument Type**: String. Path to directory. * **Multiple Arguments**: No @@ -374,7 +374,7 @@ npx eslint --fix --fix-type suggestion,layout . #### `--ignore-path` -This option allows you to specify the file to use as your `.eslintignore`. +**eslintrc Mode Only.** This option allows you to specify the file to use as your `.eslintignore`. * **Argument Type**: String. Path to file. * **Multiple Arguments**: No diff --git a/lib/cli.js b/lib/cli.js index 807d28a0d1b..f472659c20f 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -318,7 +318,14 @@ const cli = { options = CLIOptions.parse(args); } catch (error) { debug("Error parsing CLI options:", error.message); - log.error(error.message); + + let errorMessage = error.message; + + if (usingFlatConfig) { + errorMessage += "\nYou're using eslint.config.js, some command line flags are no longer available. Please see https://eslint.org/docs/latest/use/command-line-interface for details."; + } + + log.error(errorMessage); return 2; }