Skip to content

Commit abe8899

Browse files
authored
Update ts-eslint (#23723)
* Update ts-eslint * Remove comments * Remove unused ts-ignore * Add undefined generic type instead of unknown * Remove unused undefined type * Fix type issues * Use undefined instead of void for subscribed return type
1 parent 922cd72 commit abe8899

File tree

178 files changed

+321
-475
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+321
-475
lines changed

Diff for: build-scripts/eslint.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default [
99
"import/extensions": "off",
1010
"import/no-dynamic-require": "off",
1111
"global-require": "off",
12-
"@typescript-eslint/no-var-requires": "off",
12+
"@typescript-eslint/no-require-imports": "off",
1313
"prefer-arrow-callback": "off",
1414
},
1515
},

Diff for: cast/src/launcher/layout/hc-cast.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class HcCast extends LitElement {
203203
}
204204
this.connection.close();
205205
location.reload();
206-
} catch (err: any) {
206+
} catch (_err: any) {
207207
alert("Unable to log out!");
208208
}
209209
}

Diff for: cast/src/launcher/layout/hc-connect.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export class HcConnect extends LitElement {
215215
let url: URL;
216216
try {
217217
url = new URL(value);
218-
} catch (err: any) {
218+
} catch (_err: any) {
219219
this.error = "Invalid URL";
220220
return;
221221
}
@@ -288,7 +288,7 @@ export class HcConnect extends LitElement {
288288
try {
289289
saveTokens(null);
290290
location.reload();
291-
} catch (err: any) {
291+
} catch (_err: any) {
292292
alert("Unable to log out!");
293293
}
294294
}

Diff for: demo/src/stubs/lovelace.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ customElements.whenDefined("hui-root").then(() => {
4343
const index = (ev as CustomEvent).detail.index;
4444
try {
4545
await setDemoConfig(this.hass, this.lovelace!, index);
46-
} catch (err: any) {
46+
} catch (_err: any) {
4747
setDemoConfig(this.hass, this.lovelace!, selectedDemoConfigIndex);
4848
alert("Failed to switch config :-(");
4949
}

Diff for: demo/src/stubs/recorder.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type { MockHomeAssistant } from "../../../src/fake_data/provide_hass";
1515
const generateMeanStatistics = (
1616
start: Date,
1717
end: Date,
18-
// eslint-disable-next-line @typescript-eslint/default-param-last
18+
// eslint-disable-next-line default-param-last
1919
period: "5minute" | "hour" | "day" | "month" = "hour",
2020
initValue: number,
2121
maxDiff: number
@@ -52,7 +52,7 @@ const generateMeanStatistics = (
5252
const generateSumStatistics = (
5353
start: Date,
5454
end: Date,
55-
// eslint-disable-next-line @typescript-eslint/default-param-last
55+
// eslint-disable-next-line default-param-last
5656
period: "5minute" | "hour" | "day" | "month" = "hour",
5757
initValue: number,
5858
maxDiff: number
@@ -89,7 +89,7 @@ const generateSumStatistics = (
8989
const generateCurvedStatistics = (
9090
start: Date,
9191
end: Date,
92-
// eslint-disable-next-line @typescript-eslint/default-param-last
92+
// eslint-disable-next-line default-param-last
9393
_period: "5minute" | "hour" | "day" | "month" = "hour",
9494
initValue: number,
9595
maxDiff: number,

Diff for: eslint.config.mjs

+17-9
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ const compat = new FlatCompat({
1818
export default [
1919
...compat.extends(
2020
"airbnb-base",
21-
"airbnb-typescript/base",
2221
"plugin:@typescript-eslint/recommended",
22+
"plugin:@typescript-eslint/strict",
2323
"plugin:wc/recommended",
2424
"plugin:lit/all",
2525
"plugin:lit-a11y/recommended",
@@ -50,8 +50,6 @@ export default [
5050
ecmaFeatures: {
5151
modules: true,
5252
},
53-
54-
project: "./tsconfig.json",
5553
},
5654
},
5755

@@ -148,15 +146,15 @@ export default [
148146
},
149147
],
150148

151-
"@typescript-eslint/no-unused-vars": "off",
152-
153-
"unused-imports/no-unused-vars": [
149+
"@typescript-eslint/no-unused-vars": [
154150
"error",
155151
{
156-
vars: "all",
157-
varsIgnorePattern: "^_",
158-
args: "after-used",
152+
args: "all",
159153
argsIgnorePattern: "^_",
154+
caughtErrors: "all",
155+
caughtErrorsIgnorePattern: "^_",
156+
destructuredArrayIgnorePattern: "^_",
157+
varsIgnorePattern: "^_",
160158
ignoreRestSiblings: true,
161159
},
162160
],
@@ -174,6 +172,16 @@ export default [
174172
"lit-a11y/role-has-required-aria-attrs": "error",
175173
"@typescript-eslint/consistent-type-imports": "error",
176174
"@typescript-eslint/no-import-type-side-effects": "error",
175+
camelcase: "off",
176+
"@typescript-eslint/no-dynamic-delete": "off",
177+
"@typescript-eslint/no-empty-object-type": [
178+
"error",
179+
{
180+
allowInterfaces: "always",
181+
allowObjectTypes: "always",
182+
},
183+
],
184+
"no-use-before-define": "off",
177185
},
178186
},
179187
];

Diff for: hassio/src/components/hassio-upload-backup.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type { LocalizeFunc } from "../../../src/common/translations/localize";
1515
declare global {
1616
interface HASSDomEvents {
1717
"backup-uploaded": { backup: HassioBackup };
18-
"backup-cleared": void;
18+
"backup-cleared": undefined;
1919
}
2020
}
2121

Diff for: hassio/src/dialogs/backup/dialog-hassio-backup-upload.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ export class DialogHassioBackupUpload
2828
await this.updateComplete;
2929
}
3030

31-
public closeDialog(): void {
31+
public closeDialog() {
3232
if (this._dialogParams && !this._dialogParams.onboarding) {
3333
if (this._dialogParams.reloadBackup) {
3434
this._dialogParams.reloadBackup();
3535
}
3636
}
3737
this._dialogParams = undefined;
3838
fireEvent(this, "dialog-closed", { dialog: this.localName });
39+
return true;
3940
}
4041

4142
protected render() {

Diff for: hassio/src/dialogs/backup/dialog-hassio-backup.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ class HassioBackupDialog
7777
fireEvent(this, "dialog-closed", { dialog: this.localName });
7878
}
7979

80-
public closeDialog(): void {
80+
public closeDialog() {
8181
this._dialog?.close();
82+
return true;
8283
}
8384

8485
private _localize(key: BackupOrRestoreKey) {

Diff for: hassio/src/dialogs/network/dialog-hassio-network.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,11 @@ export class DialogHassioNetwork
8282
await this.updateComplete;
8383
}
8484

85-
public closeDialog(): void {
85+
public closeDialog() {
8686
this._params = undefined;
8787
this._processing = false;
8888
fireEvent(this, "dialog-closed", { dialog: this.localName });
89+
return true;
8990
}
9091

9192
protected render() {

Diff for: hassio/src/hassio-my-redirect.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class HassioMyRedirect extends LitElement {
9292
let url: string;
9393
try {
9494
url = this._createRedirectUrl(redirect);
95-
} catch (err: any) {
95+
} catch (_err: any) {
9696
this._error = this.supervisor.localize("my.error");
9797
return;
9898
}

Diff for: hassio/src/ingress-view/hassio-ingress-view.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class HassioIngressView extends LitElement {
158158

159159
try {
160160
addon = await fetchHassioAddonInfo(this.hass, addonSlug);
161-
} catch (err: any) {
161+
} catch (_err: any) {
162162
await this.updateComplete;
163163
await showAlertDialog(this, {
164164
text:
@@ -219,7 +219,7 @@ class HassioIngressView extends LitElement {
219219
});
220220
this._fetchData(addonSlug);
221221
return;
222-
} catch (e) {
222+
} catch (_err) {
223223
await showAlertDialog(this, {
224224
text:
225225
this.supervisor.localize("ingress.error_starting_addon") ||
@@ -264,7 +264,7 @@ class HassioIngressView extends LitElement {
264264

265265
try {
266266
session = await createSessionPromise;
267-
} catch (err: any) {
267+
} catch (_err: any) {
268268
if (this._sessionKeepAlive) {
269269
clearInterval(this._sessionKeepAlive);
270270
}
@@ -285,7 +285,7 @@ class HassioIngressView extends LitElement {
285285
this._sessionKeepAlive = window.setInterval(async () => {
286286
try {
287287
await validateHassioSession(this.hass, session);
288-
} catch (err: any) {
288+
} catch (_err: any) {
289289
session = await createHassioSession(this.hass);
290290
}
291291
}, 60000);

Diff for: hassio/src/system/hassio-core-info.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class HassioCoreInfo extends LitElement {
3333

3434
@state() private _metrics?: HassioStats;
3535

36-
protected render(): TemplateResult | void {
36+
protected render(): TemplateResult | undefined {
3737
const metrics = [
3838
{
3939
description: this.supervisor.localize("system.core.cpu_usage"),

Diff for: hassio/src/system/hassio-host-info.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class HassioHostInfo extends LitElement {
4949

5050
@property({ attribute: false }) public supervisor!: Supervisor;
5151

52-
protected render(): TemplateResult | void {
52+
protected render(): TemplateResult | undefined {
5353
const primaryIpAddress = this.supervisor.host.features.includes("network")
5454
? this._primaryIpAddress(this.supervisor.network!)
5555
: "";

Diff for: hassio/src/system/hassio-supervisor-info.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class HassioSupervisorInfo extends LitElement {
4444

4545
@state() private _metrics?: HassioStats;
4646

47-
protected render(): TemplateResult | void {
47+
protected render(): TemplateResult | undefined {
4848
const metrics = [
4949
{
5050
description: this.supervisor.localize("system.supervisor.cpu_usage"),

Diff for: hassio/src/system/hassio-supervisor-log.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class HassioSupervisorLog extends LitElement {
6565
await this._loadData();
6666
}
6767

68-
protected render(): TemplateResult | void {
68+
protected render(): TemplateResult | undefined {
6969
return html`
7070
<ha-card outlined>
7171
${this._error

Diff for: hassio/src/system/hassio-system.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class HassioSystem extends LitElement {
2323

2424
@property({ attribute: false }) public route!: Route;
2525

26-
protected render(): TemplateResult | void {
26+
protected render(): TemplateResult | undefined {
2727
return html`
2828
<hass-tabs-subpage
2929
.hass=${this.hass}

Diff for: landing-page/src/components/landing-page-logs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class LandingPageLogs extends LitElement {
230230
this._startLogStream();
231231
return;
232232
}
233-
} catch (err) {
233+
} catch (_err) {
234234
// ignore and continue with observer logs
235235
}
236236
this._loadObserverLogs();

Diff for: landing-page/src/ha-landing-page.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class HaLandingPage extends LandingPageBaseElement {
126126
"selectedLanguage",
127127
JSON.stringify(language)
128128
);
129-
} catch (err: any) {
129+
} catch (_err: any) {
130130
// Ignore
131131
}
132132
}

Diff for: package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,15 @@
184184
"@types/tar": "6.1.13",
185185
"@types/ua-parser-js": "0.7.39",
186186
"@types/webspeechapi": "0.0.29",
187-
"@typescript-eslint/eslint-plugin": "7.18.0",
188-
"@typescript-eslint/parser": "7.18.0",
187+
"@typescript-eslint/eslint-plugin": "8.19.1",
188+
"@typescript-eslint/parser": "8.19.1",
189189
"@vitest/coverage-v8": "2.1.8",
190190
"babel-loader": "9.2.1",
191191
"babel-plugin-template-html-minifier": "4.1.0",
192192
"browserslist-useragent-regexp": "4.1.3",
193193
"del": "8.0.0",
194194
"eslint": "9.18.0",
195195
"eslint-config-airbnb-base": "15.0.0",
196-
"eslint-config-airbnb-typescript": "18.0.0",
197196
"eslint-config-prettier": "9.1.0",
198197
"eslint-import-resolver-webpack": "0.13.10",
199198
"eslint-plugin-import": "2.31.0",

Diff for: rspack.config.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable @typescript-eslint/no-var-requires */
1+
/* eslint-disable @typescript-eslint/no-require-imports */
22
// Needs to remain CommonJS until eslint-import-resolver-webpack supports ES modules
33
const rspack = require("./build-scripts/rspack.cjs");
44
const env = require("./build-scripts/env.cjs");

Diff for: src/auth/ha-authorize.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
232232

233233
try {
234234
url = new URL(this.redirectUri);
235-
} catch (err) {
235+
} catch (_err) {
236236
this._error = "Invalid redirect URI";
237237
return;
238238
}
@@ -328,7 +328,7 @@ export class HaAuthorize extends litLocalizeLiteMixin(LitElement) {
328328

329329
try {
330330
window.localStorage.setItem("selectedLanguage", JSON.stringify(language));
331-
} catch (err: any) {
331+
} catch (_err: any) {
332332
// Ignore
333333
}
334334
}

Diff for: src/common/array/ensure-array.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ type NonNullUndefined<T> = T extends undefined
1010
*/
1111
export function ensureArray(value: undefined): undefined;
1212
export function ensureArray(value: null): null;
13-
export function ensureArray<T>(value: T | T[]): NonNullUndefined<T>[];
14-
export function ensureArray<T>(value: T | readonly T[]): NonNullUndefined<T>[];
13+
export function ensureArray<T>(
14+
value: T | T[] | readonly T[]
15+
): NonNullUndefined<T>[];
1516
export function ensureArray(value) {
1617
if (value === undefined || value === null || Array.isArray(value)) {
1718
return value;

Diff for: src/common/auth/token_storage.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function loadTokens() {
6666
} else {
6767
tokenCache.tokens = null;
6868
}
69-
} catch (err: any) {
69+
} catch (_err: any) {
7070
tokenCache.tokens = null;
7171
}
7272
}

Diff for: src/common/decorators/storage.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class StorageClass {
8787
} else {
8888
this.storage.setItem(storageKey, JSON.stringify(value));
8989
}
90-
} catch (err: any) {
90+
} catch (_err: any) {
9191
// Safari in private mode doesn't allow localstorage
9292
} finally {
9393
if (this._listeners[storageKey]) {

Diff for: src/common/dom/apply_themes_on_element.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ const processTheme = (
186186
const prefixedRgbKey = `--${rgbKey}`;
187187
styles[prefixedRgbKey] = rgbValue;
188188
keys[prefixedRgbKey] = "";
189-
} catch (err: any) {
189+
} catch (_err: any) {
190190
continue;
191191
}
192192
}

Diff for: src/common/util/parse-aspect-ratio.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default function parseAspectRatio(input: string) {
2525
return arr.length === 1
2626
? { w: parseOrThrow(arr[0]), h: 1 }
2727
: { w: parseOrThrow(arr[0]), h: parseOrThrow(arr[1]) };
28-
} catch (err: any) {
28+
} catch (_err: any) {
2929
// Ignore the error
3030
}
3131
return null;

Diff for: src/common/util/select-unit.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const SECS_PER_HOUR = SECS_PER_MIN * 60;
1919
// Adapted from https://github.com/formatjs/formatjs/blob/186cef62f980ec66252ee232f438a42d0b51b9f9/packages/intl-utils/src/diff.ts
2020
export function selectUnit(
2121
from: Date | number,
22-
// eslint-disable-next-line @typescript-eslint/default-param-last
22+
// eslint-disable-next-line default-param-last
2323
to: Date | number = Date.now(),
2424
locale: FrontendLocaleData,
2525
thresholds: Partial<Thresholds> = {}

Diff for: src/components/buttons/ha-call-service-button.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class HaCallServiceButton extends LitElement {
6161
this.progress = false;
6262
progressElement.actionSuccess();
6363
eventData.success = true;
64-
} catch (e) {
64+
} catch (_err) {
6565
this.progress = false;
6666
progressElement.actionError();
6767
eventData.success = false;

0 commit comments

Comments
 (0)