Skip to content

Commit bddb9c9

Browse files
committed
feat: Implement recursive handling of context files
1 parent 884fed0 commit bddb9c9

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

linters/typescript/src/context_linter.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as path from 'path';
2+
import * as fs from 'fs';
23
import * as yaml from 'js-yaml';
34
import MarkdownIt from 'markdown-it';
45
import { ContextdocsLinter } from './contextdocs_linter';
@@ -23,7 +24,7 @@ export class ContextLinter {
2324
printHeader(packageVersion, directoryPath);
2425
await this.handleContextignore(directoryPath);
2526
await this.handleContextdocs(directoryPath);
26-
await this.handleContextFiles(directoryPath);
27+
await this.handleContextFilesRecursively(directoryPath);
2728

2829
console.log('\nLinting completed.');
2930
}
@@ -42,15 +43,17 @@ export class ContextLinter {
4243
}
4344
}
4445

45-
private async handleContextFiles(directoryPath: string): Promise<void> {
46-
const files = await getContextFiles(directoryPath);
47-
if (files.length === 0) {
48-
console.log('No context files found in the specified directory.');
49-
return;
50-
}
46+
private async handleContextFilesRecursively(directoryPath: string): Promise<void> {
47+
const entries = await fs.promises.readdir(directoryPath, { withFileTypes: true });
5148

52-
for (const file of files) {
53-
await this.lintContextFile(path.join(directoryPath, file));
49+
for (const entry of entries) {
50+
const fullPath = path.join(directoryPath, entry.name);
51+
52+
if (entry.isDirectory()) {
53+
await this.handleContextFilesRecursively(fullPath);
54+
} else if (entry.isFile() && (entry.name.endsWith('.context.md') || entry.name.endsWith('.context.yaml') || entry.name.endsWith('.context.json'))) {
55+
await this.lintContextFile(fullPath);
56+
}
5457
}
5558
}
5659

0 commit comments

Comments
 (0)