You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

22 lines
1.1 KiB

import { readdirSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
function files(path) {
return readdirSync(path, { withFileTypes: true }).flatMap(entry => entry.isDirectory()
? files(join(path, entry.name)) : [join(path, entry.name)]);
}
let fields = 0, dates = 0;
const errors = [];
for (const path of files('src/app').filter(path => /\.(html|ts)$/.test(path) && !path.endsWith('.spec.ts'))) {
const source = readFileSync(path, 'utf8');
for (const match of source.matchAll(/<mat-form-field\b[^>]*>[\s\S]*?<\/mat-form-field\s*>/g)) {
fields++;
if (!/<mat-hint\b/.test(match[0])) errors.push(`${path}: missing hint slot`);
}
for (const match of source.matchAll(/<input\b(?=[^>]*\btype="(?:date|datetime-local)")[^>]*>/g)) {
dates++;
if (!source.slice(match.index + match[0].length).startsWith('<app-date-picker-button ')) errors.push(`${path}: missing calendar companion`);
}
}
if (errors.length) { console.error(errors.join('\n')); process.exitCode = 1; }
else console.log(`${fields} Material fields with hint slots; ${dates} ISO date inputs with calendar buttons.`);