netgescon-day0/tools/netgescon-qa.js

40 lines
1.1 KiB
JavaScript
Executable File

#!/usr/bin/env node
// Minimal NetGescon QA: scan Blade/JS/CSS for disallowed patterns
import fs from 'fs';
import path from 'path';
const root = process.cwd();
const targets = ['resources/views', 'resources/js', 'resources/css'];
const disallow = [
/\btable\b(?![\w-])/i,
/\bfont-monospace\b/i,
/\bform-label\b/i,
/\bborder-\b(?!netgescon-)/i
];
let issues = 0;
function walk(dir) {
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
const p = path.join(dir, e.name);
if (e.isDirectory()) { walk(p); continue; }
if (!/(\.blade\.php|\.js|\.css)$/i.test(p)) continue;
const txt = fs.readFileSync(p, 'utf8');
const lines = txt.split(/\r?\n/);
lines.forEach((line, i) => {
disallow.forEach(rx => {
if (rx.test(line)) {
issues++;
console.log(`[QA] ${p}:${i + 1} -> pattern ${rx}`);
}
});
});
}
}
targets.map(t => path.join(root, t)).filter(fs.existsSync).forEach(walk);
if (issues > 0) {
console.log(`\nNetGescon QA found ${issues} issues.`);
process.exitCode = 1;
} else {
console.log('NetGescon QA: no issues.');
}