@cluerise/tools 4.0.3 → 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.
@@ -11,6 +11,10 @@
11
11
  build/
12
12
  dist/
13
13
 
14
+ # Cloudflare
15
+ .wrangler/
16
+ worker-configuration.d.ts
17
+
14
18
  # Dependencies
15
19
  node_modules/
16
20
 
@@ -2,6 +2,9 @@
2
2
  build/
3
3
  dist/
4
4
 
5
+ # Cloudflare
6
+ .wrangler/
7
+
5
8
  # Dependencies
6
9
  node_modules/
7
10
 
@@ -50,7 +50,7 @@ export default defineConfig([
50
50
  },
51
51
  {
52
52
  name: 'cluerise: typescript-eslint/disable-type-checked',
53
- files: ['**/*.js', '**/*.json', '**/*.yaml'],
53
+ files: ['**/*.js', '**/*.json', '**/*.jsonc', '**/*.yaml'],
54
54
  extends: [typescriptEslint.configs.disableTypeChecked]
55
55
  },
56
56
  {
@@ -147,12 +147,13 @@ export default defineConfig([
147
147
  'import/no-duplicates': 'error',
148
148
  'import/no-mutable-exports': 'error',
149
149
  'import/no-unassigned-import': ['error', { allow: ['reset-css'] }],
150
+ 'import/no-unresolved': ['error', { ignore: ['cloudflare:test'] }],
150
151
  'import/order': 'off'
151
152
  }
152
153
  },
153
154
  {
154
155
  name: 'cluerise: eslint/import/rules/config.js',
155
- files: ['*.config.js'],
156
+ files: ['**/*.config.js'],
156
157
  rules: {
157
158
  '@typescript-eslint/no-require-imports': 'off',
158
159
  'import/no-commonjs': 'off'
@@ -160,14 +161,21 @@ export default defineConfig([
160
161
  },
161
162
  {
162
163
  name: 'cluerise: eslint/import/rules/config.js,ts',
163
- files: ['*.config.{js,ts}'],
164
+ files: ['**/*.config.{js,ts}'],
164
165
  rules: {
165
166
  'import/no-default-export': 'off'
166
167
  }
167
168
  },
168
169
  {
169
170
  name: 'cluerise: eslint/import/rules/routes',
170
- files: ['*-route.tsx'],
171
+ files: ['**/*-route.tsx'],
172
+ rules: {
173
+ 'import/no-default-export': 'off'
174
+ }
175
+ },
176
+ {
177
+ name: 'cluerise: eslint/import/rules/workers',
178
+ files: ['**/src/index.{ts,tsx}'],
171
179
  rules: {
172
180
  'import/no-default-export': 'off'
173
181
  }
@@ -206,10 +214,21 @@ export default defineConfig([
206
214
  'error',
207
215
  {
208
216
  replacements: {
217
+ acc: false,
209
218
  arg: false,
210
219
  args: false,
211
220
  dist: false,
221
+ env: false,
222
+ envs: false,
223
+ param: false,
212
224
  params: false,
225
+ prev: false,
226
+ prop: false,
227
+ props: false,
228
+ ref: false,
229
+ refs: false,
230
+ rel: false,
231
+ temp: false,
213
232
  utils: false
214
233
  }
215
234
  }
@@ -253,21 +272,25 @@ export default defineConfig([
253
272
  '*.tgz',
254
273
 
255
274
  // Build
256
- 'build/',
257
- 'dist/',
275
+ '**/build/',
276
+ '**/dist/',
277
+
278
+ // Cloudflare
279
+ '../.wrangler/',
280
+ '**/worker-configuration.d.ts',
258
281
 
259
282
  // CSS
260
- '*.css',
283
+ '**/*.css',
261
284
 
262
285
  // Dependencies
263
- 'node_modules/',
286
+ '**/node_modules/',
264
287
 
265
288
  // Fonts
266
- '*.ttf',
267
- '*.woff2',
289
+ '**/*.ttf',
290
+ '**/*.woff2',
268
291
 
269
292
  // Generated files
270
- '__generated__/',
293
+ '**/__generated__/',
271
294
  'patches/',
272
295
 
273
296
  // Git
@@ -279,13 +302,13 @@ export default defineConfig([
279
302
  '!hooks/*.ts',
280
303
 
281
304
  // I18n
282
- '*.po',
305
+ '**/*.po',
283
306
 
284
307
  // Images
285
- '*.ico',
286
- '*.png',
287
- '*.svg',
288
- '*.webp',
308
+ '**/*.ico',
309
+ '**/*.png',
310
+ '**/*.svg',
311
+ '**/*.webp',
289
312
 
290
313
  // Lock files
291
314
  'pnpm-lock.yaml',
@@ -293,32 +316,32 @@ export default defineConfig([
293
316
  'yarn.lock',
294
317
 
295
318
  // Lua scripts
296
- '*.lua',
319
+ '**/*.lua',
297
320
 
298
321
  // Misc
299
- 'etc/',
300
- '.DS_Store',
322
+ '**/etc/',
323
+ '**/.DS_Store',
301
324
 
302
325
  // Sample of .env and .envrc files
303
- '.env.example',
304
- '.env.sample',
305
- '.envrc.example',
306
- '.envrc.sample',
326
+ '**/.env.example',
327
+ '**/.env.sample',
328
+ '**/.envrc.example',
329
+ '**/.envrc.sample',
307
330
 
308
331
  // Shell scripts
309
- '*.sh',
332
+ '**/*.sh',
310
333
 
311
334
  // Stryker
312
- '.stryker-tmp/',
335
+ '**/.stryker-tmp/',
313
336
 
314
337
  // Tests coverage
315
- 'coverage/',
338
+ '**/coverage/',
316
339
 
317
340
  // Texts
318
- '*.txt',
341
+ '**/*.txt',
319
342
 
320
343
  // XML
321
- '*.xml'
344
+ '**/*.xml'
322
345
  ]
323
346
  },
324
347
  // Prettier
@@ -1,9 +1,43 @@
1
1
  import FileSystem from 'node:fs';
2
2
  import Path from 'node:path';
3
3
 
4
- const tsconfigPath = '.lint-staged-temp-tsconfig.json';
4
+ const tempConfigName = '.lint-staged-temp-tsconfig.json';
5
5
 
6
- const mapToRelative = (filenames) => filenames.map((filename) => Path.relative('.', filename));
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 relativeFilenames = mapToRelative(filenames);
20
- const tsconfig = {
21
- extends: './tsconfig.json',
22
- files: relativeFilenames
23
- };
24
-
25
- // eslint-disable-next-line no-restricted-globals
26
- FileSystem.writeFileSync(tsconfigPath, JSON.stringify(tsconfig));
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 ${tsconfigPath}`;
69
+ return [...fileGroups.keys()].map((configPath) => `tsc -p ${Path.relative('.', configPath)}`);
30
70
  }
31
71
  };
@@ -6,7 +6,7 @@
6
6
  "experimentalDecorators": true,
7
7
  "isolatedModules": true,
8
8
  "jsx": "preserve",
9
- "lib": ["dom", "esnext"],
9
+ "lib": ["esnext"],
10
10
  "module": "esnext",
11
11
  "moduleResolution": "bundler",
12
12
  "noEmit": true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cluerise/tools",
3
- "version": "4.0.3",
3
+ "version": "4.1.0",
4
4
  "description": "Tools for maintaining TypeScript projects.",
5
5
  "author": "Branislav Holý <brano@holy.am>",
6
6
  "repository": "github:cluerise/tools",
@@ -24,14 +24,14 @@
24
24
  "@commitlint/types": "19.8.1",
25
25
  "@eslint/js": "9.28.0",
26
26
  "@eslint/json": "0.12.0",
27
- "@eslint/markdown": "6.4.0",
27
+ "@eslint/markdown": "6.5.0",
28
28
  "@html-eslint/eslint-plugin": "0.41.0",
29
29
  "@html-eslint/parser": "0.41.0",
30
30
  "@typescript-eslint/parser": "8.33.1",
31
31
  "conventional-changelog-conventionalcommits": "9.0.0",
32
32
  "eslint": "9.28.0",
33
33
  "eslint-config-prettier": "10.1.5",
34
- "eslint-import-resolver-typescript": "4.4.2",
34
+ "eslint-import-resolver-typescript": "4.4.3",
35
35
  "eslint-plugin-import": "2.31.0",
36
36
  "eslint-plugin-prettier": "5.4.1",
37
37
  "eslint-plugin-simple-import-sort": "12.1.1",
@@ -45,6 +45,6 @@
45
45
  "semver": "7.7.2",
46
46
  "smol-toml": "1.3.4",
47
47
  "typescript-eslint": "8.33.1",
48
- "zod": "3.25.51"
48
+ "zod": "3.25.56"
49
49
  }
50
50
  }