Skip to content

Commit

Permalink
docs: Add note about invalid CLI flags when using flat config. (#17664)
Browse files Browse the repository at this point in the history
* 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 <milos.djermanovic@gmail.com>

* Upgrade config-array

* Move error message

---------

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
  • Loading branch information
nzakas and mdjermanovic committed Oct 20, 2023
1 parent 5de9637 commit 476d58a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 5 additions & 5 deletions docs/src/use/command-line-interface.md
Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion lib/cli.js
Expand Up @@ -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;
}

Expand Down

0 comments on commit 476d58a

Please sign in to comment.