From dcdde2e8696bb3378a91106f1ef7206d17e65590 Mon Sep 17 00:00:00 2001
From: "Shahar Or (mightyiam)" <mightyiampresence@gmail.com>
Date: Fri, 22 Nov 2019 15:02:26 +0700
Subject: [PATCH] style: @typescript-eslint/array-type

---
 .eslintrc.js         |  1 -
 src/h.ts             |  2 +-
 src/modules/style.ts |  2 +-
 src/snabbdom.ts      | 26 +++++++++++++-------------
 src/thunk.ts         |  6 +++---
 src/tovnode.ts       |  2 +-
 src/vnode.ts         |  2 +-
 7 files changed, 20 insertions(+), 21 deletions(-)

diff --git a/.eslintrc.js b/.eslintrc.js
index ab441a7..d4b958f 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -2,7 +2,6 @@ module.exports = {
   extends: 'standard-with-typescript',
   parserOptions: { project: [ './tsconfig.json', ] },
   rules: {
-    '@typescript-eslint/array-type': 'off',
     '@typescript-eslint/brace-style': 'off',
     '@typescript-eslint/consistent-type-assertions': 'off',
     '@typescript-eslint/consistent-type-definitions': 'off',
diff --git a/src/h.ts b/src/h.ts
index 9b9886c..ed4593e 100644
--- a/src/h.ts
+++ b/src/h.ts
@@ -1,5 +1,5 @@
 import {vnode, VNode, VNodeData} from './vnode';
-export type VNodes = Array<VNode>;
+export type VNodes = VNode[];
 export type VNodeChildElement = VNode | string | number | undefined | null;
 export type ArrayOrElement<T> = T | T[];
 export type VNodeChildren = ArrayOrElement<VNodeChildElement>
diff --git a/src/modules/style.ts b/src/modules/style.ts
index 9514913..33dc57f 100755
--- a/src/modules/style.ts
+++ b/src/modules/style.ts
@@ -73,7 +73,7 @@ function applyRemoveStyle(vnode: VNode, rm: () => void): void {
     reflowForced = true;
   }
   var name: string, elm = vnode.elm, i = 0, compStyle: CSSStyleDeclaration,
-      style = s.remove, amount = 0, applied: Array<string> = [];
+      style = s.remove, amount = 0, applied: string[] = [];
   for (name in style) {
     applied.push(name);
     (elm as any).style[name] = style[name];
diff --git a/src/snabbdom.ts b/src/snabbdom.ts
index a6f976b..a61be9f 100644
--- a/src/snabbdom.ts
+++ b/src/snabbdom.ts
@@ -8,7 +8,7 @@ import htmlDomApi, {DOMAPI} from './htmldomapi';
 function isUndef(s: any): boolean { return s === undefined; }
 function isDef(s: any): boolean { return s !== undefined; }
 
-type VNodeQueue = Array<VNode>;
+type VNodeQueue = VNode[];
 
 const emptyNode = vnode('', {}, [], undefined, undefined);
 
@@ -23,12 +23,12 @@ function isVnode(vnode: any): vnode is VNode {
 type KeyToIndexMap = {[key: string]: number};
 
 type ArraysOf<T> = {
-  [K in keyof T]: (T[K])[];
+  [K in keyof T]: Array<T[K]>;
 }
 
 type ModuleHooks = ArraysOf<Module>;
 
-function createKeyToOldIdx(children: Array<VNode>, beginIdx: number, endIdx: number): KeyToIndexMap {
+function createKeyToOldIdx(children: VNode[], beginIdx: number, endIdx: number): KeyToIndexMap {
   let i: number, map: KeyToIndexMap = {}, key: Key | undefined, ch;
   for (i = beginIdx; i <= endIdx; ++i) {
     ch = children[i];
@@ -40,7 +40,7 @@ function createKeyToOldIdx(children: Array<VNode>, beginIdx: number, endIdx: num
   return map;
 }
 
-const hooks: (keyof Module)[] = ['create', 'update', 'remove', 'destroy', 'pre', 'post'];
+const hooks: Array<keyof Module> = ['create', 'update', 'remove', 'destroy', 'pre', 'post'];
 
 export {h} from './h';
 export {thunk} from './thunk';
@@ -55,7 +55,7 @@ export function init(modules: Array<Partial<Module>>, domApi?: DOMAPI) {
     for (j = 0; j < modules.length; ++j) {
       const hook = modules[j][hooks[i]];
       if (hook !== undefined) {
-        (cbs[hooks[i]] as Array<any>).push(hook);
+        (cbs[hooks[i]] as any[]).push(hook);
       }
     }
   }
@@ -126,7 +126,7 @@ export function init(modules: Array<Partial<Module>>, domApi?: DOMAPI) {
   function addVnodes(
     parentElm: Node,
     before: Node | null,
-    vnodes: Array<VNode>,
+    vnodes: VNode[],
     startIdx: number,
     endIdx: number,
     insertedVnodeQueue: VNodeQueue
@@ -156,7 +156,7 @@ export function init(modules: Array<Partial<Module>>, domApi?: DOMAPI) {
   }
 
   function removeVnodes(parentElm: Node,
-                        vnodes: Array<VNode>,
+                        vnodes: VNode[],
                         startIdx: number,
                         endIdx: number): void {
     for (; startIdx <= endIdx; ++startIdx) {
@@ -180,8 +180,8 @@ export function init(modules: Array<Partial<Module>>, domApi?: DOMAPI) {
   }
 
   function updateChildren(parentElm: Node,
-                          oldCh: Array<VNode>,
-                          newCh: Array<VNode>,
+                          oldCh: VNode[],
+                          newCh: VNode[],
                           insertedVnodeQueue: VNodeQueue) {
     let oldStartIdx = 0, newStartIdx = 0;
     let oldEndIdx = oldCh.length - 1;
@@ -269,18 +269,18 @@ export function init(modules: Array<Partial<Module>>, domApi?: DOMAPI) {
     }
     if (isUndef(vnode.text)) {
       if (isDef(oldCh) && isDef(ch)) {
-        if (oldCh !== ch) updateChildren(elm, oldCh as Array<VNode>, ch as Array<VNode>, insertedVnodeQueue);
+        if (oldCh !== ch) updateChildren(elm, oldCh as VNode[], ch as VNode[], insertedVnodeQueue);
       } else if (isDef(ch)) {
         if (isDef(oldVnode.text)) api.setTextContent(elm, '');
-        addVnodes(elm, null, ch as Array<VNode>, 0, (ch as Array<VNode>).length - 1, insertedVnodeQueue);
+        addVnodes(elm, null, ch as VNode[], 0, (ch as VNode[]).length - 1, insertedVnodeQueue);
       } else if (isDef(oldCh)) {
-        removeVnodes(elm, oldCh as Array<VNode>, 0, (oldCh as Array<VNode>).length - 1);
+        removeVnodes(elm, oldCh as VNode[], 0, (oldCh as VNode[]).length - 1);
       } else if (isDef(oldVnode.text)) {
         api.setTextContent(elm, '');
       }
     } else if (oldVnode.text !== vnode.text) {
       if (isDef(oldCh)) {
-        removeVnodes(elm, oldCh as Array<VNode>, 0, (oldCh as Array<VNode>).length - 1);
+        removeVnodes(elm, oldCh as VNode[], 0, (oldCh as VNode[]).length - 1);
       }
       api.setTextContent(elm, vnode.text as string);
     }
diff --git a/src/thunk.ts b/src/thunk.ts
index 3ff05a7..1646fda 100644
--- a/src/thunk.ts
+++ b/src/thunk.ts
@@ -3,7 +3,7 @@ import {h} from './h';
 
 export interface ThunkData extends VNodeData {
   fn: () => VNode;
-  args: Array<any>;
+  args: any[];
 }
 
 export interface Thunk extends VNode {
@@ -11,8 +11,8 @@ export interface Thunk extends VNode {
 }
 
 export interface ThunkFn {
-  (sel: string, fn: Function, args: Array<any>): Thunk;
-  (sel: string, key: any, fn: Function, args: Array<any>): Thunk;
+  (sel: string, fn: Function, args: any[]): Thunk;
+  (sel: string, key: any, fn: Function, args: any[]): Thunk;
 }
 
 function copyToThunk(vnode: VNode, thunk: VNode): void {
diff --git a/src/tovnode.ts b/src/tovnode.ts
index 98e0564..67fef5d 100644
--- a/src/tovnode.ts
+++ b/src/tovnode.ts
@@ -10,7 +10,7 @@ export function toVNode(node: Node, domApi?: DOMAPI): VNode {
     const c = cn ? '.' + cn.split(' ').join('.') : '';
     const sel = api.tagName(node).toLowerCase() + id + c;
     const attrs: any = {};
-    const children: Array<VNode> = [];
+    const children: VNode[] = [];
     let name: string;
     let i: number, n: number;
     const elmAttrs = node.attributes;
diff --git a/src/vnode.ts b/src/vnode.ts
index 37512d9..1ebe7e7 100644
--- a/src/vnode.ts
+++ b/src/vnode.ts
@@ -32,7 +32,7 @@ export interface VNodeData {
   key?: Key;
   ns?: string; // for SVGs
   fn?: () => VNode; // for thunks
-  args?: Array<any>; // for thunks
+  args?: any[]; // for thunks
   [key: string]: any; // for any other 3rd party module
 }