Skip to content

Commit 78b1cdc

Browse files
committed
Interface and type safety
1 parent 1a74020 commit 78b1cdc

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/services/fileWalker.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import {
66
DEFAULT_EXCLUDE_PATTERNS,
77
} from '../core/patterns.js';
88

9+
interface FindFilesOptions {
10+
include?: string[];
11+
exclude?: string[];
12+
files?: string[];
13+
}
14+
915
/**
1016
* Recursively finds all files in the given directory matching the include patterns,
1117
* while excluding files and directories that match the exclude patterns.
@@ -15,7 +21,7 @@ import {
1521
*/
1622
export async function findFiles(
1723
rootDir: string,
18-
opts: { include: string[]; exclude: string[]; files?: string[] },
24+
opts: FindFilesOptions,
1925
): Promise<string[]> {
2026
// If --files provided, keep existing replacement behavior
2127
if (opts.files && opts.files.length > 0) {
@@ -24,7 +30,7 @@ export async function findFiles(
2430

2531
const defaultPatterns = getDefaultPatterns();
2632
const rawInclude =
27-
opts.include.length > 0
33+
opts.include && opts.include.length > 0
2834
? [...defaultPatterns, ...opts.include]
2935
: defaultPatterns;
3036
const includePatterns = rawInclude.flatMap(expandBraceSets);
@@ -69,7 +75,7 @@ export async function findFiles(
6975
if (
7076
shouldExclude(entry.name, relativeToRoot, [
7177
...DEFAULT_EXCLUDE_PATTERNS,
72-
...opts.exclude,
78+
...(opts.exclude ?? []),
7379
])
7480
) {
7581
continue;

src/services/scanOutputToConsole.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ import { printHealthScore } from '../ui/scan/printHealthScore.js';
2424
import { printExpireWarnings } from '../ui/scan/printExpireWarnings.js';
2525
import { printInconsistentNamingWarning } from '../ui/scan/printInconsistentNamingWarning.js';
2626

27+
interface FixContext {
28+
fixApplied: boolean;
29+
removedDuplicates: string[];
30+
addedEnv: string[];
31+
gitignoreUpdated: boolean;
32+
}
33+
2734
/**
2835
* Outputs the scan results to the console.
2936
* @param scanResult - The result of the scan.
@@ -35,12 +42,7 @@ export function outputToConsole(
3542
scanResult: ScanResult,
3643
opts: ScanUsageOptions,
3744
comparedAgainst: string,
38-
fixContext?: {
39-
fixApplied: boolean;
40-
removedDuplicates: string[];
41-
addedEnv: string[];
42-
gitignoreUpdated: boolean;
43-
},
45+
fixContext?: FixContext,
4446
): { exitWithError: boolean } {
4547
let exitWithError = false;
4648

0 commit comments

Comments
 (0)