Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 1 | /** |
| 2 | * @fileoverview Options configuration for optionator. |
| 3 | * @author George Zahariev |
| 4 | */ |
| 5 | |
| 6 | "use strict"; |
| 7 | |
| 8 | //------------------------------------------------------------------------------ |
| 9 | // Requirements |
| 10 | //------------------------------------------------------------------------------ |
| 11 | |
| 12 | const optionator = require("optionator"); |
| 13 | |
| 14 | //------------------------------------------------------------------------------ |
| 15 | // Initialization and Public Interface |
| 16 | //------------------------------------------------------------------------------ |
| 17 | |
| 18 | // exports "parse(args)", "generateHelp()", and "generateHelpForOption(optionName)" |
| 19 | module.exports = optionator({ |
| 20 | prepend: "eslint [options] file.js [file.js] [dir]", |
| 21 | defaults: { |
| 22 | concatRepeatedArrays: true, |
| 23 | mergeRepeatedObjects: true |
| 24 | }, |
| 25 | options: [ |
| 26 | { |
| 27 | heading: "Basic configuration" |
| 28 | }, |
| 29 | { |
| 30 | option: "eslintrc", |
| 31 | type: "Boolean", |
| 32 | default: "true", |
| 33 | description: "Disable use of configuration from .eslintrc.*" |
| 34 | }, |
| 35 | { |
| 36 | option: "config", |
| 37 | alias: "c", |
| 38 | type: "path::String", |
| 39 | description: "Use this configuration, overriding .eslintrc.* config options if present" |
| 40 | }, |
| 41 | { |
| 42 | option: "env", |
| 43 | type: "[String]", |
| 44 | description: "Specify environments" |
| 45 | }, |
| 46 | { |
| 47 | option: "ext", |
| 48 | type: "[String]", |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 49 | description: "Specify JavaScript file extensions" |
| 50 | }, |
| 51 | { |
| 52 | option: "global", |
| 53 | type: "[String]", |
| 54 | description: "Define global variables" |
| 55 | }, |
| 56 | { |
| 57 | option: "parser", |
| 58 | type: "String", |
| 59 | description: "Specify the parser to be used" |
| 60 | }, |
| 61 | { |
| 62 | option: "parser-options", |
| 63 | type: "Object", |
| 64 | description: "Specify parser options" |
| 65 | }, |
| 66 | { |
| 67 | option: "resolve-plugins-relative-to", |
| 68 | type: "path::String", |
| 69 | description: "A folder where plugins should be resolved from, CWD by default" |
| 70 | }, |
| 71 | { |
| 72 | heading: "Specifying rules and plugins" |
| 73 | }, |
| 74 | { |
| 75 | option: "rulesdir", |
| 76 | type: "[path::String]", |
| 77 | description: "Use additional rules from this directory" |
| 78 | }, |
| 79 | { |
| 80 | option: "plugin", |
| 81 | type: "[String]", |
| 82 | description: "Specify plugins" |
| 83 | }, |
| 84 | { |
| 85 | option: "rule", |
| 86 | type: "Object", |
| 87 | description: "Specify rules" |
| 88 | }, |
| 89 | { |
| 90 | heading: "Fixing problems" |
| 91 | }, |
| 92 | { |
| 93 | option: "fix", |
| 94 | type: "Boolean", |
| 95 | default: false, |
| 96 | description: "Automatically fix problems" |
| 97 | }, |
| 98 | { |
| 99 | option: "fix-dry-run", |
| 100 | type: "Boolean", |
| 101 | default: false, |
| 102 | description: "Automatically fix problems without saving the changes to the file system" |
| 103 | }, |
| 104 | { |
| 105 | option: "fix-type", |
| 106 | type: "Array", |
| 107 | description: "Specify the types of fixes to apply (problem, suggestion, layout)" |
| 108 | }, |
| 109 | { |
| 110 | heading: "Ignoring files" |
| 111 | }, |
| 112 | { |
| 113 | option: "ignore-path", |
| 114 | type: "path::String", |
| 115 | description: "Specify path of ignore file" |
| 116 | }, |
| 117 | { |
| 118 | option: "ignore", |
| 119 | type: "Boolean", |
| 120 | default: "true", |
| 121 | description: "Disable use of ignore files and patterns" |
| 122 | }, |
| 123 | { |
| 124 | option: "ignore-pattern", |
| 125 | type: "[String]", |
| 126 | description: "Pattern of files to ignore (in addition to those in .eslintignore)", |
| 127 | concatRepeatedArrays: [true, { |
| 128 | oneValuePerFlag: true |
| 129 | }] |
| 130 | }, |
| 131 | { |
| 132 | heading: "Using stdin" |
| 133 | }, |
| 134 | { |
| 135 | option: "stdin", |
| 136 | type: "Boolean", |
| 137 | default: "false", |
| 138 | description: "Lint code provided on <STDIN>" |
| 139 | }, |
| 140 | { |
| 141 | option: "stdin-filename", |
| 142 | type: "String", |
| 143 | description: "Specify filename to process STDIN as" |
| 144 | }, |
| 145 | { |
| 146 | heading: "Handling warnings" |
| 147 | }, |
| 148 | { |
| 149 | option: "quiet", |
| 150 | type: "Boolean", |
| 151 | default: "false", |
| 152 | description: "Report errors only" |
| 153 | }, |
| 154 | { |
| 155 | option: "max-warnings", |
| 156 | type: "Int", |
| 157 | default: "-1", |
| 158 | description: "Number of warnings to trigger nonzero exit code" |
| 159 | }, |
| 160 | { |
| 161 | heading: "Output" |
| 162 | }, |
| 163 | { |
| 164 | option: "output-file", |
| 165 | alias: "o", |
| 166 | type: "path::String", |
| 167 | description: "Specify file to write report to" |
| 168 | }, |
| 169 | { |
| 170 | option: "format", |
| 171 | alias: "f", |
| 172 | type: "String", |
| 173 | default: "stylish", |
| 174 | description: "Use a specific output format" |
| 175 | }, |
| 176 | { |
| 177 | option: "color", |
| 178 | type: "Boolean", |
| 179 | alias: "no-color", |
| 180 | description: "Force enabling/disabling of color" |
| 181 | }, |
| 182 | { |
| 183 | heading: "Inline configuration comments" |
| 184 | }, |
| 185 | { |
| 186 | option: "inline-config", |
| 187 | type: "Boolean", |
| 188 | default: "true", |
| 189 | description: "Prevent comments from changing config or rules" |
| 190 | }, |
| 191 | { |
| 192 | option: "report-unused-disable-directives", |
| 193 | type: "Boolean", |
Tim van der Lippe | c8f6ffd | 2020-04-06 13:42:00 +0100 | [diff] [blame] | 194 | default: void 0, |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 195 | description: "Adds reported errors for unused eslint-disable directives" |
| 196 | }, |
| 197 | { |
| 198 | heading: "Caching" |
| 199 | }, |
| 200 | { |
| 201 | option: "cache", |
| 202 | type: "Boolean", |
| 203 | default: "false", |
| 204 | description: "Only check changed files" |
| 205 | }, |
| 206 | { |
| 207 | option: "cache-file", |
| 208 | type: "path::String", |
| 209 | default: ".eslintcache", |
| 210 | description: "Path to the cache file. Deprecated: use --cache-location" |
| 211 | }, |
| 212 | { |
| 213 | option: "cache-location", |
| 214 | type: "path::String", |
| 215 | description: "Path to the cache file or directory" |
| 216 | }, |
| 217 | { |
Tim van der Lippe | 0a9b84d | 2021-03-24 11:53:15 +0000 | [diff] [blame^] | 218 | option: "cache-strategy", |
| 219 | dependsOn: ["cache"], |
| 220 | type: "String", |
| 221 | default: "metadata", |
| 222 | enum: ["metadata", "content"], |
| 223 | description: "Strategy to use for detecting changed files in the cache" |
| 224 | }, |
| 225 | { |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 226 | heading: "Miscellaneous" |
| 227 | }, |
| 228 | { |
| 229 | option: "init", |
| 230 | type: "Boolean", |
| 231 | default: "false", |
| 232 | description: "Run config initialization wizard" |
| 233 | }, |
| 234 | { |
Tim van der Lippe | c8f6ffd | 2020-04-06 13:42:00 +0100 | [diff] [blame] | 235 | option: "env-info", |
| 236 | type: "Boolean", |
| 237 | default: "false", |
| 238 | description: "Output execution environment information" |
| 239 | }, |
| 240 | { |
| 241 | option: "error-on-unmatched-pattern", |
| 242 | type: "Boolean", |
| 243 | default: "true", |
| 244 | description: "Prevent errors when pattern is unmatched" |
| 245 | }, |
| 246 | { |
Yang Guo | 4fd355c | 2019-09-19 10:59:03 +0200 | [diff] [blame] | 247 | option: "debug", |
| 248 | type: "Boolean", |
| 249 | default: false, |
| 250 | description: "Output debugging information" |
| 251 | }, |
| 252 | { |
| 253 | option: "help", |
| 254 | alias: "h", |
| 255 | type: "Boolean", |
| 256 | description: "Show help" |
| 257 | }, |
| 258 | { |
| 259 | option: "version", |
| 260 | alias: "v", |
| 261 | type: "Boolean", |
| 262 | description: "Output the version number" |
| 263 | }, |
| 264 | { |
| 265 | option: "print-config", |
| 266 | type: "path::String", |
| 267 | description: "Print the configuration for the given file" |
| 268 | } |
| 269 | ] |
| 270 | }); |