ShtukbaseStandard
файл пакета→ .shtukbase/packages/std-editorconfig/checks/ec01_present.ts

checks/ec01_present.ts

13 строк, 821 Б.

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

  1. // EC-R01: the project has an .editorconfig (in its root or above) and the search ends at one with `root = true`.
  2. import { Ec, PKG } from './eclib.ts';
  3. import { finish, norm, ROOT } from './lib/std.ts';
  4. const n = norm(PKG, 'EC-R01', 'enforce');
  5. const out: string[] = [];
  6. if (n.active) {
  7. const chain = new Ec().chain(ROOT);
  8. if (!chain.length) out.push('.editorconfig: there is no such file in the project root or above → create .editorconfig with root = true and a [*] section');
  9. else if (!chain[0].root) out.push(`${chain[chain.length - 1].path}: no root = true line — the editor will look for settings above the project → add root = true as the first line`);
  10. else if (!chain.some((e) => e.sections.length)) out.push(`${chain[0].path}: not a single [glob] section — no rules are set`);
  11. }
  12. finish(n, out);