From b59a434c650d917f4cf86c66a94f09a86a2b1cf1 Mon Sep 17 00:00:00 2001 From: Ku6epXBOCTuK Date: Sat, 26 Sep 2026 21:23:50 +0500 Subject: [PATCH] chore: add new lint rule - check hardcoded text --- docs/README.md | 6 +- docs/plan-codebase-quality.md | 48 +++-- web/eslint-plugins/README.md | 29 ++- .../__tests__/no-hardcoded-user-text.test.ts | 167 ++++++++++++++++ web/eslint-plugins/i18n/index.js | 2 + web/eslint-plugins/i18n/lists.js | 19 ++ .../i18n/no-hardcoded-user-text.js | 180 ++++++++++++++++++ web/eslint.config.js | 22 ++- .../fields/schema/ColorPairControl.svelte | 5 +- 9 files changed, 454 insertions(+), 24 deletions(-) create mode 100644 web/eslint-plugins/__tests__/no-hardcoded-user-text.test.ts create mode 100644 web/eslint-plugins/i18n/lists.js create mode 100644 web/eslint-plugins/i18n/no-hardcoded-user-text.js diff --git a/docs/README.md b/docs/README.md index 90dd503..99c69e6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -57,9 +57,9 @@ - production registry содержит 122 инструмента; - `pnpm --dir web check` проходит без ошибок и предупреждений; -- `pnpm --dir web test` — 45 test files / 497 tests, включая тесты token audit и - PostCSS HCT-плагина; -- `pnpm --dir web test:rules` — 4 test files / 74 tests; +- `pnpm --dir web test` — 46 test files / 534 tests, включая тесты token audit, + PostCSS HCT-плагина и правил линтинга; +- `pnpm --dir web test:rules` — 5 test files / 104 tests; - `pnpm --dir web lint:all` — 0 errors, 0 i18n warnings и 0 unused design tokens от token audit; - coverage `src/lib` — statements 91.77%, branches 83.3%, functions 74.31%, diff --git a/docs/plan-codebase-quality.md b/docs/plan-codebase-quality.md index cd20a37..ca549ea 100644 --- a/docs/plan-codebase-quality.md +++ b/docs/plan-codebase-quality.md @@ -476,9 +476,38 @@ file-result-инструментам. ### Q8. Новые автоматические правила -**Оценка:** L. **Зависимости:** Q4, Q7. +**Оценка:** L. **Зависимости:** Q4, Q7. **Разбивка:** три атомарных шага, каждый +заканчивается либо работающим warn-правилом с нулевым baseline, либо измерением +с записью вывода. Механически важно: `lint-all` запускает ESLint с +`--max-warnings=0`, поэтому warn-правило обязано приземлиться без срабатываний +на текущем коде. -#### Дублирование HTML/Svelte-разметки +#### Q8.1. Пользовательские тексты вне i18n + +**Статус:** выполнен. Пилот `i18n/no-hardcoded-user-text` (warn) с нулевым +baseline; 2 реальных нарушения исправлены. + +- Измерение до правила: 42 строковых атрибута пользовательского текста, все — в + `/kit`; вне кита текстовые узлы дали 2 находки. Итог после исключений: 2 + настоящих бага и 2 бренда, которые план требовал исключить. +- `web/eslint-plugins/i18n/no-hardcoded-user-text.js`: узлы `SvelteText` плюс + строковые литералы пользовательских атрибутов; `', + filename: "Component.svelte", + options: OPTIONS, + }, + { + code: '\n

{t("ui.reset")}

', + filename: "Component.svelte", + options: OPTIONS, + }, + ], + invalid: [ + { + code: "

Visible text

", + filename: "Component.svelte", + errors: [{ messageId: "hardcodedText" }], + }, + { + code: 'From', + filename: "Component.svelte", + errors: [{ messageId: "hardcodedText" }], + }, + { + code: '