style: enable eslint rule semi

pull/566/head
Shahar Or (mightyiam) 5 years ago committed by Shahar Dawn Or
parent 4d33de409a
commit 320c255975

@ -27,6 +27,7 @@ module.exports = {
'no-unused-expressions': 'off',
'no-unused-vars': 'off',
eqeqeq: 'off',
semi: 'off'
'@typescript-eslint/semi': ['error', 'always'],
semi: ['error', 'always'],
}
}

@ -61,4 +61,4 @@ module.exports = function (config) {
singleRun: !watch && !live,
concurrency: ci ? 1 : Infinity,
});
}
};

@ -4,7 +4,7 @@ import * as is from './is';
export type VNodes = VNode[];
export type VNodeChildElement = VNode | string | number | undefined | null;
export type ArrayOrElement<T> = T | T[];
export type VNodeChildren = ArrayOrElement<VNodeChildElement>
export type VNodeChildren = ArrayOrElement<VNodeChildElement>;
function addNS (data: any, children: VNodes | undefined, sel: string | undefined): void {
data.ns = 'http://www.w3.org/2000/svg';

@ -3,7 +3,7 @@ import { h, ArrayOrElement } from './h';
// for conditional rendering we support boolean child element e.g cond && <tag />
export type JsxVNodeChild = VNode | string | number | boolean | undefined | null;
export type JsxVNodeChildren = ArrayOrElement<JsxVNodeChild>
export type JsxVNodeChildren = ArrayOrElement<JsxVNodeChild>;
export type FunctionComponent = (props: {[prop: string]: any} | null, children?: VNode[]) => VNode;

@ -9,7 +9,7 @@ declare global {
}
}
export type Attrs = Record<string, string | number | boolean>
export type Attrs = Record<string, string | number | boolean>;
const xlinkNS = 'http://www.w3.org/1999/xlink';
const xmlNS = 'http://www.w3.org/XML/1998/namespace';

@ -1,7 +1,7 @@
import { VNode, VNodeData } from '../vnode';
import { Module } from './module';
export type Classes = Record<string, boolean>
export type Classes = Record<string, boolean>;
function updateClass (oldVnode: VNode, vnode: VNode): void {
var cur: any;

@ -45,7 +45,7 @@ function handleEvent (event: Event, vnode: VNode) {
function createListener () {
return function handler (event: Event) {
handleEvent(event, (handler as any).vnode);
}
};
}
function updateEventListeners (oldVnode: VNode, vnode?: VNode): void {

@ -1,7 +1,7 @@
import { VNode, VNodeData } from '../vnode';
import { Module } from './module';
export type Hero = { id: string }
export type Hero = { id: string };
var raf = (typeof window !== 'undefined' && window.requestAnimationFrame) || setTimeout;
var nextFrame = function (fn: any) {

@ -4,7 +4,7 @@ import { Module } from './module';
export type VNodeStyle = Record<string, string> & {
delayed?: Record<string, string>
remove?: Record<string, string>
}
};
// Bindig `requestAnimationFrame` like this fixes a bug in IE/Edge. See #360 and #409.
var raf = (typeof window !== 'undefined' && (window.requestAnimationFrame).bind(window)) || setTimeout;

@ -29,7 +29,7 @@ type KeyToIndexMap = {[key: string]: number};
type ArraysOf<T> = {
[K in keyof T]: Array<T[K]>;
}
};
type ModuleHooks = ArraysOf<Module>;

@ -1,8 +1,8 @@
import { assert } from 'chai'
import { init } from '../snabbdom'
import { assert } from 'chai';
import { init } from '../snabbdom';
import { RemoveHook } from '../hooks';
import attachTo from '../helpers/attachto'
import h from '../h'
import attachTo from '../helpers/attachto';
import h from '../h';
var patch = init([]);
@ -82,7 +82,7 @@ describe('attachTo', function () {
assert.strictEqual(elm.tagName, 'DIV');
assert.strictEqual(elm.innerHTML, 'First text');
cb();
}
};
var vnode1 = h('div', [
h('div#wrapper', [
h('div', 'Some element'),

@ -1,7 +1,7 @@
import { assert } from 'chai'
import { init } from '../snabbdom'
import attributesModule from '../modules/attributes'
import h from '../h'
import { assert } from 'chai';
import { init } from '../snabbdom';
import attributesModule from '../modules/attributes';
import h from '../h';
var patch = init([
attributesModule

@ -1,17 +1,17 @@
import { assert } from 'chai'
import shuffle from 'lodash.shuffle'
import { assert } from 'chai';
import shuffle from 'lodash.shuffle';
import { init } from '../snabbdom'
import classModule from '../modules/class'
import propsModule from '../modules/props'
import eventListenersModule from '../modules/eventlisteners'
import h from '../h'
import toVNode from '../tovnode'
import vnode, { VNode } from '../vnode'
import htmlDomApi from '../htmldomapi'
import { CreateHook, InsertHook, PrePatchHook, RemoveHook, InitHook, DestroyHook, UpdateHook } from '../hooks'
import { init } from '../snabbdom';
import classModule from '../modules/class';
import propsModule from '../modules/props';
import eventListenersModule from '../modules/eventlisteners';
import h from '../h';
import toVNode from '../tovnode';
import vnode, { VNode } from '../vnode';
import htmlDomApi from '../htmldomapi';
import { CreateHook, InsertHook, PrePatchHook, RemoveHook, InitHook, DestroyHook, UpdateHook } from '../hooks';
const hasSvgClassList = 'classList' in SVGElement.prototype
const hasSvgClassList = 'classList' in SVGElement.prototype;
var patch = init([
classModule,
@ -49,25 +49,25 @@ describe('snabbdom', function () {
it('can create vnode with children', function () {
var vnode = h('div', [h('span#hello'), h('b.world')]);
assert.strictEqual(vnode.sel, 'div');
const children = vnode.children as [VNode, VNode]
const children = vnode.children as [VNode, VNode];
assert.strictEqual(children[0].sel, 'span#hello');
assert.strictEqual(children[1].sel, 'b.world');
});
it('can create vnode with one child vnode', function () {
var vnode = h('div', h('span#hello'));
assert.strictEqual(vnode.sel, 'div');
const children = vnode.children as [VNode]
const children = vnode.children as [VNode];
assert.strictEqual(children[0].sel, 'span#hello');
});
it('can create vnode with props and one child vnode', function () {
var vnode = h('div', {}, h('span#hello'));
assert.strictEqual(vnode.sel, 'div');
const children = vnode.children as [VNode]
const children = vnode.children as [VNode];
assert.strictEqual(children[0].sel, 'span#hello');
});
it('can create vnode with text content', function () {
var vnode = h('a', ['I am a string']);
const children = vnode.children as [VNode]
const children = vnode.children as [VNode];
assert.strictEqual(children[0].text, 'I am a string');
});
it('can create vnode with text content in string', function () {
@ -82,7 +82,7 @@ describe('snabbdom', function () {
var vnode = h('a', null);
assert.deepEqual(vnode.data, {});
vnode = h('a', null, ['I am a string']);
const children = vnode.children as [VNode]
const children = vnode.children as [VNode];
assert.strictEqual(children[0].text, 'I am a string');
});
it('can create vnode for comment', function () {
@ -148,7 +148,7 @@ describe('snabbdom', function () {
});
it('receives classes in selector when namespaced', function () {
if (!hasSvgClassList) {
this.skip()
this.skip();
} else {
elm = patch(vnode0,
h('svg', [
@ -162,7 +162,7 @@ describe('snabbdom', function () {
});
it('receives classes in class property when namespaced', function () {
if (!hasSvgClassList) {
this.skip()
this.skip();
} else {
elm = patch(vnode0,
h('svg', [
@ -199,9 +199,9 @@ describe('snabbdom', function () {
if (typeof frame.srcdoc !== 'undefined') {
frame.srcdoc = '<div>Thing 1</div>';
frame.onload = function () {
const div0 = frame.contentDocument!.body.querySelector('div') as HTMLDivElement
const div0 = frame.contentDocument!.body.querySelector('div') as HTMLDivElement;
patch(div0, h('div', 'Thing 2'));
const div1 = frame.contentDocument!.body.querySelector('div') as HTMLDivElement
const div1 = frame.contentDocument!.body.querySelector('div') as HTMLDivElement;
assert.strictEqual(div1.textContent, 'Thing 2');
frame.remove();
done();
@ -295,7 +295,7 @@ describe('snabbdom', function () {
describe('using toVNode()', function () {
it('can remove previous children of the root element', function () {
var h2 = document.createElement('h2');
h2.textContent = 'Hello'
h2.textContent = 'Hello';
var prevElm = document.createElement('div');
prevElm.id = 'id';
prevElm.className = 'class';
@ -328,7 +328,7 @@ describe('snabbdom', function () {
});
it('can remove some children of the root element', function () {
var h2 = document.createElement('h2');
h2.textContent = 'Hello'
h2.textContent = 'Hello';
var prevElm = document.createElement('div');
prevElm.id = 'id';
prevElm.className = 'class';
@ -350,7 +350,7 @@ describe('snabbdom', function () {
});
it('can remove text elements', function () {
var h2 = document.createElement('h2');
h2.textContent = 'Hello'
h2.textContent = 'Hello';
var prevElm = document.createElement('div');
prevElm.id = 'id';
prevElm.className = 'class';
@ -385,7 +385,7 @@ describe('snabbdom', function () {
var vnode = toVNode(elm, domApi);
assert.strictEqual(vnode.sel, 'x-div#id.class.other');
assert.deepEqual(vnode.data, { attrs: { data: 'value' } });
const children = vnode.children as [VNode, VNode]
const children = vnode.children as [VNode, VNode];
assert.strictEqual(children[0].sel, 'x-h2#hx');
assert.deepEqual(children[0].data, { attrs: { 'data-env': 'xyz' } });
assert.strictEqual(children[1].text, 'Foobar');
@ -637,7 +637,7 @@ describe('snabbdom', function () {
elm = patch(vnode1, vnode2).elm as HTMLSpanElement;
for (i = 0; i < elms; ++i) {
assert.strictEqual(elm.children[i].innerHTML, shufArr[i].toString());
const opacity = (elm.children[i] as HTMLSpanElement).style.opacity as string
const opacity = (elm.children[i] as HTMLSpanElement).style.opacity as string;
assert.strictEqual(opacities[i].indexOf(opacity), 0);
}
}
@ -828,7 +828,7 @@ describe('snabbdom', function () {
assert.strictEqual((vnode.elm as HTMLDivElement).children.length, 2);
assert.strictEqual(vnode.elm!.parentNode, null);
result.push(vnode);
}
};
var vnode1 = h('div', [
h('span', 'First sibling'),
h('div', { hook: { create: cb } }, [
@ -847,7 +847,7 @@ describe('snabbdom', function () {
assert.strictEqual((vnode.elm as HTMLDivElement).children.length, 2);
assert.strictEqual(vnode.elm!.parentNode!.children.length, 3);
result.push(vnode);
}
};
var vnode1 = h('div', [
h('span', 'First sibling'),
h('div', { hook: { insert: cb } }, [
@ -865,7 +865,7 @@ describe('snabbdom', function () {
assert.strictEqual(oldVnode, vnode1.children![1]);
assert.strictEqual(vnode, vnode2.children![1]);
result.push(vnode);
}
};
var vnode1 = h('div', [
h('span', 'First sibling'),
h('div', { hook: { prepatch: cb } }, [
@ -888,11 +888,11 @@ describe('snabbdom', function () {
var pre = 0;
var post = 0;
function preCb () {
pre++
pre++;
}
function postCb () {
assert.strictEqual(pre, post + 1);
post++
post++;
}
var vnode1 = h('div', [
h('span', 'First sibling'),
@ -953,7 +953,7 @@ describe('snabbdom', function () {
result.push(vnode);
rm();
assert.strictEqual(parent.children.length, 1);
}
};
var vnode1 = h('div', [
h('span', 'First sibling'),
h('div', { hook: { remove: cb } }, [
@ -978,7 +978,7 @@ describe('snabbdom', function () {
h('span', 'Child 1'),
]),
]);
var vnode2 = h('div', 'Text node')
var vnode2 = h('div', 'Text node');
patch(vnode0, vnode1);
patch(vnode1, vnode2);
assert.strictEqual(calls, 1);
@ -988,11 +988,11 @@ describe('snabbdom', function () {
const init: InitHook = (vnode) => {
assert.strictEqual(vnode, vnode2);
count += 1;
}
};
const prepatch: PrePatchHook = (oldVnode, vnode) => {
assert.strictEqual(vnode, vnode1);
count += 1;
}
};
var vnode1 = h('div', { hook: { init: init, prepatch: prepatch } });
patch(vnode0, vnode1);
assert.strictEqual(1, count);
@ -1033,7 +1033,7 @@ describe('snabbdom', function () {
const cb: RemoveHook = (vnode, rm) => {
result.push(vnode);
rm();
}
};
var vnode1 = h('div', { hook: { remove: cb } }, [
h('b', 'Child 1'),
h('i', 'Child 2'),
@ -1062,7 +1062,7 @@ describe('snabbdom', function () {
var result = [];
const cb: DestroyHook = (vnode) => {
result.push(vnode);
}
};
var vnode1 = h('div', [
h('span', 'First sibling'),
h('div', [
@ -1148,7 +1148,7 @@ describe('snabbdom', function () {
var result = [];
const cb: UpdateHook = (vnode) => {
result.push(vnode);
}
};
var vnode1 = h('div', [
h('span', { hook: { update: cb } }, 'Hello'),
h('span', 'there'),

@ -1,8 +1,8 @@
import { assert } from 'chai'
import { assert } from 'chai';
import datasetModule from '../modules/dataset'
import { init } from '../snabbdom'
import h from '../h'
import datasetModule from '../modules/dataset';
import { init } from '../snabbdom';
import h from '../h';
var patch = init([
datasetModule

@ -1,9 +1,9 @@
import { assert } from 'chai'
import { assert } from 'chai';
import { VNode } from '../vnode';
import { init } from '../snabbdom'
import eventListenersModule from '../modules/eventlisteners'
import h from '../h'
import { init } from '../snabbdom';
import eventListenersModule from '../modules/eventlisteners';
import h from '../h';
var patch = init([
eventListenersModule

@ -1,8 +1,8 @@
import { assert } from 'chai'
import { assert } from 'chai';
import { init } from '../snabbdom'
import h from '../h'
import attributesModule from '../modules/attributes'
import { init } from '../snabbdom';
import h from '../h';
import attributesModule from '../modules/attributes';
var patch = init([
attributesModule
@ -52,4 +52,4 @@ describe('svg', function () {
assert.strictEqual(result.getAttributeNS(xmlNS, 'lang'), testAttrValue);
assert.strictEqual(result.getAttribute('xml:lang'), testAttrValue);
});
})
});

@ -182,7 +182,7 @@ describe('snabbdom', function () {
});
it('works with a function component', function () {
const Part = ({ part }: {part: string}) => <span>{part}</span>
const Part = ({ part }: {part: string}) => <span>{part}</span>;
const vnode = (
<div>
<a attrs={{ href: 'https://github.com/snabbdom/snabbdom' }}>Snabbdom</a>
@ -257,6 +257,6 @@ describe('snabbdom', function () {
text: undefined,
key: undefined
});
})
});
});
});

@ -1,17 +1,17 @@
import { assert } from 'chai'
import { assert } from 'chai';
import { init } from '../snabbdom'
import styleModule from '../modules/style'
import h from '../h'
import toVNode from '../tovnode'
import { init } from '../snabbdom';
import styleModule from '../modules/style';
import h from '../h';
import toVNode from '../tovnode';
var patch = init([
styleModule
]);
const featureDiscoveryElm = document.createElement('div')
featureDiscoveryElm.style.setProperty('--foo', 'foo')
const hasCssVariables = featureDiscoveryElm.style.getPropertyValue('--foo') === 'foo'
const featureDiscoveryElm = document.createElement('div');
featureDiscoveryElm.style.setProperty('--foo', 'foo');
const hasCssVariables = featureDiscoveryElm.style.getPropertyValue('--foo') === 'foo';
describe('style', function () {
var elm: any, vnode0: any;
@ -72,7 +72,7 @@ describe('style', function () {
});
it('updates css variables', function () {
if (!hasCssVariables) {
this.skip()
this.skip();
} else {
var vnode1 = h('div', { style: { '--myVar': 1 as any } });
var vnode2 = h('div', { style: { '--myVar': 2 as any } });
@ -87,7 +87,7 @@ describe('style', function () {
});
it('explicialy removes css variables', function () {
if (!hasCssVariables) {
this.skip()
this.skip();
} else {
var vnode1 = h('i', { style: { '--myVar': 1 as any } });
var vnode2 = h('i', { style: { '--myVar': '' } });
@ -102,7 +102,7 @@ describe('style', function () {
});
it('implicially removes css variables from element', function () {
if (!hasCssVariables) {
this.skip()
this.skip();
} else {
var vnode1 = h('div', [h('i', { style: { '--myVar': 1 as any } })]);
var vnode2 = h('div', [h('i')]);
@ -128,11 +128,11 @@ describe('style', function () {
requestAnimationFrame(() => {
requestAnimationFrame(() => {
assert.strictEqual(elm.style.fontSize, '20px');
done()
})
})
})
})
done();
});
});
});
});
});
it('applies tranform as transition on remove', function (done) {
var btn = h('button', {

@ -1,8 +1,8 @@
import { assert } from 'chai'
import { assert } from 'chai';
import { init } from '../snabbdom'
import h from '../h'
import thunk from '../thunk'
import { init } from '../snabbdom';
import h from '../h';
import thunk from '../thunk';
import { VNode } from '../vnode';
var patch = init([

@ -1,12 +1,12 @@
import { Hooks } from './hooks';
import { AttachData } from './helpers/attachto'
import { VNodeStyle } from './modules/style'
import { On } from './modules/eventlisteners'
import { Attrs } from './modules/attributes'
import { Classes } from './modules/class'
import { Props } from './modules/props'
import { Dataset } from './modules/dataset'
import { Hero } from './modules/hero'
import { AttachData } from './helpers/attachto';
import { VNodeStyle } from './modules/style';
import { On } from './modules/eventlisteners';
import { Attrs } from './modules/attributes';
import { Classes } from './modules/class';
import { Props } from './modules/props';
import { Dataset } from './modules/dataset';
import { Hero } from './modules/hero';
export type Key = string | number;

Loading…
Cancel
Save