chore(): update to ionic-rules/strict

This commit is contained in:
Manu Mtz.-Almeida
2018-07-29 23:10:26 +02:00
parent 7292fc7d38
commit c1b61d0fee
148 changed files with 354 additions and 407 deletions

View File

@ -2,7 +2,6 @@ import { HeaderFn, ItemHeightFn, VirtualNode } from '../../../interface';
import { CellType } from '../virtual-scroll-interface';
import { Range, calcCells, calcHeightIndex, getRange, getShouldUpdate, getViewport, positionForIndex, resizeBuffer, updateVDom } from '../virtual-scroll-utils';
describe('getViewport', () => {
it('should return viewport without margin', () => {
expect(getViewport(0, 100, 0)).toEqual({
@ -18,7 +17,6 @@ describe('getViewport', () => {
});
});
it('should return viewport with margin and scrollTop', () => {
expect(getViewport(150, 100, 150)).toEqual({
top: 0,
@ -34,7 +32,6 @@ describe('getViewport', () => {
});
});
describe('getRange', () => {
it('should return initial bounds without buffer', () => {
const heightBuffer = mockHeightBuffer(20, () => 10);
@ -146,7 +143,6 @@ describe('resizeBuffer', () => {
});
});
describe('calcCells', () => {
it('should calculate cells without headers and itemHeight', () => {
const items = ['0', 2, 'hola', { data: 'hello' }];
@ -501,7 +497,6 @@ describe('updateVDom', () => {
});
});
function mockVirtualScroll(
items: any[],
itemHeight?: ItemHeightFn,

View File

@ -1,4 +1,5 @@
import { Cell, HeaderFn, ItemHeightFn, ItemRenderFn, VirtualNode } from '../../interface';
import { CellType, NodeChange } from './virtual-scroll-interface';
export interface Viewport {
@ -26,7 +27,7 @@ export function updateVDom(dom: VirtualNode[], heightIndex: Uint32Array, cells:
for (let i = range.offset; i < end; i++) {
const cell = cells[i];
const node = dom.find((n) => n.d && n.cell === cell);
const node = dom.find(n => n.d && n.cell === cell);
if (node) {
const top = heightIndex[i];
if (top !== node.top) {
@ -40,7 +41,7 @@ export function updateVDom(dom: VirtualNode[], heightIndex: Uint32Array, cells:
}
// needs to append
const pool = dom.filter((n) => n.d);
const pool = dom.filter(n => n.d);
for (const cell of toMutate) {
const node = pool.find(n => n.d && n.cell.type === cell.type);
@ -61,14 +62,13 @@ export function updateVDom(dom: VirtualNode[], heightIndex: Uint32Array, cells:
}
}
dom
.filter((n) => n.d && n.top !== -9999)
.forEach((n) => {
.filter(n => n.d && n.top !== -9999)
.forEach(n => {
n.change = NodeChange.Position;
n.top = -9999;
});
}
export function doRender(
el: HTMLElement,
nodeRender: ItemRenderFn,
@ -162,7 +162,6 @@ export function getShouldUpdate(dirtyIndex: number, currentRange: Range, range:
);
}
export function findCellIndex(cells: Cell[], index: number): number {
if (index === 0) {
return 0;
@ -242,7 +241,6 @@ export function calcCells(
return cells;
}
export function calcHeightIndex(buf: Uint32Array, cells: Cell[], index: number): number {
let acum = buf[index];
for (; index < buf.length; index++) {
@ -252,7 +250,6 @@ export function calcHeightIndex(buf: Uint32Array, cells: Cell[], index: number):
return acum;
}
export function resizeBuffer(buf: Uint32Array | undefined, len: number) {
if (!buf) {
return new Uint32Array(len);

View File

@ -1,10 +1,10 @@
import { Component, Element, EventListenerEnable, Listen, Method, Prop, QueueApi, State, Watch } from '@stencil/core';
import { Cell, DomRenderFn, HeaderFn, ItemHeightFn, ItemRenderFn, VirtualNode } from '../../interface';
import { CellType } from './virtual-scroll-interface';
import { Range, calcCells, calcHeightIndex, doRender, findCellIndex, getRange, getShouldUpdate, getViewport, inplaceUpdate, positionForIndex, resizeBuffer, updateVDom } from './virtual-scroll-utils';
@Component({
tag: 'ion-virtual-scroll',
styleUrl: 'virtual-scroll.scss'
@ -318,7 +318,6 @@ export class VirtualScroll {
}
}
private calcCells() {
if (!this.items) {
return;
@ -381,7 +380,7 @@ export class VirtualScroll {
render() {
const renderItem = this.renderItem;
if (renderItem) {
return this.virtualDom.map((node) => {
return this.virtualDom.map(node => {
const item = this.renderVirtualNode(node) as any;
const classes = ['virtual-item'];
if (!item.vattrs) {