ShtukbaseStandard
файл пакета→ .shtukbase/packages/norms-core/checks/review.ts

checks/review.ts

24 строки, 1.1 КБ.

Файл как есть в пакете: код и комментарии в нём не переводятся.

  1. // NS-R05. A norm with `shelfLife.class: fast` has reviewBy; a live norm past its reviewBy is due for review.
  2. import { day, main, records, status, today } from './pagelib.ts';
  3. import { pystr } from '../../collections/checks/lib/pages.ts';
  4. const DEAD = ['rejected', 'retired', 'replaced'];
  5. export const RULE = { id: 'ns-r05', title: 'The review date of a norm has not passed' };
  6. export function check(): string[] {
  7. const out: string[] = [];
  8. for (const folder of ['norms/rules', 'norms/principles', 'norms/defaults']) {
  9. for (const [addr, head] of records(folder)) {
  10. if (DEAD.includes(status(head))) continue;
  11. const life = head.shelfLife;
  12. const fast = !!life && typeof life === 'object' && !Array.isArray(life) && (life.class ? pystr(life.class) : '').trim() === 'fast';
  13. const when = day(head.reviewBy);
  14. if (fast && when === null) out.push(`${addr}: a fast norm (shelfLife.class: fast) without reviewBy`);
  15. if (when !== null && when < today()) out.push(`${addr}: the review date ${when} has passed — review the norm and set a new date`);
  16. }
  17. }
  18. return out;
  19. }
  20. if (import.meta.main) main({ RULE, check });