Bump typescript, babel, webpack, eslint, polyfills

This commit is contained in:
Bram Kragten 2022-10-05 16:03:49 +02:00
parent aaeca323d4
commit 1525ca1a29
No known key found for this signature in database
GPG Key ID: FBE2DFDB363EF55B
26 changed files with 2025 additions and 2022 deletions

View File

@ -4,10 +4,7 @@ const env = require("./env.js");
const paths = require("./paths.js");
// Files from NPM Packages that should not be imported
module.exports.ignorePackages = ({ latestBuild }) => [
// Part of yaml.js and only used for !!js functions that we don't use
require.resolve("esprima"),
];
module.exports.ignorePackages = ({ latestBuild }) => [];
// Files from NPM packages that we should replace with empty file
module.exports.emptyPackages = ({ latestBuild, isHassioBuild }) =>

View File

@ -66,7 +66,7 @@ const incrementalUnits = ["clients", "queries", "ads"];
export const mockHistory = (mockHass: MockHomeAssistant) => {
mockHass.mockAPI(
new RegExp("history/period/.+"),
/history\/period\/.+/,
(hass, _method, path, _parameters) => {
const params = parseQuery<HistoryQueryParams>(path.split("?")[1]);
const entities = params.filter_entity_id.split(",");

View File

@ -16,9 +16,9 @@ const generateMeanStatistics = (
id: string,
start: Date,
end: Date,
period: "5minute" | "hour" | "day" | "month" = "hour",
initValue: number,
maxDiff: number
maxDiff: number,
period: "5minute" | "hour" | "day" | "month" = "hour"
): StatisticValue[] => {
const statistics: StatisticValue[] = [];
let currentDate = new Date(start);
@ -54,9 +54,9 @@ const generateSumStatistics = (
id: string,
start: Date,
end: Date,
period: "5minute" | "hour" | "day" | "month" = "hour",
initValue: number,
maxDiff: number
maxDiff: number,
period: "5minute" | "hour" | "day" | "month" = "hour"
): StatisticValue[] => {
const statistics: StatisticValue[] = [];
let currentDate = new Date(start);
@ -91,10 +91,10 @@ const generateCurvedStatistics = (
id: string,
start: Date,
end: Date,
_period: "5minute" | "hour" | "day" | "month" = "hour",
initValue: number,
maxDiff: number,
metered: boolean
metered: boolean,
_period: "5minute" | "hour" | "day" | "month" = "hour"
): StatisticValue[] => {
const statistics: StatisticValue[] = [];
let currentDate = new Date(start);
@ -147,9 +147,9 @@ const statisticsFunctions: Record<
id,
start,
end,
period,
0,
period === "day" ? 17 : 504
period === "day" ? 17 : 504,
period
);
}
const morningEnd = new Date(start.getTime() + 10 * 60 * 60 * 1000);
@ -157,9 +157,9 @@ const statisticsFunctions: Record<
id,
start,
morningEnd,
period,
0,
0.7
0.7,
period
);
const eveningStart = new Date(start.getTime() + 20 * 60 * 60 * 1000);
const morningFinalVal = morningLow.length
@ -169,17 +169,17 @@ const statisticsFunctions: Record<
id,
morningEnd,
eveningStart,
period,
morningFinalVal,
0
0,
period
);
const eveningLow = generateSumStatistics(
id,
eveningStart,
end,
period,
morningFinalVal,
0.7
0.7,
period
);
return [...morningLow, ...empty, ...eveningLow];
},
@ -194,9 +194,9 @@ const statisticsFunctions: Record<
id,
start,
end,
period,
0,
period === "day" ? 17 : 504
period === "day" ? 17 : 504,
period
);
}
const morningEnd = new Date(start.getTime() + 9 * 60 * 60 * 1000);
@ -205,41 +205,41 @@ const statisticsFunctions: Record<
id,
morningEnd,
eveningStart,
period,
0,
0.3
0.3,
period
);
const highTarifFinalVal = highTarif.length
? highTarif[highTarif.length - 1].sum!
: 0;
const morning = generateSumStatistics(id, start, morningEnd, period, 0, 0);
const morning = generateSumStatistics(id, start, morningEnd, 0, 0, period);
const evening = generateSumStatistics(
id,
eveningStart,
end,
period,
highTarifFinalVal,
0
0,
period
);
return [...morning, ...highTarif, ...evening];
},
"sensor.energy_production_tarif_1": (id, start, end, period = "hour") =>
generateSumStatistics(id, start, end, period, 0, 0),
generateSumStatistics(id, start, end, 0, 0, period),
"sensor.energy_production_tarif_1_compensation": (
id,
start,
end,
period = "hour"
) => generateSumStatistics(id, start, end, period, 0, 0),
) => generateSumStatistics(id, start, end, 0, 0, period),
"sensor.energy_production_tarif_2": (id, start, end, period = "hour") => {
if (period !== "hour") {
return generateSumStatistics(
id,
start,
end,
period,
0,
period === "day" ? 17 : 504
period === "day" ? 17 : 504,
period
);
}
const productionStart = new Date(start.getTime() + 9 * 60 * 60 * 1000);
@ -249,10 +249,10 @@ const statisticsFunctions: Record<
id,
productionStart,
productionEnd,
period,
0,
0.15,
true
true,
period
);
const productionFinalVal = production.length
? production[production.length - 1].sum!
@ -261,25 +261,25 @@ const statisticsFunctions: Record<
id,
start,
productionStart,
period,
0,
0
0,
period
);
const evening = generateSumStatistics(
id,
productionEnd,
dayEnd,
period,
productionFinalVal,
0
0,
period
);
const rest = generateSumStatistics(
id,
dayEnd,
end,
period,
productionFinalVal,
1
1,
period
);
return [...morning, ...production, ...evening, ...rest];
},
@ -289,9 +289,9 @@ const statisticsFunctions: Record<
id,
start,
end,
period,
0,
period === "day" ? 17 : 504
period === "day" ? 17 : 504,
period
);
}
const productionStart = new Date(start.getTime() + 7 * 60 * 60 * 1000);
@ -301,10 +301,10 @@ const statisticsFunctions: Record<
id,
productionStart,
productionEnd,
period,
0,
0.3,
true
true,
period
);
const productionFinalVal = production.length
? production[production.length - 1].sum!
@ -313,25 +313,25 @@ const statisticsFunctions: Record<
id,
start,
productionStart,
period,
0,
0
0,
period
);
const evening = generateSumStatistics(
id,
productionEnd,
dayEnd,
period,
productionFinalVal,
0
0,
period
);
const rest = generateSumStatistics(
id,
dayEnd,
end,
period,
productionFinalVal,
2
2,
period
);
return [...morning, ...production, ...evening, ...rest];
},
@ -365,17 +365,17 @@ export const mockRecorder = (mockHass: MockHomeAssistant) => {
id,
start,
end,
period,
state,
state * (state > 80 ? 0.01 : 0.05)
state * (state > 80 ? 0.01 : 0.05),
period
)
: generateMeanStatistics(
id,
start,
end,
period,
state,
state * (state > 80 ? 0.05 : 0.1)
state * (state > 80 ? 0.05 : 0.1),
period
);
}
});

View File

@ -37,12 +37,12 @@
"@codemirror/stream-parser": "^0.19.5",
"@codemirror/text": "^0.19.6",
"@codemirror/view": "^0.19.40",
"@formatjs/intl-datetimeformat": "^4.2.5",
"@formatjs/intl-getcanonicallocales": "^1.8.0",
"@formatjs/intl-locale": "^2.4.40",
"@formatjs/intl-numberformat": "^7.2.5",
"@formatjs/intl-pluralrules": "^4.1.5",
"@formatjs/intl-relativetimeformat": "^9.3.2",
"@formatjs/intl-datetimeformat": "^4.5.2",
"@formatjs/intl-getcanonicallocales": "^1.9.2",
"@formatjs/intl-locale": "^2.4.47",
"@formatjs/intl-numberformat": "^7.4.3",
"@formatjs/intl-pluralrules": "^4.3.3",
"@formatjs/intl-relativetimeformat": "^9.5.2",
"@formatjs/intl-utils": "^3.8.4",
"@fullcalendar/common": "5.9.0",
"@fullcalendar/core": "5.9.0",
@ -147,18 +147,18 @@
"xss": "^1.0.9"
},
"devDependencies": {
"@babel/core": "^7.15.5",
"@babel/plugin-external-helpers": "^7.14.5",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/plugin-proposal-decorators": "^7.15.4",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5",
"@babel/plugin-proposal-object-rest-spread": "^7.15.6",
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
"@babel/core": "^7.19.3",
"@babel/plugin-external-helpers": "^7.18.6",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-decorators": "^7.19.3",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
"@babel/plugin-proposal-object-rest-spread": "^7.18.9",
"@babel/plugin-proposal-optional-chaining": "^7.18.9",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-import-meta": "^7.10.4",
"@babel/plugin-syntax-top-level-await": "^7.14.5",
"@babel/preset-env": "^7.15.6",
"@babel/preset-typescript": "^7.15.0",
"@babel/preset-env": "^7.19.3",
"@babel/preset-typescript": "^7.18.6",
"@koa/cors": "^3.1.0",
"@open-wc/dev-server-hmr": "^0.0.2",
"@rollup/plugin-babel": "^5.2.1",
@ -177,23 +177,23 @@
"@types/qrcode": "^1.4.2",
"@types/sortablejs": "^1",
"@types/webspeechapi": "^0.0.29",
"@typescript-eslint/eslint-plugin": "^4.32.0",
"@typescript-eslint/parser": "^4.32.0",
"@typescript-eslint/eslint-plugin": "^5.39.0",
"@typescript-eslint/parser": "^5.39.0",
"@web/dev-server": "^0.0.24",
"@web/dev-server-rollup": "^0.2.11",
"babel-loader": "^8.2.2",
"babel-loader": "^8.2.5",
"chai": "^4.3.4",
"del": "^4.0.0",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-airbnb-typescript": "^14.0.0",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-webpack": "^0.13.1",
"eslint-plugin-disable": "^2.0.1",
"eslint-plugin-import": "^2.24.2",
"eslint": "^8.24.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-webpack": "^0.13.2",
"eslint-plugin-disable": "^2.0.3",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-lit": "^1.6.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-unused-imports": "^1.1.5",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-unused-imports": "^2.0.0",
"eslint-plugin-wc": "^1.3.2",
"fancy-log": "^1.3.3",
"fs-extra": "^7.0.1",
@ -229,14 +229,14 @@
"systemjs": "^6.3.2",
"terser-webpack-plugin": "^5.2.4",
"ts-lit-plugin": "^1.2.1",
"typescript": "^4.4.3",
"typescript": "^4.8.4",
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0",
"webpack": "^5.55.1",
"webpack-cli": "^4.8.0",
"webpack-dev-server": "^4.3.0",
"webpack-manifest-plugin": "^4.0.2",
"webpackbar": "^5.0.0-3",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.11.1",
"webpack-manifest-plugin": "^4.1.1",
"webpackbar": "^5.0.2",
"workbox-build": "^6.4.2"
},
"_comment": "Polymer 3.2 contained a bug, fixed in https://github.com/Polymer/polymer/pull/5569, add as patch",

View File

@ -9,7 +9,6 @@ if (__BUILD__ === "latest" && polyfillsLoaded) {
const formatRelTimeMem = memoizeOne(
(locale: FrontendLocaleData) =>
// @ts-expect-error
new Intl.RelativeTimeFormat(locale.language, { numeric: "auto" })
);
@ -25,7 +24,6 @@ export const relativeTime = (
}
return Intl.NumberFormat(locale.language, {
style: "unit",
// @ts-expect-error
unit: diff.unit,
unitDisplay: "long",
}).format(Math.abs(diff.value));

View File

@ -1,4 +1,4 @@
const isTemplateRegex = new RegExp("{%|{{");
const isTemplateRegex = /{%|{{/;
export const isTemplate = (value: string): boolean =>
isTemplateRegex.test(value);

View File

@ -202,7 +202,6 @@ export const loadPolyfillLocales = async (language: string) => {
Intl.NumberFormat.__addLocaleData(await result.json());
}
if (
// @ts-expect-error
Intl.RelativeTimeFormat &&
// @ts-ignore
typeof Intl.RelativeTimeFormat.__addLocaleData === "function"

View File

@ -462,7 +462,9 @@ export class HaDataTable extends LitElement {
const elapsed = curTime - startTime;
if (elapsed < 100) {
await new Promise((resolve) => setTimeout(resolve, 100 - elapsed));
await new Promise((resolve) => {
setTimeout(resolve, 100 - elapsed);
});
}
if (this.curRequest !== curRequest) {
return;

View File

@ -255,7 +255,6 @@ export class HaComboBox extends LitElement {
) {
this._overlayMutationObserver?.disconnect();
this._overlayMutationObserver = undefined;
// @ts-expect-error
overlay.inert = false;
} else if (mutation.type === "childList") {
mutation.removedNodes.forEach((node) => {

View File

@ -282,7 +282,9 @@ export class HaRelatedItems extends SubscribeMixin(LitElement) {
private async _navigateAwayClose() {
// allow new page to open before closing dialog
await new Promise((resolve) => setTimeout(resolve, 0));
await new Promise((resolve) => {
setTimeout(resolve, 0);
});
fireEvent(this, "close-dialog");
}

View File

@ -64,6 +64,8 @@ const DATA_CACHE: {
[cacheKey: string]: { [entityId: string]: Promise<LogbookEntry[]> };
} = {};
const ALL_ENTITIES = "*";
export const getLogbookDataForContext = async (
hass: HomeAssistant,
startDate: string,
@ -105,8 +107,6 @@ const getLogbookDataCache = async (
endDate: string,
entityId?: string[]
) => {
const ALL_ENTITIES = "*";
const entityIdKey = entityId ? entityId.toString() : ALL_ENTITIES;
const cacheKey = `${startDate}${endDate}`;
@ -118,6 +118,7 @@ const getLogbookDataCache = async (
return DATA_CACHE[cacheKey][entityIdKey];
}
// @ts-ignore
if (entityId && DATA_CACHE[cacheKey][ALL_ENTITIES]) {
const entities = await DATA_CACHE[cacheKey][ALL_ENTITIES];
return entities.filter(

View File

@ -146,7 +146,9 @@ export const checkForEntityUpdates = async (
});
// there is no reliable way to know if all the updates are done updating, so we just wait a bit for now...
await new Promise((r) => setTimeout(r, 10000));
await new Promise((r) => {
setTimeout(r, 10000);
});
unsubscribeEvents();

View File

@ -408,7 +408,9 @@ class MoreInfoClimate extends LitElement {
// We reset stateObj to re-sync the inputs with the state. It will be out
// of sync if our service call did not result in the entity to be turned
// on. Since the state is not changing, the resync is not called automatic.
await new Promise((resolve) => setTimeout(resolve, 2000));
await new Promise((resolve) => {
setTimeout(resolve, 2000);
});
// No need to resync if we received a new state.
if (this.stateObj !== curState) {

View File

@ -147,7 +147,9 @@ class MoreInfoHumidifier extends LitElement {
// We reset stateObj to re-sync the inputs with the state. It will be out
// of sync if our service call did not result in the entity to be turned
// on. Since the state is not changing, the resync is not called automatic.
await new Promise((resolve) => setTimeout(resolve, 2000));
await new Promise((resolve) => {
setTimeout(resolve, 2000);
});
// No need to resync if we received a new state.
if (this.stateObj !== curState) {

View File

@ -13,9 +13,8 @@ import {
StaleWhileRevalidate,
} from "workbox-strategies";
const noFallBackRegEx = new RegExp(
"/(api|static|auth|frontend_latest|frontend_es5|local)/.*"
);
const noFallBackRegEx =
/\/(api|static|auth|frontend_latest|frontend_es5|local)\/.*/;
// Clean up caches from older workboxes and old service workers.
// Will help with cleaning up Workbox v4 stuff
@ -33,22 +32,22 @@ function initRouting() {
// Cache static content (including translations) on first access.
registerRoute(
new RegExp("/(static|frontend_latest|frontend_es5)/.+"),
/\/(static|frontend_latest|frontend_es5)\/.+/,
new CacheFirst({ matchOptions: { ignoreSearch: true } })
);
// Get api from network.
registerRoute(new RegExp("/(api|auth)/.*"), new NetworkOnly());
registerRoute(/\/(api|auth)\/.*/, new NetworkOnly());
// Get manifest, service worker, onboarding from network.
registerRoute(
new RegExp("/(service_worker.js|manifest.json|onboarding.html)"),
/\/(service_worker.js|manifest.json|onboarding.html)/,
new NetworkOnly()
);
// For the root "/" we ignore search
registerRoute(
new RegExp(/\/(\?.*)?$/),
/\/(\?.*)?$/,
new StaleWhileRevalidate({ matchOptions: { ignoreSearch: true } })
);
@ -57,7 +56,7 @@ function initRouting() {
// First access might bring stale data from cache, but a single refresh will bring updated
// file.
registerRoute(
new RegExp(/\/.*/),
/\/.*/,
new StaleWhileRevalidate({
cacheName: "file-cache",
plugins: [

View File

@ -116,7 +116,7 @@ export const provideHass = (
}
mockAPI(
new RegExp("states/.+"),
/states\/.+/,
(
// @ts-ignore
method,

View File

@ -323,7 +323,9 @@ class HaOnboarding extends litLocalizeLiteMixin(HassElement) {
// Load config strings for integrations
(this as any)._loadFragmentTranslations(this.hass!.language, "config");
// Make sure hass is initialized + the config/user callbacks have called.
await new Promise((resolve) => setTimeout(resolve, 0));
await new Promise((resolve) => {
setTimeout(resolve, 0);
});
}
}

View File

@ -72,7 +72,9 @@ class DialogZHAReconfigureDevice extends LitElement {
this.hass,
this.hass.localize(`ui.dialogs.zha_reconfigure_device.heading`) +
": " +
(this._params?.device.user_given_name || this._params?.device.name)
(this._params?.device.user_given_name ||
this._params?.device.name ||
"")
)}
>
${!this._status

View File

@ -178,7 +178,7 @@ class HuiGaugeCard extends LitElement implements LovelaceCard {
// new format
let segments = this._config!.segments;
if (segments) {
segments = [...segments].sort((a, b) => a?.from - b?.from);
segments = [...segments].sort((a, b) => (a?.from || 0) - (b?.from || 0));
for (let i = 0; i < segments.length; i++) {
const segment = segments[i];

View File

@ -103,6 +103,7 @@ class HuiTimestampDisplay extends LitElement {
}
private _updateRelative(): void {
// @ts-ignore
if (this.ts && this.hass!.localize) {
this._relative =
this._format === "relative"

View File

@ -315,7 +315,9 @@ export class HuiDialogEditCard
private async _confirmCancel() {
// Make sure the open state of this dialog is handled before the open state of confirm dialog
await new Promise((resolve) => setTimeout(resolve, 0));
await new Promise((resolve) => {
setTimeout(resolve, 0);
});
const confirm = await showConfirmationDialog(this, {
title: this.hass!.localize(
"ui.panel.lovelace.editor.edit_card.unsaved_changes"

View File

@ -49,9 +49,9 @@ const getLovelaceStrategy = async <
if (
(await Promise.race([
customElements.whenDefined(tag),
new Promise((resolve) =>
setTimeout(() => resolve(true), MAX_WAIT_STRATEGY_LOAD)
),
new Promise((resolve) => {
setTimeout(() => resolve(true), MAX_WAIT_STRATEGY_LOAD);
}),
])) === true
) {
throw new Error(
@ -74,6 +74,7 @@ const generateStrategy = async <T extends keyof GenerateMethods>(
strategyType: string | undefined
): Promise<ReturnType<GenerateMethods[T]>> => {
if (!strategyType) {
// @ts-ignore
return renderError("No strategy type found");
}
@ -87,6 +88,7 @@ const generateStrategy = async <T extends keyof GenerateMethods>(
console.error(err);
}
// @ts-ignore
return renderError(err);
}
};

View File

@ -165,7 +165,9 @@ export class BarMediaPlayer extends SubscribeMixin(LitElement) {
<div class="controls-progress">
${until(
// Only show spinner after 500ms
new Promise((resolve) => setTimeout(resolve, 500)).then(
new Promise((resolve) => {
setTimeout(resolve, 500);
}).then(
() => html`<ha-circular-progress active></ha-circular-progress>`
)
)}

View File

@ -69,6 +69,7 @@ export const connectionMixin = <T extends Constructor<HassBaseEl>>(
enableShortcuts: true,
moreInfoEntityId: null,
hassUrl: (path = "") => new URL(path, auth.data.hassUrl).toString(),
// eslint-disable-next-line @typescript-eslint/default-param-last
callService: async (domain, service, serviceData = {}, target) => {
if (__DEV__) {
// eslint-disable-next-line no-console

View File

@ -347,7 +347,9 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) =>
// overwritten when we call _updateHass the second time!
// Allow hass to be updated
await new Promise((resolve) => setTimeout(resolve, 0));
await new Promise((resolve) => {
setTimeout(resolve, 0);
});
if (language !== (this.hass ?? this._pendingHass).language) {
// the language was changed, abort

3800
yarn.lock

File diff suppressed because it is too large Load Diff