chore: per-commit lint
This commit is contained in:
@@ -26,5 +26,10 @@ To add a new language configuration, follow these steps:
|
||||
- Translate the value of each key into your target language.
|
||||
|
||||
4. **Finalize the Configuration**
|
||||
|
||||
- Review and ensure all translations are complete.
|
||||
- Your new language configuration is now ready for use!
|
||||
|
||||
5. **Check the Dir and File**
|
||||
|
||||
- `npm run check:locales`
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import langConfigMap from './lang-config-map';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const localesDir = path.resolve(__dirname, './');
|
||||
|
||||
const existingEntries = new Set(fs.readdirSync(localesDir));
|
||||
|
||||
const errors: string[] = [];
|
||||
|
||||
Object.values(langConfigMap).forEach(({ lang }) => {
|
||||
const expectedDir = lang;
|
||||
const expectedFile = `${lang}.ts`;
|
||||
|
||||
const dirExists = existingEntries.has(expectedDir);
|
||||
const fileExists = existingEntries.has(expectedFile);
|
||||
|
||||
if (dirExists || fileExists) {
|
||||
if (!dirExists) errors.push(`❌ Missing directory: '${expectedDir}/'`);
|
||||
if (!fileExists) errors.push(`❌ Missing file: '${expectedFile}'`);
|
||||
}
|
||||
});
|
||||
|
||||
if (errors.length) {
|
||||
console.error('❌ Errors found:');
|
||||
errors.forEach(console.error);
|
||||
process.exit(1);
|
||||
} else {
|
||||
console.log('✅ All locales are correctly named.');
|
||||
}
|
||||
Reference in New Issue
Block a user