options.js 7.4 KB

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