import { readFileSync, writeFileSync } from 'fs'; import { resolve, dirname } from 'path'; import { fileURLToPath } from 'url'; import eslint from './translations/eslint.mjs'; import tsEsLint from './translations/ts-eslint.mjs'; import stylelint from './translations/stylelint.mjs'; import pmd1 from './translations/pmd-1.mjs'; import pmd2 from './translations/pmd-2.mjs'; import pmdJsp from './translations/pmd-jsp.mjs'; import sqlFluff from './translations/sqlfluff.mjs'; const __dirname = dirname(fileURLToPath(import.meta.url)); const srcPath = resolve(__dirname, '..', 'src', 'rules', 'static-rules.json'); const data = JSON.parse(readFileSync(srcPath, 'utf-8')); const all = { ...eslint, ...tsEsLint, ...stylelint, ...pmd1, ...pmd2, ...pmdJsp, ...sqlFluff }; let added = 0; const missing = []; for (const rules of Object.values(data.rules)) { for (const rule of rules) { const t = all[rule.id]; if (t) { rule.descriptionZh = t.zh; rule.descriptionJa = t.ja; added++; } else { missing.push(rule.id); } } } writeFileSync(srcPath, JSON.stringify(data, null, 2) + '\n', 'utf-8'); console.log(`added: ${added}`); console.log(`missing: ${missing.length}`); if (missing.length > 0) { console.log(missing.join('\n')); }