Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 3x 3x 3x 3x 3x 3x 18x 18x 1716x 1716x 18x 18x 3x 3x 2x 2x 2x 2x 2x 2x 3x 3x 3x 3x 3x | import staticRules from '../static-rules.json';
import type { CustomRule } from '../../types';
import { getLanguage, type Language } from '../../i18n/messages';
interface KnownRulesLabels {
header: string;
linterLabel: (name: string, count: number) => string;
customLabel: (count: number) => string;
footer: string;
}
const LABELS: Record<Language, KnownRulesLabels> = {
'zh-CN': {
header: '## 已知规则清单(用于重复检测)',
linterLabel: (name, count) => `### ${name} (${count} 条)`,
customLabel: (count) => `### 已导入的自定义规则 (${count} 条)`,
footer: '判定时请精确匹配上述规则 ID,而非模糊匹配分类。',
},
en: {
header: '## Known Rules (for duplicate detection)',
linterLabel: (name, count) => `### ${name} (${count} rules)`,
customLabel: (count) => `### Imported custom rules (${count} rules)`,
footer: 'Match exactly by rule ID above, not by fuzzy category matching.',
},
ja: {
header: '## 既知ルール一覧(重複検出用)',
linterLabel: (name, count) => `### ${name}(${count} 件)`,
customLabel: (count) => `### インポート済みカスタムルール(${count} 件)`,
footer: '上記ルールIDで正確にマッチングしてください。曖昧なカテゴリマッチングは避けてください。',
},
};
export function buildKnownRulesSection(existingCustomRules?: CustomRule[]): string {
const lang = getLanguage();
const l = LABELS[lang] ?? LABELS['zh-CN'];
const lines: string[] = [l.header];
for (const [linter, rules] of Object.entries(staticRules.rules)) {
lines.push(l.linterLabel(linter, rules.length));
for (const rule of rules) {
lines.push(`- ${rule.id}: ${rule.description}`);
}
lines.push('');
}
if (existingCustomRules && existingCustomRules.length > 0) {
lines.push(l.customLabel(existingCustomRules.length));
for (const rule of existingCustomRules) {
lines.push(`- custom/${rule.id}: ${rule.description}`);
}
lines.push('');
}
lines.push(l.footer);
return lines.join('\n');
}
|