Skip to content

Commit c5eac68

Browse files
chore: fix lint warnings
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7c7ccb5 commit c5eac68

9 files changed

Lines changed: 66 additions & 33 deletions

File tree

benchmark/ci-summary.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ function tsgoGenerate(source: string, filename: string): string {
241241
writeFileSync(tmpFile, source)
242242
spawnSync(tsgoBin, [...tsgoFlags, tmpFile], { stdio: 'pipe', timeout: 30000 })
243243
const dtsFile = join(tsgoOutDir, safeFilename.replace(/\.ts$/, '.d.ts'))
244-
try { return readFileSync(dtsFile, 'utf8') } catch { return '' }
244+
try { return readFileSync(dtsFile, 'utf8') }
245+
catch { return '' }
245246
}
246247

247248
// Benchmark runner

packages/dtsx/profiler-deep.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ function profileProcessor(label: string, source: string, filename: string) {
233233

234234
const fixtureDir = join(import.meta.dir, 'test', 'fixtures', 'input')
235235
let reactLike = ''
236-
try { reactLike = readFileSync(join(fixtureDir, 'real-world', 'react-like.ts'), 'utf-8') } catch {}
236+
try { reactLike = readFileSync(join(fixtureDir, 'real-world', 'react-like.ts'), 'utf-8') }
237+
catch {}
237238

238239
function generateLarge(lines: number): string {
239240
const content: string[] = []

packages/dtsx/profiler.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,10 @@ function generateLarge(lines: number): string {
261261
// Load real fixtures
262262
let reactLike = ''
263263
let lodashLike = ''
264-
try { reactLike = readFileSync(join(fixtureDir, 'real-world', 'react-like.ts'), 'utf-8') } catch {}
265-
try { lodashLike = readFileSync(join(fixtureDir, 'real-world', 'lodash-like.ts'), 'utf-8') } catch {}
264+
try { reactLike = readFileSync(join(fixtureDir, 'real-world', 'react-like.ts'), 'utf-8') }
265+
catch {}
266+
try { lodashLike = readFileSync(join(fixtureDir, 'real-world', 'lodash-like.ts'), 'utf-8') }
267+
catch {}
266268

267269
const MEDIUM = generateLarge(500)
268270
const LARGE = generateLarge(1000)

packages/dtsx/src/worker.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,11 @@ export class WorkerPool {
211211
const filePath = filePaths ? filePaths[i] : file.filePath;
212212
if (sourceCode != null) {
213213
readPromises[i] = Promise.resolve(sourceCode);
214-
} else if (bun) {
214+
}
215+
else if (bun) {
215216
readPromises[i] = bun.file(filePath).text();
216-
} else {
217+
}
218+
else {
217219
readPromises[i] = Promise.resolve(fs.readFileSync(filePath, 'utf-8'));
218220
}
219221
}
@@ -242,18 +244,21 @@ export class WorkerPool {
242244
}
243245
if (bun) {
244246
writePromises[i] = bun.write(outPath, content);
245-
} else {
247+
}
248+
else {
246249
fs.writeFileSync(outPath, content);
247250
}
248-
} else if (results) {
251+
}
252+
else if (results) {
249253
results[i] = {
250254
filePath,
251255
success: true,
252256
content,
253257
declarations,
254258
};
255259
}
256-
} catch (error) {
260+
}
261+
catch (error) {
257262
const message = error && error.message ? error.message : String(error);
258263
if (writeOutput) {
259264
if (!errorResults) {
@@ -264,7 +269,8 @@ export class WorkerPool {
264269
success: false,
265270
error: message,
266271
});
267-
} else if (results) {
272+
}
273+
else if (results) {
268274
results[i] = {
269275
filePath,
270276
success: false,
@@ -323,7 +329,8 @@ export class WorkerPool {
323329
}
324330
325331
throw new Error('Unknown task type: ' + task.type);
326-
} catch (error) {
332+
}
333+
catch (error) {
327334
return {
328335
id: task.id,
329336
success: false,

packages/dtsx/test/fixtures/input/namespace.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export namespace Utils {
2020
try {
2121
new URL(value)
2222
return true
23-
} catch {
23+
}
24+
catch {
2425
return false
2526
}
2627
}

packages/esbuild-plugin/src/index.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ export function dtsx(options: DtsxEsbuildOptions = {}): Plugin {
183183

184184
if (entryPointsOnly) {
185185
filesToProcess = getEntryPoints(state.buildOptions!)
186-
} else {
186+
}
187+
else {
187188
// Get all TypeScript files from the build
188189
filesToProcess = getTypeScriptFiles(result, state.buildOptions!)
189190
}
@@ -217,13 +218,15 @@ export function dtsx(options: DtsxEsbuildOptions = {}): Plugin {
217218
await onSuccess?.(stats)
218219

219220
console.log(`[dtsx] Generated ${state.generatedFiles.size} declaration file(s)`)
220-
} catch (error) {
221+
}
222+
catch (error) {
221223
const err = error instanceof Error ? error : new Error(String(error))
222224
state.errors.push(err)
223225

224226
if (onError) {
225227
await onError(err)
226-
} else {
228+
}
229+
else {
227230
console.error('[dtsx] Error generating declarations:', err.message)
228231
}
229232
}
@@ -325,7 +328,8 @@ function filterFiles(
325328
for (const pattern of exclude) {
326329
if (typeof pattern === 'string') {
327330
if (file.includes(pattern)) return false
328-
} else if (pattern.test(file)) {
331+
}
332+
else if (pattern.test(file)) {
329333
return false
330334
}
331335
}
@@ -335,7 +339,8 @@ function filterFiles(
335339
for (const pattern of include) {
336340
if (typeof pattern === 'string') {
337341
if (file.includes(pattern)) return true
338-
} else if (pattern.test(file)) {
342+
}
343+
else if (pattern.test(file)) {
339344
return true
340345
}
341346
}

packages/tsup-plugin/src/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,15 @@ export function dtsxPlugin(options: DtsxTsupOptions = {}): any {
206206
await onSuccess?.(stats)
207207

208208
console.log(`[${PLUGIN_NAME}] Generated ${state.generatedFiles.size} declaration file(s)`)
209-
} catch (error) {
209+
}
210+
catch (error) {
210211
const err = error instanceof Error ? error : new Error(String(error))
211212
state.errors.push(err)
212213

213214
if (onError) {
214215
await onError(err)
215-
} else {
216+
}
217+
else {
216218
console.error(`[${PLUGIN_NAME}] Error generating declarations:`, err.message)
217219
}
218220
}
@@ -265,7 +267,8 @@ function filterFiles(
265267
for (const pattern of exclude) {
266268
if (typeof pattern === 'string') {
267269
if (file.includes(pattern)) return false
268-
} else if (pattern.test(file)) {
270+
}
271+
else if (pattern.test(file)) {
269272
return false
270273
}
271274
}
@@ -275,7 +278,8 @@ function filterFiles(
275278
for (const pattern of include) {
276279
if (typeof pattern === 'string') {
277280
if (file.includes(pattern)) return true
278-
} else if (pattern.test(file)) {
281+
}
282+
else if (pattern.test(file)) {
279283
return true
280284
}
281285
}

packages/vite-plugin/src/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,21 @@ export function dts(options: DtsPluginOptions = {}): Plugin {
181181
}
182182

183183
return stats
184-
} catch (error) {
184+
}
185+
catch (error) {
185186
const err = error instanceof Error ? error : new Error(String(error))
186187

187188
if (onError) {
188189
await onError(err)
189-
} else {
190+
}
191+
else {
190192
console.error('[vite-plugin-dtsx] Error generating declarations:', err.message)
191193
throw err
192194
}
193195

194196
return null
195-
} finally {
197+
}
198+
finally {
196199
state.isGenerating = false
197200
}
198201
}
@@ -235,7 +238,8 @@ export function dts(options: DtsPluginOptions = {}): Plugin {
235238
})
236239

237240
console.log('[vite-plugin-dtsx] Watching for file changes...')
238-
} catch (error) {
241+
}
242+
catch (error) {
239243
console.error('[vite-plugin-dtsx] Failed to start watcher:', error)
240244
}
241245
}

packages/webpack-plugin/src/index.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,15 @@ export class DtsxWebpackPlugin {
252252
await onSuccess?.(stats)
253253

254254
console.log(`[${PLUGIN_NAME}] Generated ${this.state.generatedFiles.size} declaration file(s)`)
255-
} catch (error) {
255+
}
256+
catch (error) {
256257
const err = error instanceof Error ? error : new Error(String(error))
257258
this.state.errors.push(err)
258259

259260
if (onError) {
260261
await onError(err)
261-
} else {
262+
}
263+
else {
262264
console.error(`[${PLUGIN_NAME}] Error generating declarations:`, err.message)
263265
}
264266
}
@@ -280,17 +282,20 @@ export class DtsxWebpackPlugin {
280282

281283
if (typeof entries === 'string') {
282284
files.push(resolve(entries))
283-
} else if (Array.isArray(entries)) {
285+
}
286+
else if (Array.isArray(entries)) {
284287
for (const entry of entries) {
285288
if (typeof entry === 'string') {
286289
files.push(resolve(entry))
287290
}
288291
}
289-
} else if (typeof entries === 'object') {
292+
}
293+
else if (typeof entries === 'object') {
290294
for (const [, entry] of Object.entries(entries)) {
291295
if (typeof entry === 'string') {
292296
files.push(resolve(entry))
293-
} else if (typeof entry === 'object' && entry.import) {
297+
}
298+
else if (typeof entry === 'object' && entry.import) {
294299
const imports = Array.isArray(entry.import) ? entry.import : [entry.import]
295300
for (const imp of imports) {
296301
if (typeof imp === 'string') {
@@ -300,7 +305,8 @@ export class DtsxWebpackPlugin {
300305
}
301306
}
302307
}
303-
} else {
308+
}
309+
else {
304310
// Get all TypeScript files from compilation
305311
for (const module of compilation.modules) {
306312
const resource = (module as any).resource as string | undefined
@@ -335,7 +341,8 @@ export class DtsxWebpackPlugin {
335341
for (const pattern of exclude) {
336342
if (typeof pattern === 'string') {
337343
if (file.includes(pattern)) return false
338-
} else if (pattern.test(file)) {
344+
}
345+
else if (pattern.test(file)) {
339346
return false
340347
}
341348
}
@@ -345,7 +352,8 @@ export class DtsxWebpackPlugin {
345352
for (const pattern of include) {
346353
if (typeof pattern === 'string') {
347354
if (file.includes(pattern)) return true
348-
} else if (pattern.test(file)) {
355+
}
356+
else if (pattern.test(file)) {
349357
return true
350358
}
351359
}

0 commit comments

Comments
 (0)