mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-01 13:37:47 +00:00
Move check to build script
This commit is contained in:
parent
a12f007110
commit
04df530fdd
@ -16,6 +16,11 @@ function hasHtml(data) {
|
|||||||
return /<[a-z][\s\S]*>/i.test(data);
|
return /<[a-z][\s\S]*>/i.test(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasUnquotedHTags(data) {
|
||||||
|
// Guard against unquoted HTML tags https://github.com/formatjs/formatjs/issues/1878
|
||||||
|
return /[^'](<.*>)[^']/i.test(data);
|
||||||
|
}
|
||||||
|
|
||||||
function recursiveCheckHasHtml(file, data, errors, recKey) {
|
function recursiveCheckHasHtml(file, data, errors, recKey) {
|
||||||
Object.keys(data).forEach(function (key) {
|
Object.keys(data).forEach(function (key) {
|
||||||
if (typeof data[key] === "object") {
|
if (typeof data[key] === "object") {
|
||||||
@ -23,6 +28,10 @@ function recursiveCheckHasHtml(file, data, errors, recKey) {
|
|||||||
recursiveCheckHasHtml(file, data[key], errors, nextRecKey);
|
recursiveCheckHasHtml(file, data[key], errors, nextRecKey);
|
||||||
} else if (hasHtml(data[key])) {
|
} else if (hasHtml(data[key])) {
|
||||||
errors.push(`HTML found in ${file.path} at key ${recKey}.${key}`);
|
errors.push(`HTML found in ${file.path} at key ${recKey}.${key}`);
|
||||||
|
} else if (hasUnquotedHTags(data[key])) {
|
||||||
|
errors.push(
|
||||||
|
`Unquoted tags found in ${file.path} at key ${recKey}.${key}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ export const computeLocalize = (
|
|||||||
|
|
||||||
if (!translatedMessage) {
|
if (!translatedMessage) {
|
||||||
translatedMessage = new IntlMessageFormat(
|
translatedMessage = new IntlMessageFormat(
|
||||||
translatedValue.replace(/[^'](<.*>)[^']/g, "'$1'"),
|
translatedValue,
|
||||||
language,
|
language,
|
||||||
formats
|
formats
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user