Ignore generic metadata files in counts
ci / test (push) Successful in 9s

This commit is contained in:
2026-07-16 20:36:06 +00:00
parent 0ccd4e47ae
commit ecc1578b92
4 changed files with 81 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
import path from "node:path";
const ignoredFileNames = new Set([
".editorconfig",
".gitattributes",
".gitignore",
".gitmodules",
".npmrc",
".nvmrc",
".prettierignore",
".prettierrc",
".prettierrc.json",
".yarnrc",
".yarnrc.yml",
"bun.lock",
"bun.lockb",
"cargo.lock",
"composer.json",
"composer.lock",
"deno.json",
"deno.lock",
"docker-compose.yaml",
"docker-compose.yml",
"eslint.config.js",
"eslint.config.mjs",
"global.json",
"go.mod",
"go.sum",
"gradle.properties",
"makefile",
"package-lock.json",
"package.json",
"pnpm-lock.yaml",
"poetry.lock",
"pom.xml",
"requirements.txt",
"rollup.config.js",
"rollup.config.mjs",
"settings.gradle",
"settings.gradle.kts",
"tsconfig.base.json",
"tsconfig.build.json",
"tsconfig.json",
"tsconfig.node.json",
"turbo.json",
"vite.config.js",
"vite.config.mjs",
"vite.config.ts",
"webpack.config.js",
"webpack.config.ts",
"yarn.lock"
]);
export function shouldIgnoreCountFile(filePath: string): boolean {
const fileName = path.basename(filePath).toLowerCase();
return ignoredFileNames.has(fileName);
}
+5
View File
@@ -5,6 +5,7 @@ import path from "node:path";
import type { RuntimeConfig } from "../config.js";
import { HttpError } from "../errors.js";
import { shouldIgnoreCountFile } from "../file-filter.js";
import { detectLanguage } from "../language.js";
import { Semaphore } from "../lib/semaphore.js";
import type { CountRequest, CountResult, LanguageStat } from "../types.js";
@@ -183,6 +184,10 @@ async function countDirectory(rootDir: string): Promise<{
continue;
}
if (shouldIgnoreCountFile(fullPath)) {
continue;
}
const lines = await countFileLines(fullPath);
const language = detectLanguage(fullPath);
const current = languages.get(language) ?? { language, files: 0, lines: 0 };