39 lines
1.5 KiB
JavaScript
39 lines
1.5 KiB
JavaScript
// BRM-59: единое написание фамилии «Сайфарова» — старого написания нигде нет.
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const ROOT = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
const SKIP = new Set(['node_modules', '.git', 'dist', 'archive', 'test']);
|
|
const EXT = /\.(md|html|json|js|mjs|svg|css)$/;
|
|
|
|
function walk(dir, out = []) {
|
|
for (const name of fs.readdirSync(dir)) {
|
|
if (SKIP.has(name)) continue;
|
|
const p = path.join(dir, name);
|
|
const st = fs.statSync(p);
|
|
if (st.isDirectory()) walk(p, out);
|
|
else if (EXT.test(name)) out.push(p);
|
|
}
|
|
return out;
|
|
}
|
|
|
|
test('в документах, страницах и визуальной системе нет «Сафарова» и «Safarova»', () => {
|
|
const bad = [];
|
|
for (const f of walk(ROOT)) {
|
|
const text = fs.readFileSync(f, 'utf8');
|
|
if (/Сафаров|Safarov/i.test(text)) bad.push(path.relative(ROOT, f));
|
|
}
|
|
assert.deepStrictEqual(bad, []);
|
|
});
|
|
|
|
test('имя «Асель» не названо владельцем бренда', () => {
|
|
const bad = [];
|
|
for (const f of walk(path.join(ROOT, 'docs')).concat(walk(path.join(ROOT, 'public')))) {
|
|
if (/Асел[ьиюе]|Asel\b/.test(fs.readFileSync(f, 'utf8'))) bad.push(path.relative(ROOT, f));
|
|
}
|
|
assert.deepStrictEqual(bad, []);
|
|
});
|