diff --git a/.gitignore b/.gitignore index 2548df4..0f21f19 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ /node_modules/ /yarn.lock -/.rpt2_cache/ +/.tsbuildinfo /dist/ diff --git a/.prettierrc.js b/.prettierrc.js index 93f1e1c..4121004 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -4,4 +4,4 @@ module.exports = { singleQuote: true, printWidth: 120, tabWidth: 2, -}; \ No newline at end of file +}; diff --git a/eslint.config.mjs b/eslint.config.mjs index 30caed5..6465cd3 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -6,13 +6,21 @@ import globals from 'globals'; export default ts.config( js.configs.recommended, - ts.configs.recommended, + ts.configs.strictTypeChecked, + ts.configs.stylisticTypeChecked, { rules: { '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/no-unused-vars': ['warn', {'argsIgnorePattern': '^_'}], + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/no-unsafe-call': 'off', }, languageOptions: { sourceType: 'module', // Allows for the use of imports + globals: { + ...globals.browser, + }, parserOptions: { tsconfigRootDir: import.meta.dirname, projectService: true, // TypeScript type checking service diff --git a/package-lock.json b/package-lock.json index cb57ddc..21d85bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,11 +13,12 @@ "lit": "^2.8.0" }, "devDependencies": { + "@rollup/plugin-eslint": "^9.0.5", "@rollup/plugin-node-resolve": "^15.3.0", - "eslint": "^9.20.1", + "@rollup/plugin-typescript": "^12.1.2", "rollup": "^4.24.3", "rollup-plugin-serve": "^3.0.0", - "rollup-plugin-typescript2": "^0.36.0", + "tslib": "^2.8.1", "typescript": "~5.7.3", "typescript-eslint": "^8.24.0" } @@ -327,6 +328,28 @@ "node": ">= 8" } }, + "node_modules/@rollup/plugin-eslint": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/@rollup/plugin-eslint/-/plugin-eslint-9.0.5.tgz", + "integrity": "sha512-C4nh0sSeJuxVW5u5tDX+dCMjKcNfHm4hS+zeUVh1si7gttnhgGbrmPkUxIX7iZgYABwdEh/ewyMbZB+WXjSJdA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "eslint": "^8.24.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, "node_modules/@rollup/plugin-node-resolve": { "version": "15.3.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.3.1.tgz", @@ -352,6 +375,33 @@ } } }, + "node_modules/@rollup/plugin-typescript": { + "version": "12.1.2", + "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-12.1.2.tgz", + "integrity": "sha512-cdtSp154H5sv637uMr1a8OTWB0L1SWDSm1rDGiyfcGcvQ6cuTs4MDk2BVEBGysUWago4OJN4EQZqOTl/QY3Jgg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.1.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.14.0||^3.0.0||^4.0.0", + "tslib": "*", + "typescript": ">=3.7.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + }, + "tslib": { + "optional": true + } + } + }, "node_modules/@rollup/pluginutils": { "version": "5.1.4", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.4.tgz", @@ -790,13 +840,6 @@ "dev": true, "license": "MIT" }, - "node_modules/commondir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", - "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", - "dev": true, - "license": "MIT" - }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -1193,24 +1236,6 @@ "node": ">=8" } }, - "node_modules/find-cache-dir": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", - "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", - "dev": true, - "license": "MIT", - "dependencies": { - "commondir": "^1.0.1", - "make-dir": "^3.0.2", - "pkg-dir": "^4.1.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/avajs/find-cache-dir?sponsor=1" - } - }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -1249,21 +1274,6 @@ "dev": true, "license": "ISC" }, - "node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -1300,13 +1310,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/graceful-fs": { - "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", - "dev": true, - "license": "ISC" - }, "node_modules/graphemer": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", @@ -1489,19 +1492,6 @@ "dev": true, "license": "MIT" }, - "node_modules/jsonfile": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", - "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -1580,32 +1570,6 @@ "dev": true, "license": "MIT" }, - "node_modules/make-dir": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", - "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", - "dev": true, - "license": "MIT", - "dependencies": { - "semver": "^6.0.0" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/make-dir/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", - "dev": true, - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - } - }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -1746,16 +1710,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -1809,75 +1763,6 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/pkg-dir": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", - "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "find-up": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-dir/node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "license": "MIT", - "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-dir/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pkg-dir/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/pkg-dir/node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-limit": "^2.2.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -2011,51 +1896,6 @@ "opener": "1" } }, - "node_modules/rollup-plugin-typescript2": { - "version": "0.36.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.36.0.tgz", - "integrity": "sha512-NB2CSQDxSe9+Oe2ahZbf+B4bh7pHwjV5L+RSYpCu7Q5ROuN94F9b6ioWwKfz3ueL3KTtmX4o2MUH2cgHDIEUsw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@rollup/pluginutils": "^4.1.2", - "find-cache-dir": "^3.3.2", - "fs-extra": "^10.0.0", - "semver": "^7.5.4", - "tslib": "^2.6.2" - }, - "peerDependencies": { - "rollup": ">=1.26.3", - "typescript": ">=2.4.0" - } - }, - "node_modules/rollup-plugin-typescript2/node_modules/@rollup/pluginutils": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", - "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "estree-walker": "^2.0.1", - "picomatch": "^2.2.2" - }, - "engines": { - "node": ">= 8.0.0" - } - }, - "node_modules/rollup-plugin-typescript2/node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -2243,16 +2083,6 @@ "typescript": ">=4.8.4 <5.8.0" } }, - "node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", diff --git a/package.json b/package.json index 808df24..82760c3 100644 --- a/package.json +++ b/package.json @@ -21,16 +21,21 @@ "devDependencies": { "rollup": "^4.24.3", "@rollup/plugin-node-resolve": "^15.3.0", - "rollup-plugin-typescript2": "^0.36.0", + "@rollup/plugin-eslint": "^9.0.5", + "typescript-eslint": "^8.24.0", + "@rollup/plugin-typescript": "^12.1.2", "typescript": "~5.7.3", - "rollup-plugin-serve": "^3.0.0", - "eslint": "^9.20.1", - "typescript-eslint": "^8.24.0" + "tslib": "^2.8.1", + "rollup-plugin-serve": "^3.0.0" + }, + "overrides": { + "@rollup/plugin-eslint": { + "eslint": "^9.20.1" + } }, "scripts": { - "start": "rollup -c rollup.config.dev.mjs --watch", - "build": "npm run lint && npm run rollup", - "lint": "eslint src/*.ts", - "rollup": "rollup -c" + "devl": "rollup --config --watch", + "build": "rollup --config", + "lint": "eslint" } } diff --git a/rollup.config.dev.mjs b/rollup.config.dev.mjs deleted file mode 100644 index 8ea544c..0000000 --- a/rollup.config.dev.mjs +++ /dev/null @@ -1,31 +0,0 @@ -import resolve from '@rollup/plugin-node-resolve'; -import typescript from 'rollup-plugin-typescript2'; -import serve from 'rollup-plugin-serve'; - -export default { - input: ['src/config-template-card.ts'], - output: { - dir: './dist', - format: 'es', - }, - plugins: [ - resolve(), - typescript(), - serve({ - contentBase: './dist', - host: '0.0.0.0', - port: 5000, - allowCrossOrigin: true, - headers: { - 'Access-Control-Allow-Origin': '*', - }, - }), - ], treeshake: false, - moduleContext: { - // intl-utils is deprecated but still used by custom-card-helpers. - // Until it is removed from custom-card-helpers, silence a Rollup warning related to it: - // https://rollupjs.org/troubleshooting/#error-this-is-undefined - 'node_modules/@formatjs/intl-utils/lib/src/diff.js': 'window', - 'node_modules/@formatjs/intl-utils/lib/src/resolve-locale.js': 'window', - }, -}; diff --git a/rollup.config.mjs b/rollup.config.mjs index 7a1d4de..f9b77b2 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -1,15 +1,33 @@ -import resolve from '@rollup/plugin-node-resolve'; -import typescript from 'rollup-plugin-typescript2'; +import { nodeResolve } from '@rollup/plugin-node-resolve'; +import eslint from '@rollup/plugin-eslint'; +import typescript from '@rollup/plugin-typescript'; + +const watch = process.env.ROLLUP_WATCH; export default { input: ['src/config-template-card.ts'], output: { dir: './dist', format: 'es', + sourcemap: true, }, plugins: [ - resolve(), - typescript(), + nodeResolve(), + eslint({ + throwOnError: false, + }), + typescript({ + noEmitOnError: true, + }), + watch && serve({ + contentBase: './dist', + host: '0.0.0.0', + port: 5000, + allowCrossOrigin: true, + headers: { + 'Access-Control-Allow-Origin': '*', + }, + }), ], treeshake: false, moduleContext: { // intl-utils is deprecated but still used by custom-card-helpers. diff --git a/src/config-template-card.ts b/src/config-template-card.ts index 22fa959..916e2c3 100644 --- a/src/config-template-card.ts +++ b/src/config-template-card.ts @@ -6,7 +6,6 @@ import { ConfigTemplateConfig, ConfigTemplateVars } from './types'; import { CARD_VERSION } from './const'; import { isString } from './util'; -/* eslint no-console: 0 */ console.info( `%c CONFIG-TEMPLATE-CARD \n%c Version ${CARD_VERSION} `, 'color: orange; font-weight: bold; background: black', @@ -21,7 +20,7 @@ export class ConfigTemplateCard extends LitElement { @state() private _helpers?: any; private _initialized = false; - public setConfig(config: ConfigTemplateConfig): void { + public setConfig(config?: ConfigTemplateConfig): void { if (!config) { throw new Error('Invalid configuration'); } @@ -50,10 +49,10 @@ export class ConfigTemplateCard extends LitElement { this._config = config; - this.loadCardHelpers(); + void this.loadCardHelpers(); } - private getLovelacePanel() { + private getLovelacePanel(): any { const ha = document.querySelector('home-assistant'); if (ha?.shadowRoot) { const haMain = ha.shadowRoot.querySelector('home-assistant-main'); @@ -64,8 +63,8 @@ export class ConfigTemplateCard extends LitElement { return null; } - private getLovelaceConfig() { - const panel = this.getLovelacePanel() as any; + private getLovelaceConfig(): any { + const panel = this.getLovelacePanel(); if (panel?.lovelace?.config?.config_template_card_vars) { return panel.lovelace.config.config_template_card_vars; @@ -102,17 +101,20 @@ export class ConfigTemplateCard extends LitElement { public getCardSize(): number | Promise { if (this.shadowRoot) { - const element = this.shadowRoot.querySelector('#card > *') as LovelaceCard; + // eslint detects this assertion as unnecessary, but typescript requires it. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + const element = this.shadowRoot.querySelector('#card > *') as LovelaceCard | null; if (element) { - console.log('computeCardSize is ' + computeCardSize(element)); + Promise.resolve(computeCardSize(element)).then((size) => { + console.log('computeCardSize is ' + size.toString()); + }, () => undefined); return computeCardSize(element); } } - return 1; } - protected render(): TemplateResult | void { + protected render(): TemplateResult { if ( !this._config || !this.hass || @@ -135,9 +137,7 @@ export class ConfigTemplateCard extends LitElement { if (!this._curVars) { this._evaluateVars(); } configSection = this._evaluateStructure(configSection); - if (style) { - style = this._evaluateStructure(style); - } + style = this._evaluateStructure(style); // In case the next call to render() is not preceded by a call to shouldUpdate(), force the next // render() call to re-evaluate variables. @@ -151,11 +151,9 @@ export class ConfigTemplateCard extends LitElement { element.hass = this.hass; if (this._config.element) { - if (style) { - Object.keys(style).forEach((prop) => { - this.style.setProperty(prop, style[prop]); - }); - } + Object.keys(style).forEach((prop) => { + this.style.setProperty(prop, style[prop]); + }); if (configSection?.style) { Object.keys(configSection.style).forEach((prop) => { if (configSection.style) { // TypeScript requires a redundant check here, not sure why @@ -186,6 +184,7 @@ export class ConfigTemplateCard extends LitElement { struct[i] = this._evaluateStructure(value); } } else if (typeof struct === 'object') { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument Object.entries(struct).forEach(entry => { const key = entry[0]; const value = entry[1]; @@ -204,8 +203,8 @@ export class ConfigTemplateCard extends LitElement { return this._evalWithVars(template.substring(2, template.length - 1)); } - template.match(/\${[^}]+}/)?.forEach(m => { - const repl = this._evalWithVars(m.substring(2, m.length - 1)); + /\${[^}]+}/.exec(template)?.forEach(m => { + const repl = this._evalWithVars(m.substring(2, m.length - 1)).toString() as string; template = template.replace(m, repl); }); return template; @@ -227,6 +226,7 @@ export class ConfigTemplateCard extends LitElement { if (this._config?.variables) { if (Array.isArray(this._config.variables)) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument arrayVars.push(...this._config.variables); } else { Object.assign(namedVars, this._config.variables); @@ -236,14 +236,14 @@ export class ConfigTemplateCard extends LitElement { const localVars = this.getLovelaceConfig(); if (localVars) { if (Array.isArray(localVars)) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument arrayVars.push(...localVars); } else { Object.assign(namedVars, localVars); } } - for (const idx in arrayVars) { - let v = arrayVars[idx]; + for (let v of arrayVars) { if (isString(v)) { v = this._evalWithVars(v); } else { v = structuredClone(v); } vars.push(v); diff --git a/src/types.ts b/src/types.ts index a8c4482..a2d9d88 100644 --- a/src/types.ts +++ b/src/types.ts @@ -8,7 +8,7 @@ interface StyleMixin { export interface ConfigTemplateConfig { type: string; - entities: string[]; + entities?: string[]; variables?: Record | any[]; card?: LovelaceCardConfig & StyleMixin; row?: EntitiesCardEntityConfig & StyleMixin; diff --git a/tsconfig.json b/tsconfig.json index 20ef36b..159a683 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,18 +2,24 @@ "compilerOptions": { "target": "es2017", "module": "esnext", - "moduleResolution": "node", + "moduleResolution": "bundler", "lib": [ "es2017", "dom", "dom.iterable" ], - "noEmit": true, + + "noEmit": false, "sourceMap": true, + "declaration": false, + "declarationMap": false, + "tsBuildInfoFile": ".tsbuildinfo", + + "noCheck": false, + "strict": true, "noUnusedParameters": true, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, - "strict": true, "noImplicitAny": false, "skipLibCheck": true, "resolveJsonModule": true,