Require underscore for private methods (#23138)

pull/23145/head
Petar Petrov 2024-12-04 16:05:49 +02:00 committed by GitHub
parent 9396d5cf8c
commit d77dd5300e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 30 additions and 51 deletions

View File

@ -46,7 +46,6 @@ class CastDemoRow extends LitElement implements LovelaceRow {
this.requestUpdate(); this.requestUpdate();
}); });
mgr.castContext.addEventListener( mgr.castContext.addEventListener(
// eslint-disable-next-line no-undef
cast.framework.CastContextEventType.SESSION_STATE_CHANGED, cast.framework.CastContextEventType.SESSION_STATE_CHANGED,
(ev) => { (ev) => {
// On Android, opening a new session always results in SESSION_RESUMED. // On Android, opening a new session always results in SESSION_RESUMED.

View File

@ -114,13 +114,7 @@ export default [
"@typescript-eslint/no-shadow": ["error"], "@typescript-eslint/no-shadow": ["error"],
"@typescript-eslint/naming-convention": [ "@typescript-eslint/naming-convention": [
"off", "warn",
{
selector: "default",
format: ["camelCase", "snake_case"],
leadingUnderscore: "allow",
trailingUnderscore: "allow",
},
{ {
selector: ["variable"], selector: ["variable"],
format: ["camelCase", "snake_case", "UPPER_CASE"], format: ["camelCase", "snake_case", "UPPER_CASE"],
@ -131,6 +125,18 @@ export default [
selector: "typeLike", selector: "typeLike",
format: ["PascalCase"], format: ["PascalCase"],
}, },
{
selector: "method",
modifiers: ["public"],
format: ["camelCase"],
leadingUnderscore: "forbid",
},
{
selector: "method",
modifiers: ["private"],
format: ["camelCase"],
leadingUnderscore: "require",
},
], ],
"@typescript-eslint/no-unused-vars": "off", "@typescript-eslint/no-unused-vars": "off",

View File

@ -1,4 +1,3 @@
/* eslint-disable lit/no-template-arrow */
import type { TemplateResult } from "lit"; import type { TemplateResult } from "lit";
import { LitElement, html, css } from "lit"; import { LitElement, html, css } from "lit";
import { customElement, state } from "lit/decorators"; import { customElement, state } from "lit/decorators";

View File

@ -1,4 +1,3 @@
/* eslint-disable lit/no-template-arrow */
import "@material/mwc-button"; import "@material/mwc-button";
import type { TemplateResult } from "lit"; import type { TemplateResult } from "lit";
import { css, html, LitElement } from "lit"; import { css, html, LitElement } from "lit";

View File

@ -29,7 +29,6 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
declare global { declare global {
// eslint-disable-next-line
interface HASSDomEvents {} interface HASSDomEvents {}
} }

View File

@ -14,10 +14,8 @@ export default function scrollToTarget(element, target) {
const top = 0; const top = 0;
const scroller = target; const scroller = target;
const easingFn = function easeOutQuad(t, b, c, d) { const easingFn = function easeOutQuad(t, b, c, d) {
/* eslint-disable no-param-reassign, space-infix-ops, no-mixed-operators */
t /= d; t /= d;
return -c * t * (t - 2) + b; return -c * t * (t - 2) + b;
/* eslint-enable no-param-reassign, space-infix-ops, no-mixed-operators */
}; };
const animationId = Math.random(); const animationId = Math.random();
const duration = 200; const duration = 200;

View File

@ -183,7 +183,7 @@ export class HaAnsiToHtml extends LitElement {
/* eslint-disable no-cond-assign */ /* eslint-disable no-cond-assign */
let match; let match;
// eslint-disable-next-line
while ((match = re.exec(line)) !== null) { while ((match = re.exec(line)) !== null) {
const j = match!.index; const j = match!.index;
const substring = line.substring(i, j); const substring = line.substring(i, j);

View File

@ -1,4 +1,3 @@
/* eslint-disable lit/prefer-static-styles */
import { mdiEye, mdiEyeOff } from "@mdi/js"; import { mdiEye, mdiEyeOff } from "@mdi/js";
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit"; import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
import { LitElement, css, html, nothing } from "lit"; import { LitElement, css, html, nothing } from "lit";

View File

@ -20,7 +20,6 @@ type NavigationItem = {
const DEFAULT_ITEMS: NavigationItem[] = []; const DEFAULT_ITEMS: NavigationItem[] = [];
// eslint-disable-next-line lit/prefer-static-styles
const rowRenderer: ComboBoxLitRenderer<NavigationItem> = (item) => html` const rowRenderer: ComboBoxLitRenderer<NavigationItem> = (item) => html`
<mwc-list-item graphic="icon" .twoline=${!!item.title}> <mwc-list-item graphic="icon" .twoline=${!!item.title}>
<ha-icon .icon=${item.icon} slot="graphic"></ha-icon> <ha-icon .icon=${item.icon} slot="graphic"></ha-icon>

View File

@ -10,7 +10,6 @@ export interface InstallationType {
| "Unknown"; | "Unknown";
} }
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface OnboardingCoreConfigStepResponse {} export interface OnboardingCoreConfigStepResponse {}
export interface OnboardingUserStepResponse { export interface OnboardingUserStepResponse {
@ -21,7 +20,6 @@ export interface OnboardingIntegrationStepResponse {
auth_code: string; auth_code: string;
} }
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface OnboardingAnalyticsStepResponse {} export interface OnboardingAnalyticsStepResponse {}
export interface OnboardingResponses { export interface OnboardingResponses {

View File

@ -1,6 +1,5 @@
import { fireEvent } from "../../common/dom/fire_event"; import { fireEvent } from "../../common/dom/fire_event";
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface RestartDialogParams {} export interface RestartDialogParams {}
export const loadRestartDialog = () => import("./dialog-restart"); export const loadRestartDialog = () => import("./dialog-restart");

View File

@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/triple-slash-reference */ /* eslint-disable @typescript-eslint/triple-slash-reference */
// eslint-disable-next-line spaced-comment
/// <reference path="../types/service-worker.d.ts" /> /// <reference path="../types/service-worker.d.ts" />
/* eslint-env serviceworker */ /* eslint-env serviceworker */
import type { RouteHandler } from "workbox-core"; import type { RouteHandler } from "workbox-core";

View File

@ -1,4 +1,3 @@
/* eslint-disable lit/prefer-static-styles */
import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit"; import type { CSSResultGroup, PropertyValues, TemplateResult } from "lit";
import { css, html, LitElement } from "lit"; import { css, html, LitElement } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";

View File

@ -13,7 +13,7 @@ import "../../../../components/ha-radio";
import "../../../../components/ha-settings-row"; import "../../../../components/ha-settings-row";
import "../../../../components/ha-switch"; import "../../../../components/ha-switch";
import "../../../../components/ha-textfield"; import "../../../../components/ha-textfield";
// eslint-disable-next-line
import { formatDate } from "../../../../common/datetime/format_date"; import { formatDate } from "../../../../common/datetime/format_date";
import type { HaSwitch } from "../../../../components/ha-switch"; import type { HaSwitch } from "../../../../components/ha-switch";
import type { CloudStatusLoggedIn } from "../../../../data/cloud"; import type { CloudStatusLoggedIn } from "../../../../data/cloud";

View File

@ -87,7 +87,7 @@ export class HuiCard extends ReactiveElement {
} }
if (this._element.getLayoutOptions) { if (this._element.getLayoutOptions) {
// Disabled for now to avoid spamming the console, need to be re-enabled when hui-card performance are fixed // Disabled for now to avoid spamming the console, need to be re-enabled when hui-card performance are fixed
// eslint-disable-next-line no-console
// console.warn( // console.warn(
// `This card (${this.config?.type}) is using "getLayoutOptions" and it is deprecated, contact the developer to suggest to use "getGridOptions" instead` // `This card (${this.config?.type}) is using "getLayoutOptions" and it is deprecated, contact the developer to suggest to use "getGridOptions" instead`
// ); // );

View File

@ -15,9 +15,7 @@ export class HuiEmptyStateCard extends LitElement implements LovelaceCard {
return 2; return 2;
} }
public setConfig(_config: EmptyStateCardConfig): void { public setConfig(_config: EmptyStateCardConfig): void {}
// eslint-disable-next-line
}
protected render() { protected render() {
if (!this.hass) { if (!this.hass) {

View File

@ -18,9 +18,7 @@ export class HuiStartingCard extends LitElement implements LovelaceCard {
return 2; return 2;
} }
public setConfig(_config: LovelaceCardConfig): void { public setConfig(_config: LovelaceCardConfig): void {}
// eslint-disable-next-line
}
protected updated(changedProperties: PropertyValues) { protected updated(changedProperties: PropertyValues) {
super.updated(changedProperties); super.updated(changedProperties);

View File

@ -14,13 +14,12 @@ class HuiMarquee extends LitElement {
protected firstUpdated(changedProps) { protected firstUpdated(changedProps) {
super.firstUpdated(changedProps); super.firstUpdated(changedProps);
// eslint-disable-next-line wc/no-self-class
this.addEventListener("mouseover", () => this.classList.add("hovering"), { this.addEventListener("mouseover", () => this.classList.add("hovering"), {
// Capture because we need to run before a parent sets active on us. // Capture because we need to run before a parent sets active on us.
// Hovering will disable the overflow, allowing us to calc if we overflow. // Hovering will disable the overflow, allowing us to calc if we overflow.
capture: true, capture: true,
}); });
// eslint-disable-next-line wc/no-self-class
this.addEventListener("mouseout", () => this.classList.remove("hovering")); this.addEventListener("mouseout", () => this.classList.remove("hovering"));
} }

View File

@ -32,7 +32,6 @@ export class HuiImageElement extends LitElement implements LovelaceElement {
this._config = { hold_action: { action: "more-info" }, ...config }; this._config = { hold_action: { action: "more-info" }, ...config };
// eslint-disable-next-line wc/no-self-class
this.classList.toggle( this.classList.toggle(
"clickable", "clickable",
this._config.tap_action && this._config.tap_action.action !== "none" this._config.tap_action && this._config.tap_action.action !== "none"

View File

@ -99,7 +99,6 @@ export class BrowserMediaPlayer {
supported_features: supported_features:
// eslint-disable-next-line no-bitwise // eslint-disable-next-line no-bitwise
MediaPlayerEntityFeature.PLAY | MediaPlayerEntityFeature.PLAY |
// eslint-disable-next-line no-bitwise
MediaPlayerEntityFeature.PAUSE | MediaPlayerEntityFeature.PAUSE |
MediaPlayerEntityFeature.VOLUME_SET, MediaPlayerEntityFeature.VOLUME_SET,
}; };

View File

@ -18,29 +18,18 @@ export class HassBaseEl extends LitElement {
protected initializeHass(_auth: Auth, _conn: Connection) { protected initializeHass(_auth: Auth, _conn: Connection) {
// implemented in connection-mixin // implemented in connection-mixin
// eslint-disable-next-line
} }
// Exists so all methods can safely call super method // Exists so all methods can safely call super method
protected hassConnected() { protected hassConnected() {}
// eslint-disable-next-line
}
protected hassReconnected() { protected hassReconnected() {}
// eslint-disable-next-line
}
protected hassDisconnected() { protected hassDisconnected() {}
// eslint-disable-next-line
}
protected panelUrlChanged(_newPanelUrl) { protected panelUrlChanged(_newPanelUrl) {}
// eslint-disable-next-line
}
protected checkDataBaseMigration() { protected checkDataBaseMigration() {}
// eslint-disable-next-line
}
protected hassChanged(hass, _oldHass) { protected hassChanged(hass, _oldHass) {
this.__provideHass.forEach((el) => { this.__provideHass.forEach((el) => {

View File

@ -65,11 +65,13 @@ export default <T extends Constructor<HassElement>>(superClass: T) =>
a: (ev) => this._showVoiceCommandDialog(ev), a: (ev) => this._showVoiceCommandDialog(ev),
d: (ev) => this._showQuickBar(ev, QuickBarMode.Device), d: (ev) => this._showQuickBar(ev, QuickBarMode.Device),
// Those are fallbacks for non-latin keyboards that don't have e, c, m keys (qwerty-based shortcuts) // Those are fallbacks for non-latin keyboards that don't have e, c, m keys (qwerty-based shortcuts)
/* eslint-disable @typescript-eslint/naming-convention */
KeyE: (ev) => this._showQuickBar(ev), KeyE: (ev) => this._showQuickBar(ev),
KeyC: (ev) => this._showQuickBar(ev, QuickBarMode.Command), KeyC: (ev) => this._showQuickBar(ev, QuickBarMode.Command),
KeyM: (ev) => this._createMyLink(ev), KeyM: (ev) => this._createMyLink(ev),
KeyA: (ev) => this._showVoiceCommandDialog(ev), KeyA: (ev) => this._showVoiceCommandDialog(ev),
KeyD: (ev) => this._showQuickBar(ev, QuickBarMode.Device), KeyD: (ev) => this._showQuickBar(ev, QuickBarMode.Device),
/* eslint-enable @typescript-eslint/naming-convention */
}); });
} }

View File

@ -23,7 +23,7 @@ import type { Themes } from "./data/ws-themes";
import type { ExternalMessaging } from "./external_app/external_messaging"; import type { ExternalMessaging } from "./external_app/external_messaging";
declare global { declare global {
/* eslint-disable no-var */ /* eslint-disable no-var, @typescript-eslint/naming-convention */
var __DEV__: boolean; var __DEV__: boolean;
var __DEMO__: boolean; var __DEMO__: boolean;
var __BUILD__: "modern" | "legacy"; var __BUILD__: "modern" | "legacy";
@ -32,7 +32,7 @@ declare global {
var __BACKWARDS_COMPAT__: boolean; var __BACKWARDS_COMPAT__: boolean;
var __SUPERVISOR__: boolean; var __SUPERVISOR__: boolean;
var __HASS_URL__: string; var __HASS_URL__: string;
/* eslint-enable no-var, no-redeclare */ /* eslint-enable no-var, @typescript-eslint/naming-convention */
interface Window { interface Window {
// Custom panel entry point url // Custom panel entry point url
@ -70,6 +70,7 @@ declare global {
// Intl.DurationFormat is not yet part of the TypeScript standard // Intl.DurationFormat is not yet part of the TypeScript standard
// eslint-disable-next-line @typescript-eslint/no-namespace // eslint-disable-next-line @typescript-eslint/no-namespace
namespace Intl { namespace Intl {
// eslint-disable-next-line @typescript-eslint/naming-convention
const DurationFormat: DurationFormatConstructor; const DurationFormat: DurationFormatConstructor;
} }
} }