]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/options.js
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 {("directive" | "problem" | "suggestion" | "layout")[]} [fixType] Specify the types of fixes to apply (directive, 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] Load additional rules from this directory. Deprecated: Use rules from plugins
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)"
68 * Creates the CLI options for ESLint.
69 * @param {boolean} usingFlatConfig Indicates if flat config is being used.
70 * @returns {Object} The opinionator instance.
72 module
.exports = function(usingFlatConfig
) {
76 if (usingFlatConfig
) {
78 option
: "config-lookup",
81 description
: "Disable look up for eslint.config.js"
88 description
: "Disable use of configuration from .eslintrc.*"
94 if (!usingFlatConfig
) {
98 description
: "Specify environments"
104 if (!usingFlatConfig
) {
108 description
: "Specify JavaScript file extensions"
112 let resolvePluginsFlag
;
114 if (!usingFlatConfig
) {
115 resolvePluginsFlag
= {
116 option
: "resolve-plugins-relative-to",
117 type
: "path::String",
118 description
: "A folder where plugins should be resolved from, CWD by default"
124 if (!usingFlatConfig
) {
127 type
: "[path::String]",
128 description
: "Load additional rules from this directory. Deprecated: Use rules from plugins"
133 prepend
: "eslint [options] file.js [file.js] [dir]",
135 concatRepeatedArrays
: true,
136 mergeRepeatedObjects
: true
140 heading
: "Basic configuration"
146 type
: "path::String",
147 description
: usingFlatConfig
148 ? "Use this configuration instead of eslint.config.js"
149 : "Use this configuration, overriding .eslintrc.* config options if present"
156 description
: "Define global variables"
161 description
: "Specify the parser to be used"
164 option
: "parser-options",
166 description
: "Specify parser options"
170 heading
: "Specifying rules and plugins"
175 description
: "Specify plugins"
180 description
: "Specify rules"
184 heading
: "Fixing problems"
190 description
: "Automatically fix problems"
193 option
: "fix-dry-run",
196 description
: "Automatically fix problems without saving the changes to the file system"
201 description
: "Specify the types of fixes to apply (directive, problem, suggestion, layout)"
204 heading
: "Ignoring files"
207 option
: "ignore-path",
208 type
: "path::String",
209 description
: "Specify path of ignore file"
215 description
: "Disable use of ignore files and patterns"
218 option
: "ignore-pattern",
220 description
: "Pattern of files to ignore (in addition to those in .eslintignore)",
221 concatRepeatedArrays
: [true, {
222 oneValuePerFlag
: true
226 heading
: "Using stdin"
232 description
: "Lint code provided on <STDIN>"
235 option
: "stdin-filename",
237 description
: "Specify filename to process STDIN as"
240 heading
: "Handling warnings"
246 description
: "Report errors only"
249 option
: "max-warnings",
252 description
: "Number of warnings to trigger nonzero exit code"
258 option
: "output-file",
260 type
: "path::String",
261 description
: "Specify file to write report to"
268 description
: "Use a specific output format"
274 description
: "Force enabling/disabling of color"
277 heading
: "Inline configuration comments"
280 option
: "inline-config",
283 description
: "Prevent comments from changing config or rules"
286 option
: "report-unused-disable-directives",
289 description
: "Adds reported errors for unused eslint-disable directives"
298 description
: "Only check changed files"
301 option
: "cache-file",
302 type
: "path::String",
303 default: ".eslintcache",
304 description
: "Path to the cache file. Deprecated: use --cache-location"
307 option
: "cache-location",
308 type
: "path::String",
309 description
: "Path to the cache file or directory"
312 option
: "cache-strategy",
313 dependsOn
: ["cache"],
316 enum: ["metadata", "content"],
317 description
: "Strategy to use for detecting changed files in the cache"
320 heading
: "Miscellaneous"
326 description
: "Run config initialization wizard"
332 description
: "Output execution environment information"
335 option
: "error-on-unmatched-pattern",
338 description
: "Prevent errors when pattern is unmatched"
341 option
: "exit-on-fatal-error",
344 description
: "Exit with exit code 2 in case of fatal error"
350 description
: "Output debugging information"
356 description
: "Show help"
362 description
: "Output the version number"
365 option
: "print-config",
366 type
: "path::String",
367 description
: "Print the configuration for the given file"
369 ].filter(value
=> !!value
)