options.js 7.4 KB

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