@cluerise/tools 4.0.4 → 4.1.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/dist/configs/_gitignore
CHANGED
|
@@ -214,12 +214,21 @@ export default defineConfig([
|
|
|
214
214
|
'error',
|
|
215
215
|
{
|
|
216
216
|
replacements: {
|
|
217
|
+
acc: false,
|
|
217
218
|
arg: false,
|
|
218
219
|
args: false,
|
|
219
220
|
dist: false,
|
|
220
221
|
env: false,
|
|
221
222
|
envs: false,
|
|
223
|
+
param: false,
|
|
222
224
|
params: false,
|
|
225
|
+
prev: false,
|
|
226
|
+
prop: false,
|
|
227
|
+
props: false,
|
|
228
|
+
ref: false,
|
|
229
|
+
refs: false,
|
|
230
|
+
rel: false,
|
|
231
|
+
temp: false,
|
|
223
232
|
utils: false
|
|
224
233
|
}
|
|
225
234
|
}
|
|
@@ -263,21 +272,25 @@ export default defineConfig([
|
|
|
263
272
|
'*.tgz',
|
|
264
273
|
|
|
265
274
|
// Build
|
|
266
|
-
'build/',
|
|
267
|
-
'dist/',
|
|
275
|
+
'**/build/',
|
|
276
|
+
'**/dist/',
|
|
277
|
+
|
|
278
|
+
// Cloudflare
|
|
279
|
+
'../.wrangler/',
|
|
280
|
+
'**/worker-configuration.d.ts',
|
|
268
281
|
|
|
269
282
|
// CSS
|
|
270
|
-
'
|
|
283
|
+
'**/*.css',
|
|
271
284
|
|
|
272
285
|
// Dependencies
|
|
273
|
-
'node_modules/',
|
|
286
|
+
'**/node_modules/',
|
|
274
287
|
|
|
275
288
|
// Fonts
|
|
276
|
-
'
|
|
277
|
-
'
|
|
289
|
+
'**/*.ttf',
|
|
290
|
+
'**/*.woff2',
|
|
278
291
|
|
|
279
292
|
// Generated files
|
|
280
|
-
'__generated__/',
|
|
293
|
+
'**/__generated__/',
|
|
281
294
|
'patches/',
|
|
282
295
|
|
|
283
296
|
// Git
|
|
@@ -289,13 +302,13 @@ export default defineConfig([
|
|
|
289
302
|
'!hooks/*.ts',
|
|
290
303
|
|
|
291
304
|
// I18n
|
|
292
|
-
'
|
|
305
|
+
'**/*.po',
|
|
293
306
|
|
|
294
307
|
// Images
|
|
295
|
-
'
|
|
296
|
-
'
|
|
297
|
-
'
|
|
298
|
-
'
|
|
308
|
+
'**/*.ico',
|
|
309
|
+
'**/*.png',
|
|
310
|
+
'**/*.svg',
|
|
311
|
+
'**/*.webp',
|
|
299
312
|
|
|
300
313
|
// Lock files
|
|
301
314
|
'pnpm-lock.yaml',
|
|
@@ -303,32 +316,32 @@ export default defineConfig([
|
|
|
303
316
|
'yarn.lock',
|
|
304
317
|
|
|
305
318
|
// Lua scripts
|
|
306
|
-
'
|
|
319
|
+
'**/*.lua',
|
|
307
320
|
|
|
308
321
|
// Misc
|
|
309
|
-
'etc/',
|
|
310
|
-
'
|
|
322
|
+
'**/etc/',
|
|
323
|
+
'**/.DS_Store',
|
|
311
324
|
|
|
312
325
|
// Sample of .env and .envrc files
|
|
313
|
-
'
|
|
314
|
-
'
|
|
315
|
-
'
|
|
316
|
-
'
|
|
326
|
+
'**/.env.example',
|
|
327
|
+
'**/.env.sample',
|
|
328
|
+
'**/.envrc.example',
|
|
329
|
+
'**/.envrc.sample',
|
|
317
330
|
|
|
318
331
|
// Shell scripts
|
|
319
|
-
'
|
|
332
|
+
'**/*.sh',
|
|
320
333
|
|
|
321
334
|
// Stryker
|
|
322
|
-
'
|
|
335
|
+
'**/.stryker-tmp/',
|
|
323
336
|
|
|
324
337
|
// Tests coverage
|
|
325
|
-
'coverage/',
|
|
338
|
+
'**/coverage/',
|
|
326
339
|
|
|
327
340
|
// Texts
|
|
328
|
-
'
|
|
341
|
+
'**/*.txt',
|
|
329
342
|
|
|
330
343
|
// XML
|
|
331
|
-
'
|
|
344
|
+
'**/*.xml'
|
|
332
345
|
]
|
|
333
346
|
},
|
|
334
347
|
// Prettier
|
|
@@ -1,9 +1,43 @@
|
|
|
1
1
|
import FileSystem from 'node:fs';
|
|
2
2
|
import Path from 'node:path';
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const tempConfigName = '.lint-staged-temp-tsconfig.json';
|
|
5
5
|
|
|
6
|
-
const mapToRelative = (filenames) => filenames.map((filename) => Path.relative(
|
|
6
|
+
const mapToRelative = (filenames, root = '.') => filenames.map((filename) => Path.relative(root, filename));
|
|
7
|
+
|
|
8
|
+
const findFileConfig = (filename) => {
|
|
9
|
+
let directory = Path.dirname(filename);
|
|
10
|
+
while (directory !== Path.parse(directory).root) {
|
|
11
|
+
const configPath = Path.join(directory, 'tsconfig.json');
|
|
12
|
+
if (FileSystem.existsSync(configPath)) {
|
|
13
|
+
return configPath;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
directory = Path.dirname(directory);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return null;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const groupFilesByConfig = (filenames) => {
|
|
23
|
+
const fileGroups = new Map();
|
|
24
|
+
|
|
25
|
+
for (const filename of filenames) {
|
|
26
|
+
const configPath = findFileConfig(filename);
|
|
27
|
+
if (!configPath) {
|
|
28
|
+
console.warn(`No tsconfig.json found for ${filename}`);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!fileGroups.has(configPath)) {
|
|
33
|
+
fileGroups.set(configPath, []);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
fileGroups.get(configPath).push(filename);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return fileGroups;
|
|
40
|
+
};
|
|
7
41
|
|
|
8
42
|
export default {
|
|
9
43
|
'**': (filenames) => {
|
|
@@ -12,20 +46,26 @@ export default {
|
|
|
12
46
|
return [`eslint ${relativeFilenames}`, `prettier --check ${relativeFilenames}`];
|
|
13
47
|
},
|
|
14
48
|
'**/*.ts?(x)': (filenames) => {
|
|
49
|
+
const fileGroups = groupFilesByConfig(filenames);
|
|
50
|
+
|
|
15
51
|
// The lint-staged command runs this function multiple times to prepare
|
|
16
52
|
// console messages. We want to save the temporary tsconfig.json file only
|
|
17
53
|
// when this function is run with filenames (that start with a slash)
|
|
18
54
|
if (filenames.length > 0 && filenames[0].startsWith('/')) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
55
|
+
for (const [configPath, filenames] of fileGroups.entries()) {
|
|
56
|
+
const tempConfigPath = Path.join(Path.dirname(configPath), tempConfigName);
|
|
57
|
+
|
|
58
|
+
const relativeFilenames = mapToRelative(filenames, Path.dirname(configPath));
|
|
59
|
+
const tempConfig = {
|
|
60
|
+
extends: './tsconfig.json',
|
|
61
|
+
files: relativeFilenames
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// eslint-disable-next-line no-restricted-globals
|
|
65
|
+
FileSystem.writeFileSync(tempConfigPath, JSON.stringify(tempConfig));
|
|
66
|
+
}
|
|
27
67
|
}
|
|
28
68
|
|
|
29
|
-
return `tsc -p ${
|
|
69
|
+
return [...fileGroups.keys()].map((configPath) => `tsc -p ${Path.relative('.', configPath)}`);
|
|
30
70
|
}
|
|
31
71
|
};
|