UNPKG

@jsverse/transloco-validator

Version:
19 lines (18 loc) 819 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; const tslib_1 = require("tslib"); const fs_1 = tslib_1.__importDefault(require("fs")); const find_duplicated_property_keys_1 = tslib_1.__importDefault(require("find-duplicated-property-keys")); function default_1(translationFilePaths) { translationFilePaths.forEach((path) => { const translation = fs_1.default.readFileSync(path, 'utf-8'); // Verify that we can parse the JSON JSON.parse(translation); // Verify that we don't have any duplicate keys const result = (0, find_duplicated_property_keys_1.default)(translation); if (result.length) { throw new Error(`Found duplicate keys: ${result.map(({ key }) => key)} (${path})`); } }); }