Skip to content
This repository has been archived by the owner on Oct 8, 2020. It is now read-only.

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
maykar committed Jun 4, 2020
1 parent a618b0d commit 1e595d0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
31 changes: 17 additions & 14 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
experimentalDecorators: true,
},
rules: {
"@typescript-eslint/camelcase": 0
}
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
experimentalDecorators: true,
},
rules: {
'@typescript-eslint/camelcase': 0,
'@typescript-eslint/no-use-before-define': 0,
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/explicit-function-return-type': 0,
},
};
22 changes: 11 additions & 11 deletions src/custom-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ export const rebuild = () => {
return;
}

(window as any).last_template_result = [];
clearTimeout((window as any).customHeaderTempTimeout);
window['last_template_result'] = [];
clearTimeout(window['customHeaderTempTimeout']);
if (!window.location.href.includes('disable_ch')) hideHeader(haElem);

// Wait for elements before building.
Expand All @@ -120,9 +120,9 @@ export const rebuild = () => {
} else if (haElem && haElem.lovelace && haElem.menu) {
// Clear timeout and old subscriptions.
clearTimeout(timeout);
if ((window as any).customHeaderUnsub && (window as any).customHeaderUnsub.length) {
for (const prev of (window as any).customHeaderUnsub) prev();
(window as any).customHeaderUnsub = [];
if (window['customHeaderUnsub'] && window['customHeaderUnsub'].length) {
for (const prev of window['customHeaderUnsub']) prev();
window['customHeaderUnsub'] = [];
}

// Build header and config.
Expand All @@ -138,16 +138,16 @@ export const rebuild = () => {

const rawConfigObserver = () => {
const haElem = ha_elements();
if ((window as any).chRebuildMO) (window as any).chRebuildMO.disconnect();
if ((window as any).chRawConfigExit) (window as any).chRawConfigExit.disconnect();
if (window['customHeaderRebuildMO']) window['customHeaderRebuildMO'].disconnect();
if (window['customHeaderRawConfigExit']) window['customHeaderRawConfigExit'].disconnect();
if (!haElem || !haElem.partialPanel) {
window.setTimeout(() => {
rawConfigObserver();
return;
}, 100);
}
(window as any).chRebuildMO = new MutationObserver(rebuild);
(window as any).chRebuildMO.observe(
window['customHeaderRebuildMO'] = new MutationObserver(rebuild);
window['customHeaderRebuildMO'].observe(
document
.querySelector('home-assistant')!
.shadowRoot!.querySelector('home-assistant-main')!
Expand Down Expand Up @@ -184,8 +184,8 @@ const rawConfigObserver = () => {
}
}
};
(window as any).chRawConfigExit = new MutationObserver(rawExit);
(window as any).chRawConfigExit.observe(
window['customHeaderRawConfigExit'] = new MutationObserver(rawExit);
window['customHeaderRawConfigExit'].observe(
document
.querySelector('home-assistant')!
.shadowRoot!.querySelector('home-assistant-main')!
Expand Down

0 comments on commit 1e595d0

Please sign in to comment.