Skip to content

Commit da47c78

Browse files
committed
style: apply consistent code formatting
- Use consistent string quotes (single quotes for literals) - Fix indentation and whitespace - Add proper line breaks for readability - Normalize comment formatting
1 parent 53d7cb9 commit da47c78

File tree

5 files changed

+42
-23
lines changed

5 files changed

+42
-23
lines changed

src/cli.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,15 @@ program
224224
.option('--min-depth <number>', 'Minimum heading level to include (1-6)', parseInt, 1)
225225
.option('--max-depth <number>', 'Maximum heading level to include (1-6)', parseInt, 6)
226226
.option('--include-line-numbers', 'Include line numbers in TOC entries')
227-
.option('--position <position>', 'TOC position: top|after-title|before-content|replace', 'after-title')
227+
.option(
228+
'--position <position>',
229+
'TOC position: top|after-title|before-content|replace',
230+
'after-title'
231+
)
228232
.option('--title <title>', 'TOC title', 'Table of Contents')
229233
.option('--heading-level <level>', 'TOC heading level (1-6)', parseInt, 2)
230234
.option('--marker <marker>', 'Custom marker for TOC replacement (requires --position replace)')
231-
.option('--skip-empty', 'Skip files that don\'t have any headings', true)
235+
.option('--skip-empty', "Skip files that don't have any headings", true)
232236
.option('-d, --dry-run', 'Show what would be changed without making changes')
233237
.option('-v, --verbose', 'Show detailed output')
234238
.option('--json', 'Output results in JSON format')
@@ -260,7 +264,10 @@ TOC Customization:
260264
program
261265
.command('validate')
262266
.description('Find broken links in markdown files')
263-
.argument('[files...]', 'Markdown files to validate (supports globs like *.md, **/*.md, defaults to current directory)')
267+
.argument(
268+
'[files...]',
269+
'Markdown files to validate (supports globs like *.md, **/*.md, defaults to current directory)'
270+
)
264271
.option(
265272
'--link-types <types>',
266273
'Comma-separated link types to check: internal,external,anchor,image,reference,claude-import'

src/commands/toc.test.ts

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ Content here.
7474
expect(result.filesModified).toBe(1);
7575

7676
const modifiedContent = await readFile(filePath, 'utf-8');
77-
expect(modifiedContent).toMatch(/^### Contents\n\n.*- \[Main Title\]\(#main-title\).*- \[Section 1\]\(#section-1\).*# Main Title/s);
77+
expect(modifiedContent).toMatch(
78+
/^### Contents\n\n.*- \[Main Title\]\(#main-title\).*- \[Section 1\]\(#section-1\).*# Main Title/s
79+
);
7880
});
7981

8082
it('should handle position "before-content"', async () => {
@@ -129,7 +131,9 @@ Content here.
129131

130132
const modifiedContent = await readFile(filePath, 'utf-8');
131133
expect(modifiedContent).not.toContain('Old TOC content');
132-
expect(modifiedContent).toContain('<!-- TOC -->\n## Table of Contents\n\n- [Main Title](#main-title)\n - [Section 1](#section-1)\n<!-- TOC -->');
134+
expect(modifiedContent).toContain(
135+
'<!-- TOC -->\n## Table of Contents\n\n- [Main Title](#main-title)\n - [Section 1](#section-1)\n<!-- TOC -->'
136+
);
133137
});
134138

135139
it('should handle position "replace" with auto-detection', async () => {
@@ -239,7 +243,7 @@ Content here.
239243
// The original content should still contain the deep subsection
240244
// but it should not appear in the TOC
241245
expect(modifiedContent).toContain('#### Deep subsection');
242-
246+
243247
// Check that the TOC doesn't contain the deep subsection as a link
244248
const tocSection = modifiedContent.substring(
245249
modifiedContent.indexOf('## Table of Contents'),
@@ -347,7 +351,9 @@ Content here.
347351
expect(result.filesModified).toBe(1);
348352

349353
const modifiedContent = await readFile(filePath, 'utf-8');
350-
expect(modifiedContent).toContain('#### Document Contents\n\n- [Main Title](#main-title)\n - [Section 1](#section-1)');
354+
expect(modifiedContent).toContain(
355+
'#### Document Contents\n\n- [Main Title](#main-title)\n - [Section 1](#section-1)'
356+
);
351357
});
352358
});
353359

@@ -394,17 +400,19 @@ Content here.
394400
const filePath = join(tempDir, 'test.md');
395401
await writeFile(filePath, '# Test', 'utf-8');
396402

397-
await expect(tocCommand([filePath], {
398-
position: 'invalid-position',
399-
minDepth: 1,
400-
maxDepth: 6,
401-
includeLineNumbers: false,
402-
title: 'Table of Contents',
403-
headingLevel: 2,
404-
skipEmpty: true,
405-
dryRun: false,
406-
verbose: false,
407-
})).rejects.toThrow('Invalid position: invalid-position');
403+
await expect(
404+
tocCommand([filePath], {
405+
position: 'invalid-position',
406+
minDepth: 1,
407+
maxDepth: 6,
408+
includeLineNumbers: false,
409+
title: 'Table of Contents',
410+
headingLevel: 2,
411+
skipEmpty: true,
412+
dryRun: false,
413+
verbose: false,
414+
})
415+
).rejects.toThrow('Invalid position: invalid-position');
408416
});
409417

410418
it('should output JSON when requested', async () => {
@@ -440,4 +448,4 @@ Content here.
440448
consoleSpy.mockRestore();
441449
});
442450
});
443-
});
451+
});

src/commands/validate.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ Anchor link: [bad anchor](#non-existent)
219219

220220
beforeEach(async () => {
221221
originalCwd = process.cwd();
222-
222+
223223
// Mock console.log to capture output
224224
logOutput = [];
225225
originalConsoleLog = console.log;
@@ -230,7 +230,7 @@ Anchor link: [bad anchor](#non-existent)
230230
// Create test markdown files in testDir
231231
await writeFile(join(testDir, 'test1.md'), '# Test 1\n\n[broken link](./missing.md)');
232232
await writeFile(join(testDir, 'test2.md'), '# Test 2\n\n[valid link](./test1.md)');
233-
233+
234234
// Create subdirectory with markdown files
235235
const subDir = join(testDir, 'subdirectory');
236236
await mkdir(subDir);

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ export type {
107107

108108
export type { IndexOptions, FileMetadata, IndexableFile } from './commands/index.js';
109109
export type { TocOperationOptions, TocCliOptions, TocResult } from './commands/toc.js';
110-
export type { TocOptions, TocResult as TocGeneratorResult, MarkdownHeading } from './utils/toc-generator.js';
110+
export type {
111+
TocOptions,
112+
TocResult as TocGeneratorResult,
113+
MarkdownHeading,
114+
} from './utils/toc-generator.js';
111115

112116
// Re-export specific strategy types that might be useful
113117
export type {

src/scripts/generate-schemas.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ describe('Schema Generation Script', () => {
260260

261261
files.forEach((file) => {
262262
const content = readFileSync(join(GENERATED_DIR, file), 'utf8');
263-
263+
264264
expect(content).not.toContain('Generated on:');
265265
});
266266
});

0 commit comments

Comments
 (0)