diff --git a/.prettierrc.js b/.prettierrc.js index 93f1e1c1..933e929f 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -2,6 +2,7 @@ module.exports = { semi: true, trailingComma: 'all', singleQuote: true, - printWidth: 120, + printWidth: 89, tabWidth: 2, -}; \ No newline at end of file + embeddedLanguageFormatting: 'auto', +}; diff --git a/rollup.config.js b/rollup.config.js index 5412ea58..d40720cb 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -5,7 +5,7 @@ import babel from 'rollup-plugin-babel'; import { terser } from 'rollup-plugin-terser'; import serve from 'rollup-plugin-serve'; import json from '@rollup/plugin-json'; -import styles from "rollup-plugin-styles"; +import styles from 'rollup-plugin-styles'; const dev = process.env.ROLLUP_WATCH; @@ -24,10 +24,10 @@ const plugins = [ modules: false, // Behavior of inject mode, without actually injecting style // into
. - mode: ["inject", () => undefined], + mode: ['inject', () => undefined], sass: { - includePaths: ["./node_modules/"] - } + includePaths: ['./node_modules/'], + }, }), nodeResolve({}), commonjs(), diff --git a/src/action-handler-directive.ts b/src/action-handler-directive.ts index addf7b93..38968d55 100644 --- a/src/action-handler-directive.ts +++ b/src/action-handler-directive.ts @@ -1,9 +1,15 @@ import { directive, PropertyPart } from 'lit-html'; -import { ActionHandlerDetail, ActionHandlerOptions } from 'custom-card-helpers/dist/types'; +import { + ActionHandlerDetail, + ActionHandlerOptions, +} from 'custom-card-helpers/dist/types'; import { fireEvent } from 'custom-card-helpers'; -const isTouch = 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0; +const isTouch = + 'ontouchstart' in window || + navigator.maxTouchPoints > 0 || + navigator.msMaxTouchPoints > 0; interface ActionHandler extends HTMLElement { holdTime: number; @@ -49,7 +55,15 @@ class ActionHandler extends HTMLElement implements ActionHandler { this.appendChild(this.ripple); this.ripple.primary = true; - ['touchcancel', 'mouseout', 'mouseup', 'touchmove', 'mousewheel', 'wheel', 'scroll'].forEach(ev => { + [ + 'touchcancel', + 'mouseout', + 'mouseup', + 'touchmove', + 'mousewheel', + 'wheel', + 'scroll', + ].forEach((ev) => { document.addEventListener( ev, () => { @@ -111,7 +125,10 @@ class ActionHandler extends HTMLElement implements ActionHandler { if (this.held) { fireEvent(element, 'action', { action: 'hold' }); } else if (options.hasDoubleClick) { - if ((ev.type === 'click' && (ev as MouseEvent).detail < 2) || !this.dblClickTimeout) { + if ( + (ev.type === 'click' && (ev as MouseEvent).detail < 2) || + !this.dblClickTimeout + ) { this.dblClickTimeout = window.setTimeout(() => { this.dblClickTimeout = undefined; fireEvent(element, 'action', { action: 'tap' }); @@ -175,7 +192,10 @@ const getActionHandler = (): ActionHandler => { return actionhandler as ActionHandler; }; -export const actionHandlerBind = (element: ActionHandlerElement, options: ActionHandlerOptions): void => { +export const actionHandlerBind = ( + element: ActionHandlerElement, + options: ActionHandlerOptions, +): void => { const actionhandler: ActionHandler = getActionHandler(); if (!actionhandler) { return; @@ -183,6 +203,9 @@ export const actionHandlerBind = (element: ActionHandlerElement, options: Action actionhandler.bind(element, options); }; -export const actionHandler = directive((options: ActionHandlerOptions = {}) => (part: PropertyPart): void => { - actionHandlerBind(part.committer.element as ActionHandlerElement, options); -}); +export const actionHandler = directive( + (options: ActionHandlerOptions = {}) => + (part: PropertyPart): void => { + actionHandlerBind(part.committer.element as ActionHandlerElement, options); + }, +); diff --git a/src/const.ts b/src/const.ts index 59fb347d..8d745ee2 100644 --- a/src/const.ts +++ b/src/const.ts @@ -1 +1 @@ -export const CARD_VERSION = '0.0.1'; \ No newline at end of file +export const CARD_VERSION = '0.0.1'; diff --git a/src/declarations.d.ts b/src/declarations.d.ts index caaba6a2..d5cf927a 100644 --- a/src/declarations.d.ts +++ b/src/declarations.d.ts @@ -1 +1 @@ -declare module '*.scss'; \ No newline at end of file +declare module '*.scss'; diff --git a/src/editor.ts b/src/editor.ts index fb91a5e3..585259f9 100644 --- a/src/editor.ts +++ b/src/editor.ts @@ -13,7 +13,7 @@ import { HomeAssistant, fireEvent, LovelaceCardEditor } from 'custom-card-helper import { FrigateCardConfig } from './types'; -import frigate_card_editor_style from './frigate-card-editor.scss' +import frigate_card_editor_style from './frigate-card-editor.scss'; const options = { required: { @@ -63,12 +63,13 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor return true; } - protected _getEntities(domain: string) : string[] { + protected _getEntities(domain: string): string[] { if (!this.hass) { return []; } - const entities = Object.keys( - this.hass.states).filter(eid => eid.substr(0, eid.indexOf('.')) === domain); + const entities = Object.keys(this.hass.states).filter( + (eid) => eid.substr(0, eid.indexOf('.')) === domain, + ); entities.sort(); // Add a blank entry to unset a selection. @@ -87,26 +88,26 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor // You can restrict on domain type const cameraEntities = this._getEntities('camera'); const binarySensorEntities = this._getEntities('binary_sensor'); - - const webrtcCameraEntity = - this._config?.webrtc && (this._config?.webrtc as any).entity ? - (this._config?.webrtc as any).entity : - ''; + + const webrtcCameraEntity = + this._config?.webrtc && (this._config?.webrtc as any).entity + ? (this._config?.webrtc as any).entity + : ''; const viewModes = { - "": "", - "live": "Live view", - "clips": "Clip gallery", - "snapshots": "Snapshot gallery", - "clip": "Latest clip", - "snapshot": "Latest snapshot", - } + '': '', + live: 'Live view', + clips: 'Clip gallery', + snapshots: 'Snapshot gallery', + clip: 'Latest clip', + snapshot: 'Latest snapshot', + }; const liveProvider = { - "": "", - "frigate": "Frigate", - "webrtc": "WebRTC", - } + '': '', + frigate: 'Frigate', + webrtc: 'WebRTC', + }; return html`