standardlint
Version:
Extensible standards linter and auditor.
37 lines (34 loc) • 1 kB
JavaScript
import {
filterFiles
} from "./chunk-ZPBPNVN2.mjs";
import {
getAllFiles
} from "./chunk-AB6N6RTP.mjs";
import {
logDefaultPathMessage
} from "./chunk-322CAOWI.mjs";
import {
calculatePass
} from "./chunk-I4KWICZI.mjs";
// src/checks/checkForPresenceTests.ts
function checkForPresenceTests(severity, basePath, customPath, ignorePaths) {
const path = customPath || "tests";
const name = "Tests";
const message = "Check for presence of tests";
if (!customPath) logDefaultPathMessage(name, path);
const files = getAllFiles(`${basePath}/${path}`, []);
const filteredFiles = ignorePaths && ignorePaths.length > 0 ? filterFiles(files, ignorePaths) : files;
const tests = filteredFiles.filter(
(file) => file.endsWith("test.ts") || file.endsWith("spec.ts") || file.endsWith("test.js") || file.endsWith("spec.js")
);
const result = tests.length > 0;
return {
name,
status: calculatePass(result, severity),
message,
path
};
}
export {
checkForPresenceTests
};