ShtukbaseStandard
包文件→ .shtukbase/packages/norms-core/checks/waivers.ts

checks/waivers.ts

20 行, 947 B.

文件按包中的原样显示:代码及其注释不做翻译。

  1. // NS-R03. A waiver is a record with rule, where, because, simplerRejected, allowedBy and expires; an allowed
  2. // waiver past its date is a finding.
  3. import { day, empty, main, records, status, today } from './pagelib.ts';
  4. const FIELDS = ['rule', 'where', 'because', 'simplerRejected', 'allowedBy', 'expires'];
  5. export const RULE = { id: 'ns-r03', title: 'A waiver is only a record with a reason and a deadline' };
  6. export function check(): string[] {
  7. const out: string[] = [];
  8. for (const [addr, head] of records('norms/waivers')) {
  9. const miss = FIELDS.filter((f) => empty(head[f]));
  10. if (miss.length) out.push(`${addr}: the waiver does not fill ${miss.join(', ')}`);
  11. const end = day(head.expires);
  12. if (status(head) === 'allowed' && end !== null && end < today()) out.push(`${addr}: the waiver expired on ${end} — close it or extend it with a new permission`);
  13. }
  14. return out;
  15. }
  16. if (import.meta.main) main({ RULE, check });