style: single quotes (#526)

pull/527/head
Shahar Dawn Or 5 years ago committed by GitHub
parent 431f95018e
commit ad3745bfe8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,7 +13,6 @@ module.exports = {
'@typescript-eslint/member-delimiter-style': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/quotes': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/strict-boolean-expressions': 'off',
'comma-dangle': 'off',
@ -31,7 +30,6 @@ module.exports = {
'prefer-const': 'off',
'quote-props': 'off',
eqeqeq: 'off',
quotes: 'off',
semi: 'off'
}
}

@ -14,23 +14,23 @@ var data = {
function gRotation () {
// console.log("gRotation: %s", data.degRotation);
return "rotate(" + data.degRotation + "deg)";
return 'rotate(' + data.degRotation + 'deg)';
}
function triangleClick (id) {
console.log("triangleClick: %s", id);
console.log('triangleClick: %s', id);
render();
}
function handleRotate (degs) {
data.degRotation += degs;
console.log("handleRotate: %s, %s", degs, data.degRotation);
console.log('handleRotate: %s, %s', degs, data.degRotation);
render();
}
function handleReset (degs) {
data.degRotation = degs;
console.log("handleReset: %s", degs);
console.log('handleReset: %s', degs);
render();
}
@ -39,36 +39,36 @@ function render () {
}
const hTriangle = (id, degRotation) =>
h("polygon#" + id, {
h('polygon#' + id, {
attrs: {
points: "-50,-88 0,-175 50,-88",
transform: "rotate(" + degRotation + ")",
"stroke-width": 3
points: '-50,-88 0,-175 50,-88',
transform: 'rotate(' + degRotation + ')',
'stroke-width': 3
},
on: { click: [triangleClick, id] }
});
const view = (data) =>
h("div.view", [
h("h1", "Snabbdom SVG Carousel"),
h("svg", { attrs: { width: 380, height: 380, viewBox: [-190, -190, 380, 380] } }, [
h("g#carousel",
{ style: { "-webkit-transform": gRotation(), transform: gRotation() } }, [
hTriangle("yellow", 0),
hTriangle("green", 60),
hTriangle("magenta", 120),
hTriangle("red", 180),
hTriangle("cyan", 240),
hTriangle("blue", 300)
h('div.view', [
h('h1', 'Snabbdom SVG Carousel'),
h('svg', { attrs: { width: 380, height: 380, viewBox: [-190, -190, 380, 380] } }, [
h('g#carousel',
{ style: { '-webkit-transform': gRotation(), transform: gRotation() } }, [
hTriangle('yellow', 0),
hTriangle('green', 60),
hTriangle('magenta', 120),
hTriangle('red', 180),
hTriangle('cyan', 240),
hTriangle('blue', 300)
])
]),
h("button", { on: { click: [handleRotate, 60] } }, "Rotate Clockwise"),
h("button", { on: { click: [handleRotate, -60] } }, "Rotate Anticlockwise"),
h("button", { on: { click: [handleReset, 0] } }, "Reset")
h('button', { on: { click: [handleRotate, 60] } }, 'Rotate Clockwise'),
h('button', { on: { click: [handleRotate, -60] } }, 'Rotate Anticlockwise'),
h('button', { on: { click: [handleReset, 0] } }, 'Reset')
]);
window.addEventListener("DOMContentLoaded", () => {
var container = document.getElementById("container");
window.addEventListener('DOMContentLoaded', () => {
var container = document.getElementById('container');
vnode = patch(container, view(data));
render();
});

@ -32,7 +32,7 @@ function updateAttrs (oldVnode: VNode, vnode: VNode): void {
const old = oldAttrs[key];
if (old !== cur) {
if (cur === true) {
elm.setAttribute(key, "");
elm.setAttribute(key, '');
} else if (cur === false) {
elm.removeAttribute(key);
} else {

@ -8,12 +8,12 @@ export type On = {
};
function invokeHandler (handler: any, vnode?: VNode, event?: Event): void {
if (typeof handler === "function") {
if (typeof handler === 'function') {
// call function handler
handler.call(vnode, event, vnode);
} else if (typeof handler === "object") {
} else if (typeof handler === 'object') {
// call handler with arguments
if (typeof handler[0] === "function") {
if (typeof handler[0] === 'function') {
// special case for single argument for performance
if (handler.length === 2) {
handler[0].call(vnode, handler[1], event, vnode);

@ -150,7 +150,7 @@ export function init (modules: Array<Partial<Module>>, domApi?: DOMAPI) {
if (vnode.children !== undefined) {
for (let j = 0; j < vnode.children.length; ++j) {
const child = vnode.children[j];
if (child != null && typeof child !== "string") {
if (child != null && typeof child !== 'string') {
invokeDestroyHook(child);
}
}

@ -186,7 +186,7 @@ describe('snabbdom', function () {
// Only run if srcdoc is supported.
var frame = document.createElement('iframe');
if (typeof frame.srcdoc !== 'undefined') {
frame.srcdoc = "<div>Thing 1</div>";
frame.srcdoc = '<div>Thing 1</div>';
frame.onload = function () {
const div0 = frame.contentDocument!.body.querySelector('div') as HTMLDivElement
patch(div0, h('div', 'Thing 2'));
@ -362,8 +362,8 @@ describe('snabbdom', function () {
});
var h2 = document.createElement('h2');
h2.id = 'hx';
h2.setAttribute('data-env', "xyz");
var text = document.createTextNode("Foobar");
h2.setAttribute('data-env', 'xyz');
var text = document.createTextNode('Foobar');
var elm = document.createElement('div');
elm.id = 'id';
elm.className = 'class other';

@ -154,7 +154,7 @@ describe('event listeners', function () {
it('access to virtual node in event handler with arguments', function () {
var result: Array<VNode | Event> = [];
function clicked (arg1: number, arg2: string, ev: Event, vnode: VNode) { result.push(this); result.push(vnode); }
var vnode1 = h('div', { on: { click: [clicked, 1, "2"] as any } }, [
var vnode1 = h('div', { on: { click: [clicked, 1, '2'] as any } }, [
h('a', 'Click my parent'),
]);
elm = patch(vnode0, vnode1).elm;

Loading…
Cancel
Save