mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-31 21:17: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);
|
||||
}
|
||||
|
||||
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) {
|
||||
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 (hasUnquotedHTags(data[key])) {
|
||||
errors.push(
|
||||
`Unquoted tags found in ${file.path} at key ${recKey}.${key}`
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ export const computeLocalize = (
|
||||
|
||||
if (!translatedMessage) {
|
||||
translatedMessage = new IntlMessageFormat(
|
||||
translatedValue.replace(/[^'](<.*>)[^']/g, "'$1'"),
|
||||
translatedValue,
|
||||
language,
|
||||
formats
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user