Skip to content

Commit

Permalink
Merge pull request #146 from jcwillox/renovate/major-linters
Browse files Browse the repository at this point in the history
build(deps): update linters (major)
  • Loading branch information
jcwillox authored Nov 11, 2023
2 parents af691bc + 6051ff1 commit b96a989
Show file tree
Hide file tree
Showing 9 changed files with 325 additions and 171 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@
},
"devDependencies": {
"@types/node": "20.9.0",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"@typescript-eslint/eslint-plugin": "6.10.0",
"@typescript-eslint/parser": "6.10.0",
"eslint": "8.53.0",
"eslint-config-prettier": "8.10.0",
"eslint-config-prettier": "9.0.0",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-only-warn": "1.1.0",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-prettier": "5.0.1",
"husky": "8.0.3",
"lint-staged": "15.0.2",
"prettier": "2.8.8",
"prettier": "3.0.3",
"typescript": "5.2.2"
},
"packageManager": "[email protected]",
Expand Down
400 changes: 277 additions & 123 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions src/action-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface IActionHandler extends HTMLElement {
holdTime: number;
bind: (
element: ActionHandlerElement,
options?: CustomActionHandlerOptions
options?: CustomActionHandlerOptions,
) => void;
}

Expand Down Expand Up @@ -115,14 +115,14 @@ class ActionHandler extends HTMLElement implements IActionHandler {
}
}
},
{ passive: true }
{ passive: true },
);
});
}

public bind(
element: ActionHandlerElement,
options: CustomActionHandlerOptions = {}
options: CustomActionHandlerOptions = {},
): void {
if (
element.actionHandler &&
Expand Down Expand Up @@ -283,12 +283,12 @@ const getActionHandler = (): ActionHandler => {
const body = document.body;
if (body.querySelector("paper-buttons-row-action-handler")) {
return body.querySelector(
"paper-buttons-row-action-handler"
"paper-buttons-row-action-handler",
) as ActionHandler;
}

const actionHandler = document.createElement(
"paper-buttons-row-action-handler"
"paper-buttons-row-action-handler",
);
body.appendChild(actionHandler);

Expand All @@ -297,7 +297,7 @@ const getActionHandler = (): ActionHandler => {

export const actionHandlerBind = (
element: ActionHandlerElement,
options?: CustomActionHandlerOptions
options?: CustomActionHandlerOptions,
): void => {
const actionHandler: ActionHandler = getActionHandler();
if (!actionHandler) {
Expand All @@ -315,5 +315,5 @@ export const actionHandler = directive(

// eslint-disable-next-line @typescript-eslint/no-empty-function,@typescript-eslint/no-unused-vars
render(_options?: CustomActionHandlerOptions) {}
}
},
);
18 changes: 9 additions & 9 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const handleAction = (
node: HTMLElement,
hass: HomeAssistant,
config: ButtonConfig,
action: string
action: string,
): void => {
let actionConfig: ButtonActionConfig | undefined;

Expand All @@ -31,7 +31,7 @@ export function handleActionConfig(
node: HTMLElement,
hass: HomeAssistant,
config: ButtonConfig,
actionConfig: ButtonActionConfig | undefined
actionConfig: ButtonActionConfig | undefined,
) {
if (!actionConfig) {
actionConfig = {
Expand All @@ -43,15 +43,15 @@ export function handleActionConfig(
actionConfig.confirmation &&
(!actionConfig.confirmation.exemptions ||
!actionConfig.confirmation.exemptions.some(
e => e.user === hass?.user?.id
e => e.user === hass?.user?.id,
))
) {
forwardHaptic("warning");

if (
!confirm(
actionConfig.confirmation.text ||
`Are you sure you want to ${actionConfig.action}?`
`Are you sure you want to ${actionConfig.action}?`,
)
) {
return;
Expand All @@ -66,7 +66,7 @@ export function handleActionConfig(
} else {
showToast(node, {
message: hass.localize(
"ui.panel.lovelace.cards.actions.no_entity_more_info"
"ui.panel.lovelace.cards.actions.no_entity_more_info",
),
});
forwardHaptic("failure");
Expand All @@ -77,7 +77,7 @@ export function handleActionConfig(
if (!actionConfig.navigation_path) {
showToast(node, {
message: hass.localize(
"ui.panel.lovelace.cards.actions.no_navigation_path"
"ui.panel.lovelace.cards.actions.no_navigation_path",
),
});
forwardHaptic("failure");
Expand All @@ -101,7 +101,7 @@ export function handleActionConfig(
if (!config.entity) {
showToast(node, {
message: hass.localize(
"ui.panel.lovelace.cards.actions.no_entity_toggle"
"ui.panel.lovelace.cards.actions.no_entity_toggle",
),
});
forwardHaptic("failure");
Expand All @@ -123,7 +123,7 @@ export function handleActionConfig(
domain,
service,
actionConfig.service_data,
actionConfig.target
actionConfig.target,
);
forwardHaptic("light");
break;
Expand All @@ -139,7 +139,7 @@ export function handleActionConfig(
hass.callApi(
"POST",
`events/${actionConfig.event_type}`,
actionConfig.event_data || {}
actionConfig.event_data || {},
);
forwardHaptic("light");
break;
Expand Down
4 changes: 2 additions & 2 deletions src/entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface LovelaceElement extends LitElement {

type FirstUpdatedFn = (
this: LovelaceElement,
changedProperties: PropertyValues
changedProperties: PropertyValues,
) => void;

export function createModule(element: string, firstUpdated: FirstUpdatedFn) {
Expand All @@ -38,7 +38,7 @@ createModule("hui-generic-entity-row", function () {
type: "custom:paper-buttons-row",
...pbConfig,
},
true
true,
);

provideHass(paperButtons);
Expand Down
10 changes: 5 additions & 5 deletions src/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,35 @@ function computeActionTooltip(hass, state, config, isHold) {
tooltip += `${hass.localize(
"ui.panel.lovelace.cards.picture-elements.navigate_to",
"location",
config.navigation_path
config.navigation_path,
)}`;
break;
case "url":
tooltip += `${hass.localize(
"ui.panel.lovelace.cards.picture-elements.url",
"url_path",
config.url_path
config.url_path,
)}`;
break;
case "toggle":
tooltip += `${hass.localize(
"ui.panel.lovelace.cards.picture-elements.toggle",
"name",
state
state,
)}`;
break;
case "call-service":
tooltip += `${hass.localize(
"ui.panel.lovelace.cards.picture-elements.call_service",
"name",
config.service
config.service,
)}`;
break;
case "more-info":
tooltip += `${hass.localize(
"ui.panel.lovelace.cards.picture-elements.more_info",
"name",
state
state,
)}`;
break;
}
Expand Down
34 changes: 17 additions & 17 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import "./entity-row";
console.groupCollapsed(
`%c ${__NAME__} %c ${__VERSION__} `,
"color: white; background: #039be5; font-weight: 700;",
"color: #039be5; background: white; font-weight: 700;"
"color: #039be5; background: white; font-weight: 700;",
);
console.info(`branch : ${__BRANCH__}`);
console.info(`commit : ${__COMMIT__}`);
Expand All @@ -62,7 +62,7 @@ const computeStateText = (config: ButtonConfig) => {
const migrateIconAlignment = (alignment: string) => {
console.warn(
__NAME__,
"'align_icon' and 'align_icons' is deprecated and will be removed in a future version"
"'align_icon' and 'align_icons' is deprecated and will be removed in a future version",
);
switch (alignment) {
case "top":
Expand All @@ -88,7 +88,7 @@ export class PaperButtonsRow extends LitElement {

// convert an externally set config to the correct internal structure
private _transformConfig(
config: ExternalPaperButtonRowConfig
config: ExternalPaperButtonRowConfig,
): PaperButtonRowConfig {
// check valid config
if (!config) throw new Error("Invalid configuration");
Expand Down Expand Up @@ -133,7 +133,7 @@ export class PaperButtonsRow extends LitElement {
bConfig.layout = bConfig.layout
.split("|")
.map(column =>
column.includes("_") ? column.split("_") : column
column.includes("_") ? column.split("_") : column,
);
}

Expand All @@ -160,7 +160,7 @@ export class PaperButtonsRow extends LitElement {
for (const stateKey in bConfig.state_styles) {
for (const key in bConfig.state_styles[stateKey]) {
bConfig.state_styles[stateKey][key] = arrayToObject(
bConfig.state_styles[stateKey][key]
bConfig.state_styles[stateKey][key],
);
}
}
Expand All @@ -171,7 +171,7 @@ export class PaperButtonsRow extends LitElement {

return bConfig;
});
}
},
);

return config as PaperButtonRowConfig;
Expand All @@ -197,14 +197,14 @@ export class PaperButtonsRow extends LitElement {

// subscribe template options
TEMPLATE_OPTIONS.forEach(key =>
subscribeTemplate.call(this, config, config, key)
subscribeTemplate.call(this, config, config, key),
);

// subscribe template styles
Object.values(config.styles).forEach(styles => {
if (typeof styles === "object")
Object.keys(styles).forEach(key =>
subscribeTemplate.call(this, config, styles, key)
subscribeTemplate.call(this, config, styles, key),
);
});

Expand Down Expand Up @@ -264,22 +264,22 @@ export class PaperButtonsRow extends LitElement {
class="${this._getClass(
activeStates,
config.state,
stateObj?.state
stateObj?.state,
)}"
title="${computeTooltip(config, this.hass)}"
data-domain="${ifDefined(domain)}"
data-entity-state="${ifDefined(stateObj?.state)}"
data-state="${ifDefined(
typeof config.state === "string" &&
config.state.toLowerCase()
config.state.toLowerCase(),
)}"
>
${config.layout?.map(column => {
if (Array.isArray(column))
return html`
<div class="flex-column">
${column.map(row =>
this.renderElement(row, config, styles, stateObj)
this.renderElement(row, config, styles, stateObj),
)}
</div>
`;
Expand All @@ -304,7 +304,7 @@ export class PaperButtonsRow extends LitElement {
item: string,
config: ButtonConfig,
styles: StyleConfig,
entity?: HassEntity
entity?: HassEntity,
) {
const style: StyleInfo = styles?.[item] || {};
switch (item) {
Expand Down Expand Up @@ -364,7 +364,7 @@ export class PaperButtonsRow extends LitElement {
_getClass(
activeStates: Set<string>,
state?: ButtonConfig["state"],
entityState?: string
entityState?: string,
) {
if (typeof state == "string" && activeStates.has(state.toLowerCase())) {
return "button-active";
Expand Down Expand Up @@ -406,7 +406,7 @@ export class PaperButtonsRow extends LitElement {
// from `device_class`
if (stateObj.attributes.device_class) {
const hex = styles.getPropertyValue(
`--state-${domain}-${stateObj.attributes.device_class}-${stateObj.state}-color`
`--state-${domain}-${stateObj.attributes.device_class}-${stateObj.state}-color`,
);
if (hex) {
return this._hexToRgb(hex);
Expand All @@ -415,7 +415,7 @@ export class PaperButtonsRow extends LitElement {

// from `state`
let hex = styles.getPropertyValue(
`--state-${domain}-${stateObj.state}-color`
`--state-${domain}-${stateObj.state}-color`,
);
if (hex) return this._hexToRgb(hex);

Expand Down Expand Up @@ -473,7 +473,7 @@ export class PaperButtonsRow extends LitElement {

_defaultConfig(
config: ExternalPaperButtonRowConfig,
bConfig: ExternalButtonConfig
bConfig: ExternalButtonConfig,
) {
if (!bConfig.layout) {
// migrate align_icon to layout
Expand Down Expand Up @@ -524,7 +524,7 @@ export class PaperButtonsRow extends LitElement {
}
// only update if monitored entity changed state.
return this._entities.some(
entity => oldHass.states[entity] !== this.hass?.states[entity]
entity => oldHass.states[entity] !== this.hass?.states[entity],
);
}
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let lovelace = getLovelace();

export function handleButtonPreset(
bConfig: ButtonConfig,
config?: PaperButtonRowConfig
config?: PaperButtonRowConfig,
): ButtonConfig {
if (!lovelace) lovelace = getLovelace();
const userPresets = lovelace?.config?.paper_buttons_row?.presets || {};
Expand All @@ -28,7 +28,7 @@ export function handleButtonPreset(
}[preset] ||
userPresets[preset] ||
{},
bConfig
bConfig,
)
: bConfig;
}
Expand Down
2 changes: 1 addition & 1 deletion src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function subscribeTemplate(this: PaperButtonsRow, config, object, key) {
{
template: option,
variables: { config: config },
}
},
);
object[key] = "";
}
Expand Down

0 comments on commit b96a989

Please sign in to comment.