ShtukbaseStandard
package file→ .shtukbase/packages/std-keep-a-changelog/checks/cl03_sections.ts

checks/cl03_sections.ts

16 lines, 889 B.

  1. // CL-R03: changes are grouped under the six types of the standard (Added, Changed, Deprecated, Removed, Fixed,
  2. // Security; setting `types`); a group is not empty.
  3. import { config, logs, PKG } from './kaclib.ts';
  4. import { finish, norm } from './lib/std.ts';
  5. const n = norm(PKG, 'CL-R03', 'enforce');
  6. const cfg = config();
  7. const out: string[] = [];
  8. if (n.active)
  9. for (const l of logs(cfg).logs)
  10. for (const r of l.releases)
  11. for (const s of r.sections) {
  12. if (!cfg.types.includes(s.name)) out.push(`${l.file}:${s.line}: the group "${s.name}" in ${r.unreleased ? 'Unreleased' : r.version} is not from the standard (${cfg.types.join(', ')})`);
  13. else if (!s.items && !cfg.allowEmptySections) out.push(`${l.file}:${s.line}: the empty group "${s.name}" in ${r.unreleased ? 'Unreleased' : r.version} — remove the heading or write the change`);
  14. }
  15. finish(n, out);