Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
KTibow committed Sep 23, 2023
1 parent 7e500ae commit b4fb114
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 27 deletions.
30 changes: 15 additions & 15 deletions src/common/translations/localize-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function parse(message: string) {
let part = "";
let level = 0;
let sub = 0;
const cache = {};
const cache: Record<string, ReturnType<typeof block>> = {};
const parts: ReturnType<typeof block>[] = [];
const refs = { 0: parts };

Expand Down Expand Up @@ -171,8 +171,8 @@ const formatPart = (
continue;
}
if (!type) {
const str = String(values[prop] ?? `{${prop}}`);
strs.push(str);
const repr = String(values[prop] ?? `{${prop}}`);
strs.push(repr);
continue;
}

Expand All @@ -184,8 +184,8 @@ const formatPart = (
break;
}
const options = splitKeyVals(opts, FORMATS.number);
const str = new Intl.NumberFormat(lng, options).format(value);
strs.push(str);
const repr = new Intl.NumberFormat(lng, options).format(value);
strs.push(repr);
break;
}
case "plural": {
Expand All @@ -201,8 +201,8 @@ const formatPart = (
(rule === opts && opts[0] !== "=") ||
opts === "other"
) {
const str = formatPart(parts, values, lng).replace("#", "" + value);
strs.push(str);
const repr = formatPart(parts, values, lng).replace("#", "" + value);
strs.push(repr);
pluralMatches[prop] = true;
} else if (ast[i + 1]?.type !== type) {
throw new TypeError(`type "${type}" needs an "other" match`);
Expand All @@ -216,8 +216,8 @@ const formatPart = (
}
const value = values[prop];
if (value === opts || opts === "other") {
const str = formatPart(parts, values, lng);
strs.push(str);
const repr = formatPart(parts, values, lng);
strs.push(repr);
selectMatches[prop] = true;
} else if (ast[i + 1]?.type !== type) {
throw new TypeError(`type "${type}" needs an "other" match`);
Expand All @@ -238,8 +238,8 @@ const formatPart = (
(opts[0] !== "=" && rule === opts) ||
opts === "other"
) {
const str = formatPart(parts, values, lng).replace("#", "" + value);
strs.push(str);
const repr = formatPart(parts, values, lng).replace("#", "" + value);
strs.push(repr);
selectOrdinalMatches[prop] = true;
} else if (ast[i + 1]?.type !== type) {
throw new TypeError(`type "${type}" needs an "other" match`);
Expand All @@ -249,15 +249,15 @@ const formatPart = (
case "date": {
const date = values[prop];
const options = splitKeyVals(opts, FORMATS.date);
const str = new Intl.DateTimeFormat(lng, options).format(date);
strs.push(str);
const repr = new Intl.DateTimeFormat(lng, options).format(date);
strs.push(repr);
break;
}
case "time": {
const date = values[prop];
const options = splitKeyVals(opts, FORMATS.time, FORMATS.time.medium);
const str = new Intl.DateTimeFormat(lng, options).format(date);
strs.push(str);
const repr = new Intl.DateTimeFormat(lng, options).format(date);
strs.push(repr);
break;
}
}
Expand Down
17 changes: 10 additions & 7 deletions src/components/ha-assist-pipeline-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export class HaAssistPipelinePicker extends LitElement {
return nothing;
}
const value = this.value ?? this._default;
const preferredPipeline = this._pipelines.find(
(p) => p.id === this._preferredPipeline
);
return html`
<ha-select
.label=${this.label ||
Expand All @@ -67,13 +70,13 @@ export class HaAssistPipelinePicker extends LitElement {
</ha-list-item>
`
: null}
<ha-list-item .value=${PREFERRED}>
${this.hass!.localize("ui.components.pipeline-picker.preferred", {
preferred: this._pipelines.find(
(pipeline) => pipeline.id === this._preferredPipeline
)?.name!,
})}
</ha-list-item>
${preferredPipeline
? html`<ha-list-item .value=${PREFERRED}>
${this.hass!.localize("ui.components.pipeline-picker.preferred", {
preferred: preferredPipeline.name,
})}
</ha-list-item>`
: nothing}
${this._pipelines.map(
(pipeline) =>
html`<ha-list-item .value=${pipeline.id}>
Expand Down
2 changes: 1 addition & 1 deletion src/panels/config/automation/ha-automation-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ export class HaAutomationEditor extends KeyboardShortcutMixin(LitElement) {
),
text: this.hass.localize(
"ui.panel.config.automation.picker.delete_confirm_text",
{ name: this._config?.alias! }
{ name: this._config!.alias! }
),
confirmText: this.hass!.localize("ui.common.delete"),
destructive: true,
Expand Down
2 changes: 1 addition & 1 deletion src/panels/config/scene/ha-scene-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ export class HaSceneEditor extends SubscribeMixin(
),
text: this.hass!.localize(
"ui.panel.config.scene.picker.delete_confirm_text",
{ name: this._config?.name! }
{ name: this._config!.name! }
),
confirmText: this.hass!.localize("ui.common.delete"),
dismissText: this.hass!.localize("ui.common.cancel"),
Expand Down
2 changes: 1 addition & 1 deletion src/panels/config/script/ha-script-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ export class HaScriptEditor extends KeyboardShortcutMixin(LitElement) {
),
text: this.hass.localize(
"ui.panel.config.script.editor.delete_confirm_text",
{ name: this._config?.alias! }
{ name: this._config!.alias! }
),
confirmText: this.hass!.localize("ui.common.delete"),
dismissText: this.hass!.localize("ui.common.cancel"),
Expand Down
4 changes: 2 additions & 2 deletions src/panels/my/ha-panel-my.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ class HaPanelMy extends LitElement {
href="https://my.home-assistant.io/faq.html#supported-pages"
>${this.hass.localize("ui.panel.my.faq_link")}</a>`,
}) || "This redirect is not supported."
: this._error == "no_component"
: this._error === "no_component"
? this.hass.localize("ui.panel.my.component_not_loaded", {
integration: `<a
target="_blank"
Expand All @@ -406,7 +406,7 @@ class HaPanelMy extends LitElement {
href=${documentationUrl(this.hass, "/installation")}
>${this.hass.localize("ui.panel.my.documentation")}</a>`,
})
: this._error == "not_app"
: this._error === "not_app"
? this.hass.localize("ui.panel.my.not_app", {
link: `<a
target="_blank"
Expand Down

0 comments on commit b4fb114

Please sign in to comment.