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