2 * @fileoverview Options configuration for optionator.
3 * @author George Zahariev
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
12 const optionator = require("optionator");
14 //------------------------------------------------------------------------------
16 //------------------------------------------------------------------------------
19 * The options object parsed by Optionator.
20 * @typedef {Object} ParsedCLIOptions
21 * @property {boolean} cache Only check changed files
22 * @property {string} cacheFile Path to the cache file. Deprecated: use --cache-location
23 * @property {string} [cacheLocation] Path to the cache file or directory
24 * @property {"metadata" | "content"} cacheStrategy Strategy to use for detecting changed files in the cache
25 * @property {boolean} [color] Force enabling/disabling of color
26 * @property {string} [config] Use this configuration, overriding .eslintrc.* config options if present
27 * @property {boolean} debug Output debugging information
28 * @property {string[]} [env] Specify environments
29 * @property {boolean} envInfo Output execution environment information
30 * @property {boolean} errorOnUnmatchedPattern Prevent errors when pattern is unmatched
31 * @property {boolean} eslintrc Disable use of configuration from .eslintrc.*
32 * @property {string[]} [ext] Specify JavaScript file extensions
33 * @property {boolean} fix Automatically fix problems
34 * @property {boolean} fixDryRun Automatically fix problems without saving the changes to the file system
35 * @property {("problem" | "suggestion" | "layout")[]} [fixType] Specify the types of fixes to apply (problem, suggestion, layout)
36 * @property {string} format Use a specific output format
37 * @property {string[]} [global] Define global variables
38 * @property {boolean} [help] Show help
39 * @property {boolean} ignore Disable use of ignore files and patterns
40 * @property {string} [ignorePath] Specify path of ignore file
41 * @property {string[]} [ignorePattern] Pattern of files to ignore (in addition to those in .eslintignore)
42 * @property {boolean} init Run config initialization wizard
43 * @property {boolean} inlineConfig Prevent comments from changing config or rules
44 * @property {number} maxWarnings Number of warnings to trigger nonzero exit code
45 * @property {string} [outputFile] Specify file to write report to
46 * @property {string} [parser] Specify the parser to be used
47 * @property {Object} [parserOptions] Specify parser options
48 * @property {string[]} [plugin] Specify plugins
49 * @property {string} [printConfig] Print the configuration for the given file
50 * @property {boolean | undefined} reportUnusedDisableDirectives Adds reported errors for unused eslint-disable directives
51 * @property {string} [resolvePluginsRelativeTo] A folder where plugins should be resolved from, CWD by default
52 * @property {Object} [rule] Specify rules
53 * @property {string[]} [rulesdir] Use additional rules from this directory
54 * @property {boolean} stdin Lint code provided on <STDIN>
55 * @property {string} [stdinFilename] Specify filename to process STDIN as
56 * @property {boolean} quiet Report errors only
57 * @property {boolean} [version] Output the version number
58 * @property {string[]} _ Positional filenames or patterns
61 //------------------------------------------------------------------------------
62 // Initialization and Public Interface
63 //------------------------------------------------------------------------------
65 // exports "parse(args)", "generateHelp()", and "generateHelpForOption(optionName)"
66 module.exports = optionator({
67 prepend: "eslint [options] file.js [file.js] [dir]",
69 concatRepeatedArrays: true,
70 mergeRepeatedObjects: true
74 heading: "Basic configuration"
80 description: "Disable use of configuration from .eslintrc.*"
86 description: "Use this configuration, overriding .eslintrc.* config options if present"
91 description: "Specify environments"
96 description: "Specify JavaScript file extensions"
101 description: "Define global variables"
106 description: "Specify the parser to be used"
109 option: "parser-options",
111 description: "Specify parser options"
114 option: "resolve-plugins-relative-to",
115 type: "path::String",
116 description: "A folder where plugins should be resolved from, CWD by default"
119 heading: "Specifying rules and plugins"
123 type: "[path::String]",
124 description: "Use additional rules from this directory"
129 description: "Specify plugins"
134 description: "Specify rules"
137 heading: "Fixing problems"
143 description: "Automatically fix problems"
146 option: "fix-dry-run",
149 description: "Automatically fix problems without saving the changes to the file system"
154 description: "Specify the types of fixes to apply (problem, suggestion, layout)"
157 heading: "Ignoring files"
160 option: "ignore-path",
161 type: "path::String",
162 description: "Specify path of ignore file"
168 description: "Disable use of ignore files and patterns"
171 option: "ignore-pattern",
173 description: "Pattern of files to ignore (in addition to those in .eslintignore)",
174 concatRepeatedArrays: [true, {
175 oneValuePerFlag: true
179 heading: "Using stdin"
185 description: "Lint code provided on <STDIN>"
188 option: "stdin-filename",
190 description: "Specify filename to process STDIN as"
193 heading: "Handling warnings"
199 description: "Report errors only"
202 option: "max-warnings",
205 description: "Number of warnings to trigger nonzero exit code"
211 option: "output-file",
213 type: "path::String",
214 description: "Specify file to write report to"
221 description: "Use a specific output format"
227 description: "Force enabling/disabling of color"
230 heading: "Inline configuration comments"
233 option: "inline-config",
236 description: "Prevent comments from changing config or rules"
239 option: "report-unused-disable-directives",
242 description: "Adds reported errors for unused eslint-disable directives"
251 description: "Only check changed files"
254 option: "cache-file",
255 type: "path::String",
256 default: ".eslintcache",
257 description: "Path to the cache file. Deprecated: use --cache-location"
260 option: "cache-location",
261 type: "path::String",
262 description: "Path to the cache file or directory"
265 option: "cache-strategy",
266 dependsOn: ["cache"],
269 enum: ["metadata", "content"],
270 description: "Strategy to use for detecting changed files in the cache"
273 heading: "Miscellaneous"
279 description: "Run config initialization wizard"
285 description: "Output execution environment information"
288 option: "error-on-unmatched-pattern",
291 description: "Prevent errors when pattern is unmatched"
294 option: "exit-on-fatal-error",
297 description: "Exit with exit code 2 in case of fatal error"
303 description: "Output debugging information"
309 description: "Show help"
315 description: "Output the version number"
318 option: "print-config",
319 type: "path::String",
320 description: "Print the configuration for the given file"