diff --git a/docs/user-guide/command-line-interface.md b/docs/user-guide/command-line-interface.md index 27d4edc3247..6f350d48597 100644 --- a/docs/user-guide/command-line-interface.md +++ b/docs/user-guide/command-line-interface.md @@ -30,62 +30,62 @@ The command line utility has several options. You can view the options by runnin eslint [options] file.js [file.js] [dir] Basic configuration: - --no-eslintrc Disable use of configuration from .eslintrc.* - -c, --config path::String Use this configuration, overriding .eslintrc.* config options if present - --env [String] Specify environments - --ext [String] Specify JavaScript file extensions - default: .js - --global [String] Define global variables - --parser String Specify the parser to be used - --parser-options Object Specify parser options + --no-eslintrc Disable use of configuration from .eslintrc.* + -c, --config path::String Use this configuration, overriding .eslintrc.* config options if present + --env [String] Specify environments + --ext [String] Specify JavaScript file extensions + --global [String] Define global variables + --parser String Specify the parser to be used + --parser-options Object Specify parser options --resolve-plugins-relative-to path::String A folder where plugins should be resolved from, CWD by default Specifying rules and plugins: - --rulesdir [path::String] Use additional rules from this directory - --plugin [String] Specify plugins - --rule Object Specify rules + --plugin [String] Specify plugins + --rule Object Specify rules + --rulesdir [path::String] Load additional rules from this directory. Deprecated: Use rules from plugins Fixing problems: - --fix Automatically fix problems - --fix-dry-run Automatically fix problems without saving the changes to the file system - --fix-type Array Specify the types of fixes to apply (directive, problem, suggestion, layout) + --fix Automatically fix problems + --fix-dry-run Automatically fix problems without saving the changes to the file system + --fix-type Array Specify the types of fixes to apply (directive, problem, suggestion, layout) Ignoring files: - --ignore-path path::String Specify path of ignore file - --no-ignore Disable use of ignore files and patterns - --ignore-pattern [String] Pattern of files to ignore (in addition to those in .eslintignore) + --ignore-path path::String Specify path of ignore file + --no-ignore Disable use of ignore files and patterns + --ignore-pattern [String] Pattern of files to ignore (in addition to those in .eslintignore) Using stdin: - --stdin Lint code provided on - default: false - --stdin-filename String Specify filename to process STDIN as + --stdin Lint code provided on - default: false + --stdin-filename String Specify filename to process STDIN as Handling warnings: - --quiet Report errors only - default: false - --max-warnings Int Number of warnings to trigger nonzero exit code - default: -1 + --quiet Report errors only - default: false + --max-warnings Int Number of warnings to trigger nonzero exit code - default: -1 Output: -o, --output-file path::String Specify file to write report to - -f, --format String Use a specific output format - default: stylish - --color, --no-color Force enabling/disabling of color + -f, --format String Use a specific output format - default: stylish + --color, --no-color Force enabling/disabling of color Inline configuration comments: - --no-inline-config Prevent comments from changing config or rules + --no-inline-config Prevent comments from changing config or rules --report-unused-disable-directives Adds reported errors for unused eslint-disable directives Caching: - --cache Only check changed files - default: false - --cache-file path::String Path to the cache file. Deprecated: use --cache-location - default: .eslintcache - --cache-location path::String Path to the cache file or directory - --cache-strategy String Strategy to use for detecting changed files - either: metadata or content - default: metadata + --cache Only check changed files - default: false + --cache-file path::String Path to the cache file. Deprecated: use --cache-location - default: .eslintcache + --cache-location path::String Path to the cache file or directory + --cache-strategy String Strategy to use for detecting changed files in the cache - either: metadata or content - default: metadata Miscellaneous: - --init Run config initialization wizard - default: false - --env-info Output execution environment information - default: false - --no-error-on-unmatched-pattern Prevent errors when pattern is unmatched - default: false - --exit-on-fatal-error Exit with exit code 2 in case of fatal error - default: false - --debug Output debugging information - -h, --help Show help - -v, --version Output the version number - --print-config path::String Print the configuration for the given file + --init Run config initialization wizard - default: false + --env-info Output execution environment information - default: false + --no-error-on-unmatched-pattern Prevent errors when pattern is unmatched + --exit-on-fatal-error Exit with exit code 2 in case of fatal error - default: false + --debug Output debugging information + -h, --help Show help + -v, --version Output the version number + --print-config path::String Print the configuration for the given file ``` Options that accept array values can be specified by repeating the option or with a comma-delimited list (other than `--ignore-pattern` which does not allow the second style). @@ -178,20 +178,6 @@ Changes the folder where plugins are resolved from. By default, plugins are reso ### Specifying rules and plugins -#### `--rulesdir` - -This option allows you to specify another directory from which to load rules files. This allows you to dynamically load new rules at run time. This is useful when you have custom rules that aren't suitable for being bundled with ESLint. - -Example: - - eslint --rulesdir my-rules/ file.js - -The rules in your custom rules directory must follow the same format as bundled rules to work properly. You can also specify multiple locations for custom rules by including multiple `--rulesdir` options: - - eslint --rulesdir my-rules/ --rulesdir my-other-rules/ file.js - -Note that, as with core rules and plugin rules, you still need to enable the rules in configuration or via the `--rule` CLI option in order to actually run those rules during linting. Specifying a rules directory with `--rulesdir` does not automatically enable the rules within that directory. - #### `--plugin` This option specifies a plugin to load. You can omit the prefix `eslint-plugin-` from the plugin name. @@ -215,6 +201,22 @@ Examples: eslint --rule 'guard-for-in: error' --rule 'brace-style: [error, 1tbs]' eslint --rule 'jquery/dollar-sign: error' +#### `--rulesdir` + +**Deprecated**: Use rules from plugins instead. + +This option allows you to specify another directory from which to load rules files. This allows you to dynamically load new rules at run time. This is useful when you have custom rules that aren't suitable for being bundled with ESLint. + +Example: + + eslint --rulesdir my-rules/ file.js + +The rules in your custom rules directory must follow the same format as bundled rules to work properly. You can also specify multiple locations for custom rules by including multiple `--rulesdir` options: + + eslint --rulesdir my-rules/ --rulesdir my-other-rules/ file.js + +Note that, as with core rules and plugin rules, you still need to enable the rules in configuration or via the `--rule` CLI option in order to actually run those rules during linting. Specifying a rules directory with `--rulesdir` does not automatically enable the rules within that directory. + ### Fixing problems #### `--fix` diff --git a/lib/options.js b/lib/options.js index 2dd186de3e8..6d06e3ddce1 100644 --- a/lib/options.js +++ b/lib/options.js @@ -50,7 +50,7 @@ const optionator = require("optionator"); * @property {boolean | undefined} reportUnusedDisableDirectives Adds reported errors for unused eslint-disable directives * @property {string} [resolvePluginsRelativeTo] A folder where plugins should be resolved from, CWD by default * @property {Object} [rule] Specify rules - * @property {string[]} [rulesdir] Use additional rules from this directory + * @property {string[]} [rulesdir] Load additional rules from this directory. Deprecated: Use rules from plugins * @property {boolean} stdin Lint code provided on * @property {string} [stdinFilename] Specify filename to process STDIN as * @property {boolean} quiet Report errors only @@ -118,11 +118,6 @@ module.exports = optionator({ { heading: "Specifying rules and plugins" }, - { - option: "rulesdir", - type: "[path::String]", - description: "Use additional rules from this directory" - }, { option: "plugin", type: "[String]", @@ -133,6 +128,11 @@ module.exports = optionator({ type: "Object", description: "Specify rules" }, + { + option: "rulesdir", + type: "[path::String]", + description: "Load additional rules from this directory. Deprecated: Use rules from plugins" + }, { heading: "Fixing problems" },