vize 0.39.0 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -1
- package/bin/vize +1 -1
- package/dist/cli.mjs +36 -4
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-DBaKDK6P.d.mts → config-tYKh_ZMu.d.mts} +14 -7
- package/dist/{config-DBaKDK6P.d.mts.map → config-tYKh_ZMu.d.mts.map} +1 -1
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +71 -34
- package/dist/config.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +21 -17
- package/pkl/vize.pkl +122 -0
- package/schemas/vize.config.schema.json +352 -0
- package/src/cli.ts +55 -4
- package/src/config.ts +100 -41
- package/src/index.ts +8 -1
- package/src/types/core.ts +5 -0
- package/src/types/tools.ts +4 -4
package/pkl/vize.pkl
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/// Shared schema for `vize.config.pkl`.
|
|
2
|
+
///
|
|
3
|
+
/// Example:
|
|
4
|
+
/// amends "node_modules/vize/pkl/vize.pkl"
|
|
5
|
+
///
|
|
6
|
+
/// compiler {
|
|
7
|
+
/// sourceMap = true
|
|
8
|
+
/// }
|
|
9
|
+
module vize.Config
|
|
10
|
+
|
|
11
|
+
typealias CompilerMode = "module" | "function"
|
|
12
|
+
typealias ScriptExt = "ts" | "js"
|
|
13
|
+
typealias RuleSeverity = "off" | "warn" | "error"
|
|
14
|
+
typealias LintPreset = "happy-path" | "opinionated" | "essential" | "nuxt"
|
|
15
|
+
typealias TrailingComma = "all" | "none" | "es5"
|
|
16
|
+
typealias FilterPattern = String | Listing<String>
|
|
17
|
+
typealias GlobalTypeValue = String | GlobalTypeDeclaration
|
|
18
|
+
|
|
19
|
+
class CompilerConfig {
|
|
20
|
+
mode: CompilerMode? = null
|
|
21
|
+
vapor: Boolean? = null
|
|
22
|
+
ssr: Boolean? = null
|
|
23
|
+
sourceMap: Boolean? = null
|
|
24
|
+
prefixIdentifiers: Boolean? = null
|
|
25
|
+
hoistStatic: Boolean? = null
|
|
26
|
+
cacheHandlers: Boolean? = null
|
|
27
|
+
isTs: Boolean? = null
|
|
28
|
+
scriptExt: ScriptExt? = null
|
|
29
|
+
runtimeModuleName: String? = null
|
|
30
|
+
runtimeGlobalName: String? = null
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class VitePluginConfig {
|
|
34
|
+
include: FilterPattern? = null
|
|
35
|
+
exclude: FilterPattern? = null
|
|
36
|
+
scanPatterns: Listing<String>? = null
|
|
37
|
+
ignorePatterns: Listing<String>? = null
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
class LinterConfig {
|
|
41
|
+
enabled: Boolean? = null
|
|
42
|
+
preset: LintPreset? = null
|
|
43
|
+
rules: Mapping<String, RuleSeverity>? = null
|
|
44
|
+
categories: Mapping<String, RuleSeverity>? = null
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
class TypeCheckerConfig {
|
|
48
|
+
enabled: Boolean? = null
|
|
49
|
+
strict: Boolean? = null
|
|
50
|
+
checkProps: Boolean? = null
|
|
51
|
+
checkEmits: Boolean? = null
|
|
52
|
+
checkTemplateBindings: Boolean? = null
|
|
53
|
+
tsconfig: String? = null
|
|
54
|
+
corsaPath: String? = null
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
class FormatterConfig {
|
|
58
|
+
printWidth: Int? = null
|
|
59
|
+
tabWidth: Int? = null
|
|
60
|
+
useTabs: Boolean? = null
|
|
61
|
+
semi: Boolean? = null
|
|
62
|
+
singleQuote: Boolean? = null
|
|
63
|
+
trailingComma: TrailingComma? = null
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
class LspConfig {
|
|
67
|
+
enabled: Boolean? = null
|
|
68
|
+
diagnostics: Boolean? = null
|
|
69
|
+
completion: Boolean? = null
|
|
70
|
+
hover: Boolean? = null
|
|
71
|
+
definition: Boolean? = null
|
|
72
|
+
formatting: Boolean? = null
|
|
73
|
+
codeActions: Boolean? = null
|
|
74
|
+
corsa: Boolean? = null
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
class MuseaViewport {
|
|
78
|
+
width: Number
|
|
79
|
+
height: Number
|
|
80
|
+
name: String? = null
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
class MuseaVrtConfig {
|
|
84
|
+
threshold: Number? = null
|
|
85
|
+
outDir: String? = null
|
|
86
|
+
viewports: Listing<MuseaViewport>? = null
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
class MuseaA11yConfig {
|
|
90
|
+
enabled: Boolean? = null
|
|
91
|
+
rules: Mapping<String, Boolean>? = null
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
class MuseaAutogenConfig {
|
|
95
|
+
enabled: Boolean? = null
|
|
96
|
+
maxVariants: Int? = null
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
class MuseaConfig {
|
|
100
|
+
include: Listing<String>? = null
|
|
101
|
+
exclude: Listing<String>? = null
|
|
102
|
+
basePath: String? = null
|
|
103
|
+
storybookCompat: Boolean? = null
|
|
104
|
+
inlineArt: Boolean? = null
|
|
105
|
+
vrt: MuseaVrtConfig?
|
|
106
|
+
a11y: MuseaA11yConfig?
|
|
107
|
+
autogen: MuseaAutogenConfig?
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
class GlobalTypeDeclaration {
|
|
111
|
+
type: String
|
|
112
|
+
defaultValue: String? = null
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
compiler: CompilerConfig?
|
|
116
|
+
vite: VitePluginConfig?
|
|
117
|
+
linter: LinterConfig?
|
|
118
|
+
typeChecker: TypeCheckerConfig?
|
|
119
|
+
formatter: FormatterConfig?
|
|
120
|
+
lsp: LspConfig?
|
|
121
|
+
musea: MuseaConfig?
|
|
122
|
+
globalTypes: Mapping<String, GlobalTypeValue>? = null
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://unpkg.com/vize/schemas/vize.config.schema.json",
|
|
4
|
+
"title": "Vize Config",
|
|
5
|
+
"description": "Configuration file for Vize.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"$schema": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "JSON Schema reference for editor autocompletion."
|
|
12
|
+
},
|
|
13
|
+
"compiler": {
|
|
14
|
+
"$ref": "#/$defs/compilerConfig"
|
|
15
|
+
},
|
|
16
|
+
"vite": {
|
|
17
|
+
"$ref": "#/$defs/vitePluginConfig"
|
|
18
|
+
},
|
|
19
|
+
"linter": {
|
|
20
|
+
"$ref": "#/$defs/linterConfig"
|
|
21
|
+
},
|
|
22
|
+
"typeChecker": {
|
|
23
|
+
"$ref": "#/$defs/typeCheckerConfig"
|
|
24
|
+
},
|
|
25
|
+
"formatter": {
|
|
26
|
+
"$ref": "#/$defs/formatterConfig"
|
|
27
|
+
},
|
|
28
|
+
"lsp": {
|
|
29
|
+
"$ref": "#/$defs/lspConfig"
|
|
30
|
+
},
|
|
31
|
+
"musea": {
|
|
32
|
+
"$ref": "#/$defs/museaConfig"
|
|
33
|
+
},
|
|
34
|
+
"globalTypes": {
|
|
35
|
+
"$ref": "#/$defs/globalTypesConfig"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"$defs": {
|
|
39
|
+
"ruleSeverity": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"enum": ["off", "warn", "error"]
|
|
42
|
+
},
|
|
43
|
+
"lintPreset": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"enum": ["happy-path", "opinionated", "essential", "nuxt"]
|
|
46
|
+
},
|
|
47
|
+
"patternLike": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"description": "Pattern string used by non-JavaScript configs. JavaScript configs may also use RegExp values."
|
|
50
|
+
},
|
|
51
|
+
"compilerConfig": {
|
|
52
|
+
"type": "object",
|
|
53
|
+
"additionalProperties": false,
|
|
54
|
+
"properties": {
|
|
55
|
+
"mode": {
|
|
56
|
+
"type": "string",
|
|
57
|
+
"enum": ["module", "function"]
|
|
58
|
+
},
|
|
59
|
+
"vapor": {
|
|
60
|
+
"type": "boolean"
|
|
61
|
+
},
|
|
62
|
+
"ssr": {
|
|
63
|
+
"type": "boolean"
|
|
64
|
+
},
|
|
65
|
+
"sourceMap": {
|
|
66
|
+
"type": "boolean"
|
|
67
|
+
},
|
|
68
|
+
"prefixIdentifiers": {
|
|
69
|
+
"type": "boolean"
|
|
70
|
+
},
|
|
71
|
+
"hoistStatic": {
|
|
72
|
+
"type": "boolean"
|
|
73
|
+
},
|
|
74
|
+
"cacheHandlers": {
|
|
75
|
+
"type": "boolean"
|
|
76
|
+
},
|
|
77
|
+
"isTs": {
|
|
78
|
+
"type": "boolean"
|
|
79
|
+
},
|
|
80
|
+
"scriptExt": {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"enum": ["ts", "js"]
|
|
83
|
+
},
|
|
84
|
+
"runtimeModuleName": {
|
|
85
|
+
"type": "string"
|
|
86
|
+
},
|
|
87
|
+
"runtimeGlobalName": {
|
|
88
|
+
"type": "string"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"vitePluginConfig": {
|
|
93
|
+
"type": "object",
|
|
94
|
+
"additionalProperties": false,
|
|
95
|
+
"properties": {
|
|
96
|
+
"include": {
|
|
97
|
+
"oneOf": [
|
|
98
|
+
{ "$ref": "#/$defs/patternLike" },
|
|
99
|
+
{
|
|
100
|
+
"type": "array",
|
|
101
|
+
"items": { "$ref": "#/$defs/patternLike" }
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
"exclude": {
|
|
106
|
+
"oneOf": [
|
|
107
|
+
{ "$ref": "#/$defs/patternLike" },
|
|
108
|
+
{
|
|
109
|
+
"type": "array",
|
|
110
|
+
"items": { "$ref": "#/$defs/patternLike" }
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
"scanPatterns": {
|
|
115
|
+
"type": "array",
|
|
116
|
+
"items": { "type": "string" }
|
|
117
|
+
},
|
|
118
|
+
"ignorePatterns": {
|
|
119
|
+
"type": "array",
|
|
120
|
+
"items": { "type": "string" }
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"linterConfig": {
|
|
125
|
+
"type": "object",
|
|
126
|
+
"additionalProperties": false,
|
|
127
|
+
"properties": {
|
|
128
|
+
"enabled": {
|
|
129
|
+
"type": "boolean"
|
|
130
|
+
},
|
|
131
|
+
"preset": {
|
|
132
|
+
"$ref": "#/$defs/lintPreset"
|
|
133
|
+
},
|
|
134
|
+
"rules": {
|
|
135
|
+
"type": "object",
|
|
136
|
+
"additionalProperties": {
|
|
137
|
+
"$ref": "#/$defs/ruleSeverity"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"categories": {
|
|
141
|
+
"type": "object",
|
|
142
|
+
"additionalProperties": false,
|
|
143
|
+
"properties": {
|
|
144
|
+
"correctness": { "$ref": "#/$defs/ruleSeverity" },
|
|
145
|
+
"suspicious": { "$ref": "#/$defs/ruleSeverity" },
|
|
146
|
+
"style": { "$ref": "#/$defs/ruleSeverity" },
|
|
147
|
+
"perf": { "$ref": "#/$defs/ruleSeverity" },
|
|
148
|
+
"a11y": { "$ref": "#/$defs/ruleSeverity" },
|
|
149
|
+
"security": { "$ref": "#/$defs/ruleSeverity" }
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
"typeCheckerConfig": {
|
|
155
|
+
"type": "object",
|
|
156
|
+
"additionalProperties": false,
|
|
157
|
+
"properties": {
|
|
158
|
+
"enabled": {
|
|
159
|
+
"type": "boolean"
|
|
160
|
+
},
|
|
161
|
+
"strict": {
|
|
162
|
+
"type": "boolean"
|
|
163
|
+
},
|
|
164
|
+
"checkProps": {
|
|
165
|
+
"type": "boolean"
|
|
166
|
+
},
|
|
167
|
+
"checkEmits": {
|
|
168
|
+
"type": "boolean"
|
|
169
|
+
},
|
|
170
|
+
"checkTemplateBindings": {
|
|
171
|
+
"type": "boolean"
|
|
172
|
+
},
|
|
173
|
+
"tsconfig": {
|
|
174
|
+
"type": "string"
|
|
175
|
+
},
|
|
176
|
+
"corsaPath": {
|
|
177
|
+
"type": "string"
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
"formatterConfig": {
|
|
182
|
+
"type": "object",
|
|
183
|
+
"additionalProperties": false,
|
|
184
|
+
"properties": {
|
|
185
|
+
"printWidth": {
|
|
186
|
+
"type": "integer"
|
|
187
|
+
},
|
|
188
|
+
"tabWidth": {
|
|
189
|
+
"type": "integer"
|
|
190
|
+
},
|
|
191
|
+
"useTabs": {
|
|
192
|
+
"type": "boolean"
|
|
193
|
+
},
|
|
194
|
+
"semi": {
|
|
195
|
+
"type": "boolean"
|
|
196
|
+
},
|
|
197
|
+
"singleQuote": {
|
|
198
|
+
"type": "boolean"
|
|
199
|
+
},
|
|
200
|
+
"trailingComma": {
|
|
201
|
+
"type": "string",
|
|
202
|
+
"enum": ["all", "none", "es5"]
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
"lspConfig": {
|
|
207
|
+
"type": "object",
|
|
208
|
+
"additionalProperties": false,
|
|
209
|
+
"properties": {
|
|
210
|
+
"enabled": {
|
|
211
|
+
"type": "boolean"
|
|
212
|
+
},
|
|
213
|
+
"diagnostics": {
|
|
214
|
+
"type": "boolean"
|
|
215
|
+
},
|
|
216
|
+
"completion": {
|
|
217
|
+
"type": "boolean"
|
|
218
|
+
},
|
|
219
|
+
"hover": {
|
|
220
|
+
"type": "boolean"
|
|
221
|
+
},
|
|
222
|
+
"definition": {
|
|
223
|
+
"type": "boolean"
|
|
224
|
+
},
|
|
225
|
+
"formatting": {
|
|
226
|
+
"type": "boolean"
|
|
227
|
+
},
|
|
228
|
+
"codeActions": {
|
|
229
|
+
"type": "boolean"
|
|
230
|
+
},
|
|
231
|
+
"corsa": {
|
|
232
|
+
"type": "boolean"
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
"museaViewport": {
|
|
237
|
+
"type": "object",
|
|
238
|
+
"additionalProperties": false,
|
|
239
|
+
"properties": {
|
|
240
|
+
"width": {
|
|
241
|
+
"type": "number"
|
|
242
|
+
},
|
|
243
|
+
"height": {
|
|
244
|
+
"type": "number"
|
|
245
|
+
},
|
|
246
|
+
"name": {
|
|
247
|
+
"type": "string"
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
"required": ["width", "height"]
|
|
251
|
+
},
|
|
252
|
+
"museaVrtConfig": {
|
|
253
|
+
"type": "object",
|
|
254
|
+
"additionalProperties": false,
|
|
255
|
+
"properties": {
|
|
256
|
+
"threshold": {
|
|
257
|
+
"type": "number"
|
|
258
|
+
},
|
|
259
|
+
"outDir": {
|
|
260
|
+
"type": "string"
|
|
261
|
+
},
|
|
262
|
+
"viewports": {
|
|
263
|
+
"type": "array",
|
|
264
|
+
"items": {
|
|
265
|
+
"$ref": "#/$defs/museaViewport"
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
"museaA11yConfig": {
|
|
271
|
+
"type": "object",
|
|
272
|
+
"additionalProperties": false,
|
|
273
|
+
"properties": {
|
|
274
|
+
"enabled": {
|
|
275
|
+
"type": "boolean"
|
|
276
|
+
},
|
|
277
|
+
"rules": {
|
|
278
|
+
"type": "object",
|
|
279
|
+
"additionalProperties": {
|
|
280
|
+
"type": "boolean"
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
"museaAutogenConfig": {
|
|
286
|
+
"type": "object",
|
|
287
|
+
"additionalProperties": false,
|
|
288
|
+
"properties": {
|
|
289
|
+
"enabled": {
|
|
290
|
+
"type": "boolean"
|
|
291
|
+
},
|
|
292
|
+
"maxVariants": {
|
|
293
|
+
"type": "integer"
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
"museaConfig": {
|
|
298
|
+
"type": "object",
|
|
299
|
+
"additionalProperties": false,
|
|
300
|
+
"properties": {
|
|
301
|
+
"include": {
|
|
302
|
+
"type": "array",
|
|
303
|
+
"items": { "type": "string" }
|
|
304
|
+
},
|
|
305
|
+
"exclude": {
|
|
306
|
+
"type": "array",
|
|
307
|
+
"items": { "type": "string" }
|
|
308
|
+
},
|
|
309
|
+
"basePath": {
|
|
310
|
+
"type": "string"
|
|
311
|
+
},
|
|
312
|
+
"storybookCompat": {
|
|
313
|
+
"type": "boolean"
|
|
314
|
+
},
|
|
315
|
+
"inlineArt": {
|
|
316
|
+
"type": "boolean"
|
|
317
|
+
},
|
|
318
|
+
"vrt": {
|
|
319
|
+
"$ref": "#/$defs/museaVrtConfig"
|
|
320
|
+
},
|
|
321
|
+
"a11y": {
|
|
322
|
+
"$ref": "#/$defs/museaA11yConfig"
|
|
323
|
+
},
|
|
324
|
+
"autogen": {
|
|
325
|
+
"$ref": "#/$defs/museaAutogenConfig"
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
"globalTypeDeclaration": {
|
|
330
|
+
"type": "object",
|
|
331
|
+
"additionalProperties": false,
|
|
332
|
+
"properties": {
|
|
333
|
+
"type": {
|
|
334
|
+
"type": "string"
|
|
335
|
+
},
|
|
336
|
+
"defaultValue": {
|
|
337
|
+
"type": "string"
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
"required": ["type"]
|
|
341
|
+
},
|
|
342
|
+
"globalTypesConfig": {
|
|
343
|
+
"type": "object",
|
|
344
|
+
"additionalProperties": {
|
|
345
|
+
"oneOf": [
|
|
346
|
+
{ "type": "string" },
|
|
347
|
+
{ "$ref": "#/$defs/globalTypeDeclaration" }
|
|
348
|
+
]
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
package/src/cli.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createRequire } from "module";
|
|
2
2
|
import { readFileSync } from "fs";
|
|
3
|
+
import { loadConfig } from "./config.js";
|
|
3
4
|
|
|
4
5
|
const require = createRequire(import.meta.url);
|
|
5
6
|
|
|
@@ -103,9 +104,23 @@ interface LintResult {
|
|
|
103
104
|
timeMs: number;
|
|
104
105
|
}
|
|
105
106
|
|
|
106
|
-
|
|
107
|
+
interface SharedConfigOptions {
|
|
108
|
+
configFile?: string;
|
|
109
|
+
configMode: "root" | "none";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
interface ParsedLintCommand {
|
|
113
|
+
patterns: string[];
|
|
114
|
+
options: LintOptions;
|
|
115
|
+
sharedConfig: SharedConfigOptions;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function parseLintCommand(args: string[]): ParsedLintCommand {
|
|
107
119
|
const patterns: string[] = [];
|
|
108
120
|
const options: LintOptions = {};
|
|
121
|
+
const sharedConfig: SharedConfigOptions = {
|
|
122
|
+
configMode: "root",
|
|
123
|
+
};
|
|
109
124
|
|
|
110
125
|
for (let i = 0; i < args.length; i++) {
|
|
111
126
|
const arg = args[i];
|
|
@@ -121,11 +136,44 @@ function runLint(args: string[]): void {
|
|
|
121
136
|
options.helpLevel = args[++i];
|
|
122
137
|
} else if (arg === "--preset") {
|
|
123
138
|
options.preset = args[++i];
|
|
139
|
+
} else if (arg === "--config" || arg === "-c") {
|
|
140
|
+
const configFile = args[++i];
|
|
141
|
+
if (!configFile) {
|
|
142
|
+
throw new Error("Missing path after --config");
|
|
143
|
+
}
|
|
144
|
+
sharedConfig.configFile = configFile;
|
|
145
|
+
} else if (arg === "--no-config") {
|
|
146
|
+
sharedConfig.configMode = "none";
|
|
124
147
|
} else if (!arg.startsWith("-")) {
|
|
125
148
|
patterns.push(arg);
|
|
126
149
|
}
|
|
127
150
|
}
|
|
128
151
|
|
|
152
|
+
return { patterns, options, sharedConfig };
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
async function runLint(args: string[]): Promise<void> {
|
|
156
|
+
const { patterns, options, sharedConfig } = parseLintCommand(args);
|
|
157
|
+
const config = await loadConfig(process.cwd(), {
|
|
158
|
+
mode: sharedConfig.configMode,
|
|
159
|
+
configFile: sharedConfig.configFile,
|
|
160
|
+
env: {
|
|
161
|
+
mode: process.env.NODE_ENV ?? "development",
|
|
162
|
+
command: "lint",
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
if (sharedConfig.configFile && !config) {
|
|
167
|
+
throw new Error(`Could not find config file: ${sharedConfig.configFile}`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (config?.linter?.enabled === false) {
|
|
171
|
+
process.stderr.write("[vize] Skipping lint because linter.enabled is false in vize.config.\n");
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
options.preset ??= config?.linter?.preset;
|
|
176
|
+
|
|
129
177
|
if (patterns.length === 0) {
|
|
130
178
|
patterns.push(".");
|
|
131
179
|
}
|
|
@@ -169,7 +217,7 @@ function runLint(args: string[]): void {
|
|
|
169
217
|
|
|
170
218
|
const NAPI_COMMANDS = new Set(["lint"]);
|
|
171
219
|
|
|
172
|
-
function main(): void {
|
|
220
|
+
async function main(): Promise<void> {
|
|
173
221
|
const args = process.argv.slice(2);
|
|
174
222
|
const command = args[0];
|
|
175
223
|
|
|
@@ -183,7 +231,7 @@ function main(): void {
|
|
|
183
231
|
const commandArgs = args.slice(1);
|
|
184
232
|
switch (command) {
|
|
185
233
|
case "lint":
|
|
186
|
-
runLint(commandArgs);
|
|
234
|
+
await runLint(commandArgs);
|
|
187
235
|
break;
|
|
188
236
|
}
|
|
189
237
|
} else {
|
|
@@ -195,4 +243,7 @@ function main(): void {
|
|
|
195
243
|
}
|
|
196
244
|
}
|
|
197
245
|
|
|
198
|
-
main()
|
|
246
|
+
void main().catch((error) => {
|
|
247
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
248
|
+
process.exit(1);
|
|
249
|
+
});
|