options.js 6.6 KB

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