Compare commits

...

4 Commits

Author SHA1 Message Date
Ludeeus
db8a5feff6 fix typo 2020-08-06 08:25:50 +00:00
Ludeeus
04df530fdd Move check to build script 2020-08-06 08:21:48 +00:00
Ludeeus
a12f007110 Fix lint issues 2020-08-05 22:10:54 +00:00
Ludeeus
74e5bdddd8 Fixes issues with translation strings containing < > 2020-08-05 21:25:04 +00:00

View File

@@ -16,6 +16,11 @@ function hasHtml(data) {
return /<[a-z][\s\S]*>/i.test(data);
}
function hasUnquotedTags(data) {
// Guard against unquoted HTML tags https://github.com/formatjs/formatjs/issues/1878
return /[^'](<.*>)[^']/i.test(data);
}
function recursiveCheckHasHtml(file, data, errors, recKey) {
Object.keys(data).forEach(function (key) {
if (typeof data[key] === "object") {
@@ -23,6 +28,10 @@ function recursiveCheckHasHtml(file, data, errors, recKey) {
recursiveCheckHasHtml(file, data[key], errors, nextRecKey);
} else if (hasHtml(data[key])) {
errors.push(`HTML found in ${file.path} at key ${recKey}.${key}`);
} else if (hasUnquotedTags(data[key])) {
errors.push(
`Unquoted tags found in ${file.path} at key ${recKey}.${key}`
);
}
});
}