🚨(i18n) add linter to i18n package
We need to add a linter to the i18n package, we are mainly interested by the jest linting rules so we create a jest eslint config pluggable our other configs and to the i18n eslint config.
This commit is contained in:
10
src/frontend/packages/i18n/.eslintrc.js
Normal file
10
src/frontend/packages/i18n/.eslintrc.js
Normal file
@@ -0,0 +1,10 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: ['people/jest', 'plugin:import/recommended'],
|
||||
parserOptions: {
|
||||
sourceType: 'module',
|
||||
ecmaVersion: 'latest',
|
||||
tsconfigRootDir: __dirname,
|
||||
project: ['./tsconfig.json'],
|
||||
},
|
||||
};
|
||||
@@ -1,15 +1,15 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { hideBin } from "yargs/helpers";
|
||||
import yargs from "yargs/yargs";
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
import yargs from 'yargs/yargs';
|
||||
|
||||
// Get our args
|
||||
const argv = yargs(hideBin(process.argv)).argv;
|
||||
const { app, output } = argv;
|
||||
|
||||
const folderPath = "./locales/" + app;
|
||||
const namefile = "translations.json";
|
||||
const folderPath = './locales/' + app;
|
||||
const namefile = 'translations.json';
|
||||
const jsonI18n = {};
|
||||
|
||||
// Fetch the files in the locales folder
|
||||
@@ -31,7 +31,7 @@ fs.readdirSync(folderPath).map((language) => {
|
||||
throw new Error(`File ${pathTranslateFile} not found!`);
|
||||
}
|
||||
|
||||
const json = JSON.parse(fs.readFileSync(pathTranslateFile, "utf8"));
|
||||
const json = JSON.parse(fs.readFileSync(pathTranslateFile, 'utf8'));
|
||||
|
||||
// Transform the json file to the format expected by i18next
|
||||
const jsonKeyMessage = {};
|
||||
@@ -48,6 +48,6 @@ if (!Object.keys(jsonI18n).length) {
|
||||
}
|
||||
|
||||
// Write the file to the output
|
||||
fs.writeFileSync(output, JSON.stringify(jsonI18n), "utf8");
|
||||
fs.writeFileSync(output, JSON.stringify(jsonI18n), 'utf8');
|
||||
|
||||
console.log(`${app} translations deployed!`);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const config = {
|
||||
customValueTemplate: {
|
||||
message: "${key}",
|
||||
description: "${description}",
|
||||
message: '${key}',
|
||||
description: '${description}',
|
||||
},
|
||||
keepRemoved: true,
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export default {
|
||||
rootDir: "./",
|
||||
testEnvironment: "node",
|
||||
rootDir: './',
|
||||
testEnvironment: 'node',
|
||||
transform: {
|
||||
"^.+\\.(ts)$": "ts-jest",
|
||||
'^.+\\.(ts)$': 'ts-jest',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -7,11 +7,14 @@
|
||||
"extract-translation:desk": "yarn i18next ../../apps/desk/**/*.{ts,tsx} -c ./i18next-parser.config.mjs -o ./locales/desk/translations-crowdin.json",
|
||||
"format-deploy": "yarn format-deploy:desk",
|
||||
"format-deploy:desk": "node ./format-deploy.mjs --app=desk --output=../../apps/desk/src/i18n/translations.json",
|
||||
"lint": "eslint --ext .js,.ts,.mjs .",
|
||||
"test": "jest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/jest": "29.5.11",
|
||||
"@types/node": "20.11.6",
|
||||
"eslint-config-people": "*",
|
||||
"eslint-plugin-import": "2.29.1",
|
||||
"i18next-parser": "8.8.0",
|
||||
"jest": "29.7.0",
|
||||
"ts-jest": "29.1.2",
|
||||
|
||||
Reference in New Issue
Block a user