import { readFileSync, readdirSync, statSync } from "node:fs"; import { join } from "node:path"; import { expect, it } from "vitest"; function sources(dir: string): string[] { return readdirSync(dir).flatMap((name) => { const p = join(dir, name); if (statSync(p).isDirectory()) return sources(p); return /\.tsx$/.test(name) && !/\.test\.tsx$/.test(name) ? [p] : []; }); } it("no admin page renders a native type=\"date\" input", () => { const offenders = sources(join(__dirname)).filter((f) => /type=\{?"date"/.test(readFileSync(f, "utf8")), ); expect(offenders).toEqual([]); }); it('no admin page renders a native type="datetime-local" input', () => { const offenders = sources(join(__dirname)).filter((f) => /type=\{?"datetime-local"/.test(readFileSync(f, "utf8")), ); expect(offenders).toEqual([]); }); it('no helper passes a "date" or "datetime-local" type string to a native input', () => { const offenders = sources(join(__dirname)).filter((f) => /,\s*"(date|datetime-local)"\s*\)/.test(readFileSync(f, "utf8")), ); expect(offenders).toEqual([]); });