style: enable eslint rule prefer-const

pull/566/head
Shahar Or (mightyiam) 5 years ago committed by Shahar Dawn Or
parent fe84111d66
commit b551d93f31

@ -21,7 +21,6 @@ module.exports = {
'no-unneeded-ternary': 'off',
'no-unused-expressions': 'off',
'no-unused-vars': 'off',
'prefer-const': 'off',
eqeqeq: 'off',
semi: 'off'
}

@ -10,7 +10,7 @@ function addNS (data: any, children: VNodes | undefined, sel: string | undefined
data.ns = 'http://www.w3.org/2000/svg';
if (sel !== 'foreignObject' && children !== undefined) {
for (let i = 0; i < children.length; ++i) {
let childData = children[i].data;
const childData = children[i].data;
if (childData !== undefined) {
addNS(childData, (children[i] as VNode).children as VNodes, children[i].sel);
}

@ -6,7 +6,7 @@ export type Dataset = Record<string, string>;
const CAPS_REGEX = /[A-Z]/g;
function updateDataset (oldVnode: VNode, vnode: VNode): void {
let elm: HTMLElement = vnode.elm as HTMLElement;
const elm: HTMLElement = vnode.elm as HTMLElement;
let oldDataset = (oldVnode.data as VNodeData).dataset;
let dataset = (vnode.data as VNodeData).dataset;
let key: string;

@ -46,7 +46,7 @@ function updateStyle (oldVnode: VNode, vnode: VNode): void {
for (name in style) {
cur = style[name];
if (name === 'delayed' && style.delayed) {
for (let name2 in style.delayed) {
for (const name2 in style.delayed) {
cur = style.delayed[name2];
if (!oldHasDel || cur !== (oldStyle.delayed as any)[name2]) {
setNextFrame((elm as any).style, name2, cur);

@ -52,7 +52,7 @@ export { thunk } from './thunk';
export function init (modules: Array<Partial<Module>>, domApi?: DOMAPI) {
let i: number;
let j: number;
let cbs = ({} as ModuleHooks);
const cbs = ({} as ModuleHooks);
const api: DOMAPI = domApi !== undefined ? domApi : htmlDomApi;
@ -91,8 +91,8 @@ export function init (modules: Array<Partial<Module>>, domApi?: DOMAPI) {
data = vnode.data;
}
}
let children = vnode.children;
let sel = vnode.sel;
const children = vnode.children;
const sel = vnode.sel;
if (sel === '!') {
if (isUndef(vnode.text)) {
vnode.text = '';
@ -173,7 +173,7 @@ export function init (modules: Array<Partial<Module>>, domApi?: DOMAPI) {
for (; startIdx <= endIdx; ++startIdx) {
let listeners: number;
let rm: () => void;
let ch = vnodes[startIdx];
const ch = vnodes[startIdx];
if (ch != null) {
if (isDef(ch.sel)) {
invokeDestroyHook(ch);
@ -271,8 +271,8 @@ export function init (modules: Array<Partial<Module>>, domApi?: DOMAPI) {
const hook = vnode.data?.hook;
hook?.prepatch?.(oldVnode, vnode);
const elm = vnode.elm = oldVnode.elm!;
let oldCh = oldVnode.children as VNode[];
let ch = vnode.children as VNode[];
const oldCh = oldVnode.children as VNode[];
const ch = vnode.children as VNode[];
if (oldVnode === vnode) return;
if (vnode.data !== undefined) {
for (let i = 0; i < cbs.update.length; ++i) cbs.update[i](oldVnode, vnode);

@ -33,8 +33,8 @@ function init (thunk: VNode): void {
function prepatch (oldVnode: VNode, thunk: VNode): void {
let i: number;
let old = oldVnode.data as VNodeData;
let cur = thunk.data as VNodeData;
const old = oldVnode.data as VNodeData;
const cur = thunk.data as VNodeData;
const oldArgs = old.args;
const args = cur.args;
if (old.fn !== cur.fn || (oldArgs as any).length !== (args as any).length) {

@ -41,7 +41,7 @@ export function vnode (sel: string | undefined,
children: Array<VNode | string> | undefined,
text: string | undefined,
elm: Element | Text | undefined): VNode {
let key = data === undefined ? undefined : data.key;
const key = data === undefined ? undefined : data.key;
return { sel, data, children, text, elm, key };
}

Loading…
Cancel
Save