1/** 2 * @fileoverview Options configuration for optionator. 3 * @author George Zahariev 4 */ 5 6"use strict"; 7 8//------------------------------------------------------------------------------ 9// Requirements 10//------------------------------------------------------------------------------ 11 12const optionator = require("optionator"); 13 14//------------------------------------------------------------------------------ 15// Initialization and Public Interface 16//------------------------------------------------------------------------------ 17 18// exports "parse(args)", "generateHelp()", and "generateHelpForOption(optionName)" 19module.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]", 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", 194 default: void 0, 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 { 218 heading: "Miscellaneous" 219 }, 220 { 221 option: "init", 222 type: "Boolean", 223 default: "false", 224 description: "Run config initialization wizard" 225 }, 226 { 227 option: "env-info", 228 type: "Boolean", 229 default: "false", 230 description: "Output execution environment information" 231 }, 232 { 233 option: "error-on-unmatched-pattern", 234 type: "Boolean", 235 default: "true", 236 description: "Prevent errors when pattern is unmatched" 237 }, 238 { 239 option: "debug", 240 type: "Boolean", 241 default: false, 242 description: "Output debugging information" 243 }, 244 { 245 option: "help", 246 alias: "h", 247 type: "Boolean", 248 description: "Show help" 249 }, 250 { 251 option: "version", 252 alias: "v", 253 type: "Boolean", 254 description: "Output the version number" 255 }, 256 { 257 option: "print-config", 258 type: "path::String", 259 description: "Print the configuration for the given file" 260 } 261 ] 262}); 263