lint(eslint): migrate to eslint and prettier (#25046)

This commit is contained in:
Liam DeBeasi
2022-04-04 11:12:53 -04:00
committed by GitHub
parent 12fd19dd4d
commit 5676bab316
826 changed files with 56539 additions and 52754 deletions

View File

@ -1,8 +1,9 @@
import { Component, ComponentInterface, Element, Host, Prop, State, forceUpdate, h } from '@stencil/core';
import type { ComponentInterface } from '@stencil/core';
import { Component, Element, Host, Prop, State, forceUpdate, h } from '@stencil/core';
import { getIonMode } from '../../global/ionic-global';
import { SegmentButtonLayout } from '../../interface';
import { ButtonInterface } from '../../utils/element-interface';
import type { SegmentButtonLayout } from '../../interface';
import type { ButtonInterface } from '../../utils/element-interface';
import { addEventListener, removeEventListener } from '../../utils/helpers';
import { hostContext } from '../../utils/theme';
@ -19,9 +20,9 @@ let ids = 0;
tag: 'ion-segment-button',
styleUrls: {
ios: 'segment-button.ios.scss',
md: 'segment-button.md.scss'
md: 'segment-button.md.scss',
},
shadow: true
shadow: true,
})
export class SegmentButton implements ComponentInterface, ButtonInterface {
private segmentEl: HTMLIonSegmentElement | null = null;
@ -48,10 +49,10 @@ export class SegmentButton implements ComponentInterface, ButtonInterface {
/**
* The value of the segment button.
*/
@Prop() value: string = 'ion-sb-' + (ids++);
@Prop() value: string = 'ion-sb-' + ids++;
connectedCallback() {
const segmentEl = this.segmentEl = this.el.closest('ion-segment');
const segmentEl = (this.segmentEl = this.el.closest('ion-segment'));
if (segmentEl) {
this.updateState();
addEventListener(segmentEl, 'ionSelect', this.updateState);
@ -78,13 +79,13 @@ export class SegmentButton implements ComponentInterface, ButtonInterface {
private updateStyle = () => {
forceUpdate(this);
}
};
private updateState = () => {
if (this.segmentEl) {
this.checked = this.segmentEl.value === this.value;
}
}
};
private get tabIndex() {
return this.checked && !this.disabled ? 0 : -1;
@ -93,7 +94,7 @@ export class SegmentButton implements ComponentInterface, ButtonInterface {
render() {
const { checked, type, disabled, hasIcon, hasLabel, layout, segmentEl, tabIndex } = this;
const mode = getIonMode(this);
const hasSegmentColor = () => segmentEl !== null && segmentEl.color !== undefined;
const hasSegmentColor = () => segmentEl?.color !== undefined;
return (
<Host
role="tab"
@ -118,13 +119,7 @@ export class SegmentButton implements ComponentInterface, ButtonInterface {
'ion-focusable': true,
}}
>
<button
type={type}
tabIndex={-1}
class="button-native"
part="native"
disabled={disabled}
>
<button type={type} tabIndex={-1} class="button-native" part="native" disabled={disabled}>
<span class="button-inner">
<slot></slot>
</span>
@ -134,12 +129,11 @@ export class SegmentButton implements ComponentInterface, ButtonInterface {
part="indicator"
class={{
'segment-button-indicator': true,
'segment-button-indicator-animated': true
'segment-button-indicator-animated': true,
}}
>
<div part="indicator-background" class="segment-button-indicator-background"></div>
</div>
</Host>
);
}