@w5s/dev 3.2.3 → 3.3.2

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/dist/index.d.ts CHANGED
@@ -1,167 +1,36 @@
1
1
  import { ESLint } from "eslint";
2
2
 
3
- //#region src/directory.d.ts
4
- interface DirectoryOptions {
5
- /**
6
- * Directory path
7
- */
8
- readonly path: string;
9
- /**
10
- * Directory target state
11
- */
12
- readonly state: 'present' | 'absent';
13
- }
14
- /**
15
- * Ensure directory is present/absent
16
- *
17
- * @example
18
- * ```ts
19
- * await directory({
20
- * path: 'foo/bar',
21
- * state: 'present',
22
- * })
23
- * ```
24
- *
25
- * @param options
26
- */
27
- declare function directory(options: DirectoryOptions): Promise<void>;
28
- /**
29
- * Ensure directory is present/absent
30
- *
31
- * @example
32
- * ```ts
33
- * await directorySync({
34
- * path: 'foo/bar',
35
- * state: 'present',
36
- * })
37
- * ```
38
- *
39
- * @param options
40
- */
41
- declare function directorySync(options: DirectoryOptions): void;
42
- //#endregion
43
3
  //#region src/ESLintConfig.d.ts
44
- declare namespace ESLintConfig {
45
- /**
46
- *
47
- * @param configs
48
- */
49
- function concat(...configs: ESLint.ConfigData[]): ESLint.ConfigData;
50
- /**
51
- * Always return 'off'. `_status` is the previous rule value.
52
- *
53
- * @param _status
54
- */
55
- function fixme(_status: string | number | [string | number, ...any[]] | undefined): "off";
56
- /**
57
- * Renames rules in the given object according to the given map.
58
- *
59
- * Given a map `{ 'old-prefix': 'new-prefix' }`, and a rule object
60
- * `{ 'old-prefix/rule-name': 'error' }`, this function will return
61
- * `{ 'new-prefix/rule-name': 'error' }`.
62
- *
63
- * @param rules The object containing the rules to rename.
64
- * @param map The object containing the rename map.
65
- */
66
- function renameRules(rules: Record<string, any>, map: Record<string, string>): Record<string, any>;
67
- }
68
- //#endregion
69
- //#region src/block.d.ts
70
- interface BlockOptions {
71
- /**
72
- * The marker builder function that will take either `markerBegin` or `markerEnd`
73
- *
74
- * @default '# ${mark} MANAGED BLOCK'
75
- */
76
- marker?: (mark: 'Begin' | 'End') => string;
77
- /**
78
- * File path
79
- */
80
- path: string;
81
- /**
82
- * Block content to insert
83
- */
84
- block: string;
85
- /**
86
- * Insert position
87
- */
88
- insertPosition?: ['before', 'BeginningOfFile' | RegExp] | ['after', 'EndOfFile' | RegExp];
89
- /**
90
- * Block target state
91
- */
92
- state?: 'present' | 'absent';
93
- }
94
4
  /**
95
- * Replace asynchronously a block in file that follows pattern :
96
- *
97
- * marker(markerBegin)
98
- * ...
99
- * marker(markerEnd)
100
5
  *
101
- * @param options
6
+ * @param configs
102
7
  */
103
- declare function block(options: BlockOptions): Promise<void>;
8
+ declare function concat(...configs: ESLint.ConfigData[]): ESLint.ConfigData;
104
9
  /**
105
- * Replace synchronously a block in file that follows pattern :
106
- *
107
- * marker(markerBegin)
108
- * ...
109
- * marker(markerEnd)
10
+ * Always return 'off'. `_status` is the previous rule value.
110
11
  *
111
- * @param options
12
+ * @param _status
112
13
  */
113
- declare function blockSync(options: BlockOptions): void;
114
- //#endregion
115
- //#region src/file.d.ts
116
- interface FileOptions {
117
- /**
118
- * File path
119
- */
120
- readonly path: string;
121
- /**
122
- * File target state
123
- */
124
- readonly state: 'present' | 'absent';
125
- /**
126
- * File content mapping function
127
- *
128
- */
129
- readonly update?: ((content: string) => string | undefined) | undefined;
130
- /**
131
- * File encoding
132
- */
133
- readonly encoding?: BufferEncoding;
134
- }
14
+ declare function fixme(_status: string | number | [string | number, ...any[]] | undefined): "off";
135
15
  /**
136
- * Ensure file is present/absent with content initialized or modified with `update
16
+ * Renames rules in the given object according to the given map.
137
17
  *
138
- * @example
139
- * ```ts
140
- * await file({
141
- * path: 'foo/bar',
142
- * state: 'present',
143
- * update: (content) => content + '_test', // This will append '_test' after current content
144
- * })
145
- * ```
18
+ * Given a map `{ 'old-prefix': 'new-prefix' }`, and a rule object
19
+ * `{ 'old-prefix/rule-name': 'error' }`, this function will return
20
+ * `{ 'new-prefix/rule-name': 'error' }`.
146
21
  *
147
- * @param options
22
+ * @param rules The object containing the rules to rename.
23
+ * @param map The object containing the rename map.
148
24
  */
149
- declare function file(options: FileOptions): Promise<void>;
25
+ declare function renameRules(rules: Record<string, any>, map: Record<string, string>): Record<string, any>;
150
26
  /**
151
- * Ensure file is present/absent with content initialized or modified with `update
152
- *
153
- * @example
154
- * ```ts
155
- * fileSync({
156
- * path: 'foo/bar',
157
- * state: 'present',
158
- * update: (content) => content + '_test', // This will append '_test' after current content
159
- * })
160
- * ```
161
- *
162
- * @param options
27
+ * @namespace
163
28
  */
164
- declare function fileSync(options: FileOptions): void;
29
+ declare const ESLintConfig: Readonly<{
30
+ concat: typeof concat;
31
+ fixme: typeof fixme;
32
+ renameRules: typeof renameRules;
33
+ }>;
165
34
  //#endregion
166
35
  //#region src/interopDefault.d.ts
167
36
  /**
@@ -214,41 +83,6 @@ interface LanguageIdMap {
214
83
  */
215
84
  type LanguageId = keyof LanguageIdMap;
216
85
  //#endregion
217
- //#region src/json.d.ts
218
- type JSONValue = null | number | string | boolean | JSONValue[] | {
219
- [key: string]: JSONValue;
220
- };
221
- interface JSONOption<V = JSONValue> {
222
- /**
223
- * File path
224
- */
225
- readonly path: string;
226
- /**
227
- * File target state
228
- */
229
- readonly state: 'present' | 'absent';
230
- /**
231
- * File content mapping function
232
- */
233
- readonly update?: ((content: V | undefined) => V | undefined) | undefined;
234
- /**
235
- * File encoding
236
- */
237
- readonly encoding?: BufferEncoding;
238
- }
239
- /**
240
- * Ensure file is present/absent asynchronously with content value initialized or modified with `update`
241
- *
242
- * @param options
243
- */
244
- declare function json<Value>(options: JSONOption<Value>): Promise<void>;
245
- /**
246
- * Ensure file is present/absent synchronously with content value initialized or modified with `update`
247
- *
248
- * @param options
249
- */
250
- declare function jsonSync<Value>(options: JSONOption<Value>): void;
251
- //#endregion
252
86
  //#region src/meta.d.ts
253
87
  declare const meta: Readonly<{
254
88
  name: string;
@@ -257,84 +91,91 @@ declare const meta: Readonly<{
257
91
  }>;
258
92
  //#endregion
259
93
  //#region src/Project.d.ts
260
- declare namespace Project {
261
- /**
262
- * A type of a file extension
263
- */
264
- type Extension = `.${string}`;
265
- /**
266
- * Object hash of all well-known file extension category to file extensions mapping
267
- */
268
- type ExtensionRegistry = { [K in LanguageId]: readonly Extension[] };
269
- /**
270
- * Supported ECMA version
271
- *
272
- * @example
273
- * ```ts
274
- * Project.ecmaVersion() // 2022
275
- * ```
276
- */
277
- function ecmaVersion(): 2022;
278
- /**
279
- * Return a list of extensions
280
- *
281
- * @example
282
- * ```ts
283
- * Project.queryExtensions(['javascript']); // ['.js', '.cjs', ...]
284
- * Project.queryExtensions(['typescript', 'typescriptreact']); // ['.ts', '.mts', ..., '.tsx']
285
- * ```
286
- *
287
- * @param languages
288
- */
289
- function queryExtensions(languages: LanguageId[]): readonly Extension[];
290
- /**
291
- * Supported file extensions
292
- *
293
- * @example
294
- * ```ts
295
- * Project.sourceExtensions() // ['.ts', '.js', ...]
296
- * ```
297
- */
298
- function sourceExtensions(): readonly `.${string}`[];
299
- /**
300
- * Resource file extensions
301
- *
302
- * @example
303
- * ```ts
304
- * Project.resourceExtensions() // ['.css', '.sass', ...]
305
- * ```
306
- */
307
- function resourceExtensions(): readonly `.${string}`[];
308
- /**
309
- * Files and folders to always ignore
310
- *
311
- * @example
312
- * ```ts
313
- * IGNORED // ['node_modules/', 'build/', ...]
314
- * ```
315
- */
316
- function ignored(): readonly string[];
317
- /**
318
- * Return a RegExp that will match any list of extensions
319
- *
320
- * @param extensions
321
- * @example
322
- * ```ts
323
- * Project.extensionsToMatcher(['.js', '.ts']) // RegExp = /(\.js|\.ts)$/
324
- * ```
325
- */
326
- function extensionsToMatcher(extensions: readonly Extension[]): RegExp;
327
- /**
328
- * Return a glob matcher that will match any list of extensions
329
- *
330
- * @param extensions
331
- * @example
332
- * ```ts
333
- * Project.extensionsToGlob(['.js', '.ts']) // '*.+(js|ts)'
334
- * ```
335
- */
336
- function extensionsToGlob(extensions: readonly Extension[]): string;
337
- }
94
+ /**
95
+ * A type of a file extension
96
+ */
97
+ type Extension = `.${string}`;
98
+ /**
99
+ * Object hash of all well-known file extension category to file extensions mapping
100
+ */
101
+ type ExtensionRegistry = { [K in LanguageId]: readonly Extension[] };
102
+ /**
103
+ * Supported ECMA version
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * Project.ecmaVersion() // 2022
108
+ * ```
109
+ */
110
+ declare function ecmaVersion(): 2022;
111
+ /**
112
+ * Return a list of extensions
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * Project.queryExtensions(['javascript']); // ['.js', '.cjs', ...]
117
+ * Project.queryExtensions(['typescript', 'typescriptreact']); // ['.ts', '.mts', ..., '.tsx']
118
+ * ```
119
+ *
120
+ * @param languages
121
+ */
122
+ declare function queryExtensions(languages: LanguageId[]): readonly Extension[];
123
+ /**
124
+ * Supported file extensions
125
+ *
126
+ * @example
127
+ * ```ts
128
+ * Project.sourceExtensions() // ['.ts', '.js', ...]
129
+ * ```
130
+ */
131
+ declare function sourceExtensions(): readonly `.${string}`[];
132
+ /**
133
+ * Resource file extensions
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * Project.resourceExtensions() // ['.css', '.sass', ...]
138
+ * ```
139
+ */
140
+ declare function resourceExtensions(): readonly `.${string}`[];
141
+ /**
142
+ * Files and folders to always ignore
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * IGNORED // ['node_modules/', 'build/', ...]
147
+ * ```
148
+ */
149
+ declare function ignored(): readonly string[];
150
+ /**
151
+ * Return a RegExp that will match any list of extensions
152
+ *
153
+ * @param extensions
154
+ * @example
155
+ * ```ts
156
+ * Project.extensionsToMatcher(['.js', '.ts']) // RegExp = /(\.js|\.ts)$/
157
+ * ```
158
+ */
159
+ declare function extensionsToMatcher(extensions: readonly Extension[]): RegExp;
160
+ /**
161
+ * Return a glob matcher that will match any list of extensions
162
+ *
163
+ * @param extensions
164
+ * @example
165
+ * ```ts
166
+ * Project.extensionsToGlob(['.js', '.ts']) // '*.+(js|ts)'
167
+ * ```
168
+ */
169
+ declare function extensionsToGlob(extensions: readonly Extension[]): string;
170
+ declare const Project: Readonly<{
171
+ ecmaVersion: typeof ecmaVersion;
172
+ extensionsToGlob: typeof extensionsToGlob;
173
+ extensionsToMatcher: typeof extensionsToMatcher;
174
+ ignored: typeof ignored;
175
+ queryExtensions: typeof queryExtensions;
176
+ resourceExtensions: typeof resourceExtensions;
177
+ sourceExtensions: typeof sourceExtensions;
178
+ }>;
338
179
  //#endregion
339
180
  //#region src/ProjectScript.d.ts
340
181
  /**
@@ -355,86 +196,10 @@ declare const ProjectScript: {
355
196
  readonly Rescue: "rescue";
356
197
  readonly Spellcheck: "spellcheck";
357
198
  readonly Test: "test";
199
+ readonly Typecheck: "typecheck";
358
200
  readonly Validate: "validate";
359
201
  };
360
202
  type ProjectScript = (typeof ProjectScript)[keyof typeof ProjectScript];
361
203
  //#endregion
362
- //#region src/yarnConfig.d.ts
363
- interface YarnConfigOptions {
364
- /**
365
- * Configuration key
366
- */
367
- readonly key: string;
368
- /**
369
- * Option target state
370
- */
371
- readonly state: 'present' | 'absent';
372
- /**
373
- * File content mapping function
374
- *
375
- */
376
- readonly update?: ((content: string) => string | undefined) | undefined;
377
- }
378
- /**
379
- * Synchronous version of {@link yarnConfig}
380
- *
381
- * @param options
382
- * @example
383
- * yarnConfigSync({
384
- * key: 'nodeLinker',
385
- * state: 'present',
386
- * update: (content) => content.replace('node-modules', 'hoisted'),
387
- * })
388
- */
389
- declare function yarnConfigSync(options: YarnConfigOptions): void;
390
- /**
391
- * Set/Unset yarn configuration value
392
- *
393
- * @param options
394
- * @example
395
- * await yarnConfig({
396
- * key: 'nodeLinker',
397
- * state: 'present',
398
- * update: (content) => content.replace('node-modules', 'hoisted'),
399
- * })
400
- */
401
- declare function yarnConfig(options: YarnConfigOptions): Promise<void>;
402
- //#endregion
403
- //#region src/yarnVersion.d.ts
404
- type YarnVersionKind = 'berry' | 'classic';
405
- interface YarnVersionOptions {
406
- /**
407
- * Option target state
408
- */
409
- readonly state: 'present' | 'absent';
410
- /**
411
- * Version mapping function
412
- *
413
- */
414
- readonly update?: (() => YarnVersionKind | undefined) | undefined;
415
- }
416
- /**
417
- * Synchronous version of {@link yarnVersion}
418
- *
419
- * @param options
420
- * @example
421
- * yarnVersionSync({
422
- * state: 'present',
423
- * update: () => 'berry', // or 'classic'
424
- * })
425
- */
426
- declare function yarnVersionSync(options: YarnVersionOptions): void;
427
- /**
428
- * Set/Unset yarn configuration value
429
- *
430
- * @param options
431
- * @example
432
- * await yarnVersion({
433
- * state: 'present',
434
- * update: () => 'berry', // or 'classic'
435
- * })
436
- */
437
- declare function yarnVersion(options: YarnVersionOptions): Promise<void>;
438
- //#endregion
439
- export { BlockOptions, DirectoryOptions, ESLintConfig, FileOptions, JSONOption, JSONValue, LanguageId, LanguageIdMap, Project, ProjectScript, YarnConfigOptions, YarnVersionKind, YarnVersionOptions, block, blockSync, directory, directorySync, file, fileSync, interopDefault, json, jsonSync, meta, yarnConfig, yarnConfigSync, yarnVersion, yarnVersionSync };
204
+ export { ESLintConfig, Extension, ExtensionRegistry, LanguageId, LanguageIdMap, Project, ProjectScript, interopDefault, meta };
440
205
  //# sourceMappingURL=index.d.ts.map