lint(): fix lint issues with feature-6.1

This commit is contained in:
Liam DeBeasi
2022-04-04 19:37:12 +00:00
parent cb341167c3
commit d737f7074d
19 changed files with 60 additions and 66 deletions

View File

@ -1,6 +1,6 @@
import { printIonError } from '@utils/logging';
import type { ComponentInterface, EventEmitter } from '@stencil/core'; import type { ComponentInterface, EventEmitter } from '@stencil/core';
import { Component, Element, Event, Host, Method, Prop, State, Watch, h, writeTask } from '@stencil/core'; import { Component, Element, Event, Host, Method, Prop, State, Watch, h, writeTask } from '@stencil/core';
import { printIonError } from '@utils/logging';
import { caretDownSharp, caretUpSharp, chevronBack, chevronDown, chevronForward } from 'ionicons/icons'; import { caretDownSharp, caretUpSharp, chevronBack, chevronDown, chevronForward } from 'ionicons/icons';
import { getIonMode } from '../../global/ionic-global'; import { getIonMode } from '../../global/ionic-global';

View File

@ -1,6 +1,5 @@
import type { E2EPage } from '@stencil/core/testing'; import type { E2EPage } from '@stencil/core/testing';
import { newE2EPage } from '@stencil/core/testing'; import { newE2EPage } from '@stencil/core/testing';
import { scrollToBottom } from '@utils/test'; import { scrollToBottom } from '@utils/test';
/** /**

View File

@ -1,8 +1,8 @@
import { findIonContent, getScrollElement, printIonContentErrorMsg } from '@utils/content';
import type { ComponentInterface } from '@stencil/core'; import type { ComponentInterface } from '@stencil/core';
import { Component, Element, Host, Prop, h, writeTask } from '@stencil/core'; import { Component, Element, Host, Prop, h, writeTask } from '@stencil/core';
import { findIonContent, getScrollElement, printIonContentErrorMsg } from '@utils/content';
import { getIonMode } from '../../global/ionic-global'; import { getIonMode } from '../../global/ionic-global';
import type { Attributes } from '../../utils/helpers'; import type { Attributes } from '../../utils/helpers';

View File

@ -1,6 +1,5 @@
import { newE2EPage } from '@stencil/core/testing'; import { newE2EPage } from '@stencil/core/testing';
import type { E2EPage } from '@stencil/core/testing'; import type { E2EPage } from '@stencil/core/testing';
import { scrollToBottom } from '@utils/test'; import { scrollToBottom } from '@utils/test';
describe('ion-header: custom scroll target', () => { describe('ion-header: custom scroll target', () => {

View File

@ -1,6 +1,5 @@
import { newE2EPage } from '@stencil/core/testing'; import { newE2EPage } from '@stencil/core/testing';
import type { E2EPage } from '@stencil/core/testing'; import type { E2EPage } from '@stencil/core/testing';
import { scrollToBottom } from '@utils/test'; import { scrollToBottom } from '@utils/test';
/** /**

View File

@ -2,7 +2,6 @@
import type { ComponentInterface } from '@stencil/core'; import type { ComponentInterface } from '@stencil/core';
import { Component, Element, Host, Listen, Prop, State, Watch, forceUpdate, h } from '@stencil/core'; import { Component, Element, Host, Listen, Prop, State, Watch, forceUpdate, h } from '@stencil/core';
import { printIonError } from '@utils/logging'; import { printIonError } from '@utils/logging';
import { chevronForward } from 'ionicons/icons'; import { chevronForward } from 'ionicons/icons';
import { getIonMode } from '../../global/ionic-global'; import { getIonMode } from '../../global/ionic-global';
@ -12,7 +11,7 @@ import { raf } from '../../utils/helpers';
import { createColorClasses, hostContext, openURL } from '../../utils/theme'; import { createColorClasses, hostContext, openURL } from '../../utils/theme';
import type { InputChangeEventDetail } from '../input/input-interface'; import type { InputChangeEventDetail } from '../input/input-interface';
import { CounterFormatter } from './item-interface'; import type { CounterFormatter } from './item-interface';
/** /**
* @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use. * @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use.

View File

@ -1,4 +1,5 @@
import { E2EPage, newE2EPage } from '@stencil/core/testing'; import type { E2EPage} from '@stencil/core/testing';
import { newE2EPage } from '@stencil/core/testing';
describe('item: counter', () => { describe('item: counter', () => {
@ -75,7 +76,7 @@ describe('item: counter', () => {
} }
}); });
let itemCounter = await page.find('ion-item >>> .item-counter'); const itemCounter = await page.find('ion-item >>> .item-counter');
expect(itemCounter.textContent).toBe('0 / 20'); expect(itemCounter.textContent).toBe('0 / 20');
@ -105,13 +106,5 @@ describe('item: counter', () => {
}); });
}); });
<<<<<<< HEAD
=======
test('item: counter-rtl', async () => {
const page = await newE2EPage({
url: '/src/components/item/test/counter?ionic:_testing=true&rtl=true',
>>>>>>> origin/main
}); });
}) })

View File

@ -1,5 +1,6 @@
import { Animation } from '../../../interface'; import type { Animation } from '../../../interface';
import { GestureDetail, createGesture } from '../../../utils/gesture'; import type { GestureDetail} from '../../../utils/gesture';
import { createGesture } from '../../../utils/gesture';
import { clamp, raf } from '../../../utils/helpers'; import { clamp, raf } from '../../../utils/helpers';
import { getBackdropValueForSheet } from '../utils'; import { getBackdropValueForSheet } from '../utils';

View File

@ -1,6 +1,7 @@
import { Animation } from '../../../interface'; import type { Animation } from '../../../interface';
import { getTimeGivenProgression } from '../../../utils/animation/cubic-bezier'; import { getTimeGivenProgression } from '../../../utils/animation/cubic-bezier';
import { GestureDetail, createGesture } from '../../../utils/gesture'; import type { GestureDetail} from '../../../utils/gesture';
import { createGesture } from '../../../utils/gesture';
import { clamp } from '../../../utils/helpers'; import { clamp } from '../../../utils/helpers';
import { calculateSpringStep, handleCanDismiss } from './utils'; import { calculateSpringStep, handleCanDismiss } from './utils';

View File

@ -1,4 +1,4 @@
import { Animation } from '../../../interface'; import type { Animation } from '../../../interface';
export const handleCanDismiss = async ( export const handleCanDismiss = async (
el: HTMLIonModalElement, el: HTMLIonModalElement,

View File

@ -1,6 +1,6 @@
import { JSXBase } from '@stencil/core/internal'; import type { JSXBase } from '@stencil/core/internal';
import { AnimationBuilder, ComponentProps, ComponentRef, FrameworkDelegate, Mode } from '../../interface'; import type { AnimationBuilder, ComponentProps, ComponentRef, FrameworkDelegate, Mode } from '../../interface';
export interface ModalOptions<T extends ComponentRef = ComponentRef> { export interface ModalOptions<T extends ComponentRef = ComponentRef> {
component: T; component: T;
@ -33,7 +33,7 @@ export interface ModalAnimationOptions {
backdropBreakpoint?: number; backdropBreakpoint?: number;
} }
export interface ModalAttributes extends JSXBase.HTMLAttributes<HTMLElement> { } export type ModalAttributes = JSXBase.HTMLAttributes<HTMLElement>
export interface ModalBreakpointChangeEventDetail { export interface ModalBreakpointChangeEventDetail {
breakpoint: number; breakpoint: number;

View File

@ -1,9 +1,10 @@
import { Component, ComponentInterface, Element, Event, EventEmitter, Host, Method, Prop, State, Watch, h, writeTask } from '@stencil/core'; import type { ComponentInterface, EventEmitter} from '@stencil/core';
import { Component, Element, Event, Host, Method, Prop, State, Watch, h, writeTask } from '@stencil/core';
import { printIonWarning } from '@utils/logging'; import { printIonWarning } from '@utils/logging';
import { config } from '../../global/config'; import { config } from '../../global/config';
import { getIonMode } from '../../global/ionic-global'; import { getIonMode } from '../../global/ionic-global';
import { Animation, AnimationBuilder, ComponentProps, ComponentRef, FrameworkDelegate, Gesture, ModalAttributes, ModalBreakpointChangeEventDetail, OverlayEventDetail, OverlayInterface } from '../../interface'; import type { Animation, AnimationBuilder, ComponentProps, ComponentRef, FrameworkDelegate, Gesture, ModalAttributes, ModalBreakpointChangeEventDetail, OverlayEventDetail, OverlayInterface } from '../../interface';
import { CoreDelegate, attachComponent, detachComponent } from '../../utils/framework-delegate'; import { CoreDelegate, attachComponent, detachComponent } from '../../utils/framework-delegate';
import { raf } from '../../utils/helpers'; import { raf } from '../../utils/helpers';
import { KEYBOARD_DID_OPEN } from '../../utils/keyboard/keyboard'; import { KEYBOARD_DID_OPEN } from '../../utils/keyboard/keyboard';
@ -15,7 +16,8 @@ import { iosEnterAnimation } from './animations/ios.enter';
import { iosLeaveAnimation } from './animations/ios.leave'; import { iosLeaveAnimation } from './animations/ios.leave';
import { mdEnterAnimation } from './animations/md.enter'; import { mdEnterAnimation } from './animations/md.enter';
import { mdLeaveAnimation } from './animations/md.leave'; import { mdLeaveAnimation } from './animations/md.leave';
import { MoveSheetToBreakpointOptions, createSheetGesture } from './gestures/sheet'; import type { MoveSheetToBreakpointOptions} from './gestures/sheet';
import { createSheetGesture } from './gestures/sheet';
import { createSwipeToCloseGesture } from './gestures/swipe-to-close'; import { createSwipeToCloseGesture } from './gestures/swipe-to-close';
/** /**

View File

@ -1,10 +1,11 @@
import { openModal, testModal } from '../test.utils';
import { newE2EPage } from '@stencil/core/testing'; import { newE2EPage } from '@stencil/core/testing';
import { openModal, testModal } from '../test.utils';
const DIRECTORY = 'basic'; const DIRECTORY = 'basic';
const getActiveElementText = async (page) => { const getActiveElementText = async (page) => {
const activeElement = await page.evaluateHandle(() => document.activeElement); const activeElement = await page.evaluateHandle(() => document.activeElement);
return await page.evaluate(el => el && el.textContent, activeElement); return await page.evaluate(el => el?.textContent, activeElement);
} }
test('modal: focus trap', async () => { test('modal: focus trap', async () => {
@ -14,7 +15,7 @@ test('modal: focus trap', async () => {
await page.click('#basic-modal'); await page.click('#basic-modal');
await page.waitForSelector('#basic-modal'); await page.waitForSelector('#basic-modal');
let modal = await page.find('ion-modal'); const modal = await page.find('ion-modal');
expect(modal).not.toBe(null); expect(modal).not.toBe(null);
await ionModalDidPresent.next(); await ionModalDidPresent.next();
@ -45,7 +46,7 @@ test('modal: return focus', async () => {
await page.click('#basic-modal'); await page.click('#basic-modal');
await page.waitForSelector('#basic-modal'); await page.waitForSelector('#basic-modal');
let modal = await page.find('ion-modal'); const modal = await page.find('ion-modal');
expect(modal).not.toBe(null); expect(modal).not.toBe(null);
await ionModalDidPresent.next() await ionModalDidPresent.next()
@ -75,12 +76,12 @@ test('modal: htmlAttributes', async () => {
await page.click('#basic-modal'); await page.click('#basic-modal');
await page.waitForSelector('#basic-modal'); await page.waitForSelector('#basic-modal');
let alert = await page.find('ion-modal'); const alert = await page.find('ion-modal');
expect(alert).not.toBe(null); expect(alert).not.toBe(null);
await alert.waitForVisible(); await alert.waitForVisible();
const attribute = await page.evaluate((el) => document.querySelector('ion-modal').getAttribute('data-testid')); const attribute = await page.evaluate(() => document.querySelector('ion-modal').getAttribute('data-testid'));
expect(attribute).toEqual('basic-modal'); expect(attribute).toEqual('basic-modal');
}); });

View File

@ -332,7 +332,6 @@ describe('modal - canDismiss handler', () => {
it('should not dismiss on swipe when not attempting to close', async () => { it('should not dismiss on swipe when not attempting to close', async () => {
const ionModalDidPresent = await page.spyOnEvent('ionModalDidPresent'); const ionModalDidPresent = await page.spyOnEvent('ionModalDidPresent');
const ionHandlerDone = await page.spyOnEvent('ionHandlerDone');
const screenshotCompares = []; const screenshotCompares = [];
await page.click('#radio-promise-true'); await page.click('#radio-promise-true');

View File

@ -1,8 +1,9 @@
import { E2EElement, E2EPage, newE2EPage } from '@stencil/core/testing'; import type { E2EElement, E2EPage} from '@stencil/core/testing';
import { openModal, testModal } from '../test.utils'; import { newE2EPage } from '@stencil/core/testing';
import { getActiveElement, getActiveElementParent, dragElementBy } from '@utils/test'; import { getActiveElement, getActiveElementParent, dragElementBy } from '@utils/test';
import { testModal } from '../test.utils'; import { openModal, testModal , testModal } from '../test.utils';
const DIRECTORY = 'sheet'; const DIRECTORY = 'sheet';

View File

@ -1,5 +1,5 @@
import { E2EPage, newE2EPage } from '@stencil/core/testing'; import type { E2EPage} from '@stencil/core/testing';
import { newE2EPage } from '@stencil/core/testing';
import { generateE2EUrl } from '@utils/test'; import { generateE2EUrl } from '@utils/test';
export const openModal = async ( export const openModal = async (

View File

@ -1,8 +1,8 @@
import { findClosestIonContent, getScrollElement } from '@utils/content';
import type { ComponentInterface, EventEmitter } from '@stencil/core'; import type { ComponentInterface, EventEmitter } from '@stencil/core';
import { Component, Element, Event, Host, Method, Prop, State, Watch, h } from '@stencil/core'; import { Component, Element, Event, Host, Method, Prop, State, Watch, h } from '@stencil/core';
import { findClosestIonContent, getScrollElement } from '@utils/content';
import { getIonMode } from '../../global/ionic-global'; import { getIonMode } from '../../global/ionic-global';
import type { Gesture, GestureDetail, ItemReorderEventDetail } from '../../interface'; import type { Gesture, GestureDetail, ItemReorderEventDetail } from '../../interface';

View File

@ -1,7 +1,7 @@
import type { E2EPage } from '@stencil/core/testing'; import type { E2EPage } from '@stencil/core/testing';
import { newE2EPage } from '@stencil/core/testing'; import { newE2EPage } from '@stencil/core/testing';
import { getElementProperty, queryDeep } from '../../../../utils/test/utils'; import { getElementProperty } from '../../../../utils/test/utils';
import { moveReorderItem } from '../test.utils'; import { moveReorderItem } from '../test.utils';
it('reorder: custom scroll target', async () => { it('reorder: custom scroll target', async () => {

View File

@ -5,12 +5,12 @@ describe('Content Utils', () => {
describe('getScrollElement', () => { describe('getScrollElement', () => {
it('should return the scroll element for ion-content', async () => { it('should return the scroll element for ion-content', async () => {
const res = await getScrollElement(<any>{ const res = await getScrollElement({
tagName: 'ION-CONTENT', tagName: 'ION-CONTENT',
getScrollElement: () => Promise.resolve({ getScrollElement: () => Promise.resolve({
tagName: 'my-scroll-element' tagName: 'my-scroll-element'
}) })
}); } as any);
expect(res).toStrictEqual({ expect(res).toStrictEqual({
tagName: 'my-scroll-element' tagName: 'my-scroll-element'
@ -24,9 +24,9 @@ describe('Content Utils', () => {
it('should query the ion-content element', () => { it('should query the ion-content element', () => {
const querySelectorMock = jest.fn(); const querySelectorMock = jest.fn();
findIonContent(<any>{ findIonContent({
querySelector: querySelectorMock querySelector: querySelectorMock
}); } as any);
expect(querySelectorMock).toHaveBeenCalledWith('ion-content, .ion-content-scroll-host'); expect(querySelectorMock).toHaveBeenCalledWith('ion-content, .ion-content-scroll-host');
}); });
@ -38,9 +38,9 @@ describe('Content Utils', () => {
it('should query the closest ion-content', () => { it('should query the closest ion-content', () => {
const closestMock = jest.fn(); const closestMock = jest.fn();
findClosestIonContent(<any>{ findClosestIonContent({
closest: closestMock closest: closestMock
}); } as any);
expect(closestMock).toHaveBeenCalledWith('ion-content, .ion-content-scroll-host'); expect(closestMock).toHaveBeenCalledWith('ion-content, .ion-content-scroll-host');
}); });
@ -53,10 +53,10 @@ describe('Content Utils', () => {
it('should call scrollToTop when the tag name is ion-content', () => { it('should call scrollToTop when the tag name is ion-content', () => {
const scrollToTopMock = jest.fn(); const scrollToTopMock = jest.fn();
scrollToTop(<any>{ scrollToTop({
tagName: 'ION-CONTENT', tagName: 'ION-CONTENT',
scrollToTop: scrollToTopMock scrollToTop: scrollToTopMock
}, 0); } as any, 0);
expect(scrollToTopMock).toHaveBeenCalledWith(0); expect(scrollToTopMock).toHaveBeenCalledWith(0);
}); });
@ -64,10 +64,10 @@ describe('Content Utils', () => {
it('should call the element scrollTo when the tag name is not ion-content', async () => { it('should call the element scrollTo when the tag name is not ion-content', async () => {
const scrollToMock = jest.fn(); const scrollToMock = jest.fn();
await scrollToTop(<any>{ await scrollToTop({
tagName: 'DIV', tagName: 'DIV',
scrollTo: scrollToMock scrollTo: scrollToMock
}, 0); } as any, 0);
expect(scrollToMock).toHaveBeenCalledWith({ expect(scrollToMock).toHaveBeenCalledWith({
top: 0, top: 0,
@ -83,10 +83,10 @@ describe('Content Utils', () => {
it('should smooth scroll ion-content', () => { it('should smooth scroll ion-content', () => {
const scrollToTopMock = jest.fn(); const scrollToTopMock = jest.fn();
scrollToTop(<any>{ scrollToTop({
tagName: 'ION-CONTENT', tagName: 'ION-CONTENT',
scrollToTop: scrollToTopMock scrollToTop: scrollToTopMock
}, 300); } as any, 300);
expect(scrollToTopMock).toHaveBeenCalledWith(300); expect(scrollToTopMock).toHaveBeenCalledWith(300);
}); });
@ -94,10 +94,10 @@ describe('Content Utils', () => {
it('should smooth scroll the element', async () => { it('should smooth scroll the element', async () => {
const scrollToMock = jest.fn(); const scrollToMock = jest.fn();
await scrollToTop(<any>{ await scrollToTop({
tagName: 'DIV', tagName: 'DIV',
scrollTo: scrollToMock scrollTo: scrollToMock
}, 300); } as any, 300);
expect(scrollToMock).toHaveBeenCalledWith({ expect(scrollToMock).toHaveBeenCalledWith({
top: 0, top: 0,
@ -117,10 +117,10 @@ describe('Content Utils', () => {
it('should call scrollByPoint when the tag name is ion-content', async () => { it('should call scrollByPoint when the tag name is ion-content', async () => {
const scrollByPointMock = jest.fn(); const scrollByPointMock = jest.fn();
await scrollByPoint(<any>{ await scrollByPoint({
tagName: 'ION-CONTENT', tagName: 'ION-CONTENT',
scrollByPoint: scrollByPointMock scrollByPoint: scrollByPointMock
}, 10, 15, 0); } as any, 10, 15, 0);
expect(scrollByPointMock).toHaveBeenCalledWith(10, 15, 0); expect(scrollByPointMock).toHaveBeenCalledWith(10, 15, 0);
}); });
@ -128,10 +128,10 @@ describe('Content Utils', () => {
it('should call the element scrollBy when the tag name is not ion-content', async () => { it('should call the element scrollBy when the tag name is not ion-content', async () => {
const scrollByMock = jest.fn(); const scrollByMock = jest.fn();
await scrollByPoint(<any>{ await scrollByPoint({
tagName: 'DIV', tagName: 'DIV',
scrollBy: scrollByMock scrollBy: scrollByMock
}, 10, 15, 0); } as any, 10, 15, 0);
expect(scrollByMock).toHaveBeenCalledWith({ expect(scrollByMock).toHaveBeenCalledWith({
top: 15, top: 15,
@ -147,10 +147,10 @@ describe('Content Utils', () => {
it('should smooth scroll ion-content', async () => { it('should smooth scroll ion-content', async () => {
const scrollByPointMock = jest.fn(); const scrollByPointMock = jest.fn();
await scrollByPoint(<any>{ await scrollByPoint({
tagName: 'ION-CONTENT', tagName: 'ION-CONTENT',
scrollByPoint: scrollByPointMock scrollByPoint: scrollByPointMock
}, 10, 15, 300); } as any, 10, 15, 300);
expect(scrollByPointMock).toHaveBeenCalledWith(10, 15, 300); expect(scrollByPointMock).toHaveBeenCalledWith(10, 15, 300);
}); });
@ -158,10 +158,10 @@ describe('Content Utils', () => {
it('should smooth scroll the element', async () => { it('should smooth scroll the element', async () => {
const scrollByMock = jest.fn(); const scrollByMock = jest.fn();
await scrollByPoint(<any>{ await scrollByPoint({
tagName: 'DIV', tagName: 'DIV',
scrollBy: scrollByMock scrollBy: scrollByMock
}, 10, 15, 300); } as any, 10, 15, 300);
expect(scrollByMock).toHaveBeenCalledWith({ expect(scrollByMock).toHaveBeenCalledWith({
top: 15, top: 15,
@ -177,9 +177,9 @@ describe('Content Utils', () => {
it('printIonContentErrorMsg should display "<my-el> must be used inside ion-content."', () => { it('printIonContentErrorMsg should display "<my-el> must be used inside ion-content."', () => {
const consoleErrorMock = jest.spyOn(console, 'error').mockImplementation(); const consoleErrorMock = jest.spyOn(console, 'error').mockImplementation();
printIonContentErrorMsg(<any>{ printIonContentErrorMsg({
tagName: 'MY-EL' tagName: 'MY-EL'
}); } as any);
expect(consoleErrorMock).toHaveBeenCalledWith('<my-el> must be used inside ion-content.'); expect(consoleErrorMock).toHaveBeenCalledWith('<my-el> must be used inside ion-content.');