Skip to content

Commit a6156af

Browse files
Copilotfregante
andcommitted
Fix linting issues in add-examples-to-dts.ts script
Co-authored-by: fregante <1402241+fregante@users.noreply.github.com>
1 parent 4f5a347 commit a6156af

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

add-examples-to-dts.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env tsx
22
import {readFileSync, writeFileSync} from 'node:fs';
3-
// Import index.ts first to populate the test data
3+
// Import index.ts to populate the test data via side effect
4+
// eslint-disable-next-line import/no-unassigned-import, n/file-extension-in-import
45
import './index.ts';
6+
// eslint-disable-next-line n/file-extension-in-import
57
import {getTests} from './collector.ts';
68

79
// Read the generated .d.ts file
@@ -12,33 +14,32 @@ const dtsContent = readFileSync(dtsPath, 'utf8');
1214
const lines = dtsContent.split('\n');
1315
const outputLines: string[] = [];
1416

15-
for (let i = 0; i < lines.length; i++) {
16-
const line = lines[i];
17-
17+
for (const line of lines) {
1818
// Check if this is a function declaration
19-
const match = line.match(/^export declare const (\w+):/);
19+
const match = /^export declare const (\w+):/.exec(line);
2020
if (match) {
2121
const functionName = match[1];
22-
22+
2323
// Get the tests/examples for this function
2424
const examples = getTests(functionName);
25-
25+
2626
// Only add examples if they exist and aren't just references to other functions
2727
if (examples && examples.length > 0 && examples[0] !== 'combinedTestOnly') {
2828
// Filter to only include actual URLs (not references to other functions)
29-
const urlExamples = examples.filter(url => url.startsWith('http'));
30-
29+
const urlExamples = examples.filter((url: string) => url.startsWith('http'));
30+
3131
if (urlExamples.length > 0) {
3232
// Add JSDoc comment with examples before the declaration
3333
outputLines.push('/**');
3434
for (const url of urlExamples) {
3535
outputLines.push(` * @example ${url}`);
3636
}
37+
3738
outputLines.push(' */');
3839
}
3940
}
4041
}
41-
42+
4243
outputLines.push(line);
4344
}
4445

0 commit comments

Comments
 (0)