diff --git a/README.md b/README.md index 1d8f413..e22a460 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ npx lostconf --include "**/tsconfig.json" ### Filtering Options -- `--skip-ignore-files` - Skip .gitignore, .prettierignore, .eslintignore, and .dockerignore files. Reduces noise by 70-80% since these files contain many intentionally missing patterns. +- `--skip-ignore-files` - Skip all ignore files (.gitignore, .prettierignore, .eslintignore, .dockerignore, .stylelintignore, etc.). Reduces noise by 70-80% since these files contain many intentionally missing patterns. - `--exclude-parsers ` - Skip specific parsers by name (e.g., `--exclude-parsers gitignore prettierignore`) - `--include ` - Only check config files matching these glob patterns (e.g., `--include "**/tsconfig.json"`) - `--exclude ` - Skip config files matching these glob patterns (e.g., `--exclude "**/test/**"`) diff --git a/src/cli.ts b/src/cli.ts index 5cfbd89..ad1099e 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -110,11 +110,13 @@ async function run(paths: string[], options: CliOptions): Promise { let parsers = getBuiltinParsers(); // Filter parsers based on options - const ignoreParserNames = ['gitignore', 'dockerignore', 'prettierignore', 'eslintignore']; - const excludeParserSet = new Set([ - ...(skipIgnoreFiles ? ignoreParserNames : []), - ...excludeParsers - ]); + // If skipIgnoreFiles is enabled, find all parsers whose names end with 'ignore' + // Note: This filters parser names (e.g., 'gitignore', 'stylelintignore'), not file paths. + // Parser names are defined in code, so a directory named 'superignore' won't be affected. + const ignoreParserNames = skipIgnoreFiles + ? parsers.filter((p) => p.name.endsWith('ignore')).map((p) => p.name) + : []; + const excludeParserSet = new Set([...ignoreParserNames, ...excludeParsers]); if (excludeParserSet.size > 0) { parsers = parsers.filter((p) => !excludeParserSet.has(p.name)); diff --git a/tests/integration/cli.test.ts b/tests/integration/cli.test.ts index 4d712b5..37a3d6a 100644 --- a/tests/integration/cli.test.ts +++ b/tests/integration/cli.test.ts @@ -178,4 +178,41 @@ describe('CLI Integration Tests', () => { expect(stderr).toContain('[lostconf]'); expect(stderr).toContain('Discovering config files'); }); + + it('should skip ignore files with --skip-ignore-files', async () => { + await fs.writeFile(path.join(testDir, '.gitignore'), 'stale-git'); + await fs.writeFile(path.join(testDir, '.prettierignore'), 'stale-prettier'); + await fs.writeFile(path.join(testDir, '.eslintignore'), 'stale-eslint'); + await fs.writeFile(path.join(testDir, '.stylelintignore'), 'stale-stylelint'); + await fs.writeFile(path.join(testDir, '.dockerignore'), 'stale-docker'); + await fs.writeFile(path.join(testDir, 'tsconfig.json'), '{"exclude": ["stale-ts"]}'); + + const { stdout } = await execAsync( + `node ${cliPath} ${testDir} --format json --skip-ignore-files --show-all` + ); + + const result = JSON.parse(stdout); + // Should only find the tsconfig.json stale pattern, not the ignore files + expect(result.findings).toHaveLength(1); + expect(result.findings[0].pattern).toBe('stale-ts'); + }); + + it('should skip stylelintignore specifically with --skip-ignore-files', async () => { + await fs.writeFile(path.join(testDir, '.stylelintignore'), 'stale-stylelint-pattern'); + + // Without --skip-ignore-files, should find the stale pattern + const { stdout: withoutSkip } = await execAsync( + `node ${cliPath} ${testDir} --format json --show-all` + ); + const resultWithout = JSON.parse(withoutSkip); + expect(resultWithout.findings.length).toBeGreaterThan(0); + expect(resultWithout.findings[0].pattern).toBe('stale-stylelint-pattern'); + + // With --skip-ignore-files, should skip .stylelintignore + const { stdout: withSkip } = await execAsync( + `node ${cliPath} ${testDir} --format json --skip-ignore-files --show-all` + ); + const resultWith = JSON.parse(withSkip); + expect(resultWith.findings).toHaveLength(0); + }); });