From 814c2e50d76c915f6b0893465451e06a7da602d8 Mon Sep 17 00:00:00 2001 From: Shahar Dawn Or Date: Thu, 16 Jan 2020 21:13:34 +0700 Subject: [PATCH] style: four eslint rules enabled (#548) - import/newline-after-import - dot-notation - import/first - no-undef --- .eslintrc.js | 4 +--- perf/benchmarks.js | 2 ++ src/h.ts | 3 ++- src/snabbdom.bundle.ts | 5 ++++- src/test/attachto.ts | 4 ++-- src/test/attributes.ts | 3 ++- src/test/core.ts | 11 ++++++----- src/test/dataset.ts | 3 ++- src/test/eventlisteners.ts | 3 ++- src/test/htmldomapi.ts | 1 + src/test/style.ts | 5 +++-- src/test/thunk.ts | 5 +++-- 12 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index f7d7732..f734670 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,6 +6,7 @@ module.exports = { '/dist/' ], rules: { + 'import/newline-after-import': 'error', '@typescript-eslint/no-non-null-assertion': 'off', '@typescript-eslint/consistent-type-assertions': 'off', '@typescript-eslint/consistent-type-definitions': 'off', @@ -16,10 +17,7 @@ module.exports = { '@typescript-eslint/restrict-plus-operands': 'off', '@typescript-eslint/strict-boolean-expressions': 'off', 'comma-dangle': 'off', - 'dot-notation': 'off', - 'import/first': 'off', 'no-mixed-operators': 'off', - 'no-undef': 'off', 'no-unneeded-ternary': 'off', 'no-unused-expressions': 'off', 'no-unused-vars': 'off', diff --git a/perf/benchmarks.js b/perf/benchmarks.js index 63eaaac..cfd7acb 100644 --- a/perf/benchmarks.js +++ b/perf/benchmarks.js @@ -1,3 +1,5 @@ +// Has not been maintained for a while. +/* eslint-disable */ var Benchmark = require('benchmark'); var a = require('../snabbdom.js'); var b = require('../oldsnabbdom.js'); diff --git a/src/h.ts b/src/h.ts index 11605db..2dcdd76 100644 --- a/src/h.ts +++ b/src/h.ts @@ -1,9 +1,10 @@ import { vnode, VNode, VNodeData } from './vnode'; +import * as is from './is'; + export type VNodes = VNode[]; export type VNodeChildElement = VNode | string | number | undefined | null; export type ArrayOrElement = T | T[]; export type VNodeChildren = ArrayOrElement -import * as is from './is'; function addNS (data: any, children: VNodes | undefined, sel: string | undefined): void { data.ns = 'http://www.w3.org/2000/svg'; diff --git a/src/snabbdom.bundle.ts b/src/snabbdom.bundle.ts index d3ff95a..2961ad3 100644 --- a/src/snabbdom.bundle.ts +++ b/src/snabbdom.bundle.ts @@ -4,7 +4,10 @@ import { classModule } from './modules/class'; // makes it easy to toggle classe import { propsModule } from './modules/props'; // for setting properties on DOM elements import { styleModule } from './modules/style'; // handles styling on elements with support for animations import { eventListenersModule } from './modules/eventlisteners'; // attaches event listeners -import { h } from './h'; // helper function for creating vnodes + +// helper function for creating vnodes +import { h } from './h'; + var patch = init([ // Init patch function with choosen modules attributesModule, classModule, diff --git a/src/test/attachto.ts b/src/test/attachto.ts index ff55b72..943d005 100644 --- a/src/test/attachto.ts +++ b/src/test/attachto.ts @@ -1,11 +1,11 @@ import assert from 'assert' import { init } from '../snabbdom' import { RemoveHook } from '../hooks'; - -var patch = init([]); import attachTo from '../helpers/attachto' import h from '../h' +var patch = init([]); + describe('attachTo', function () { var elm: any, vnode0: any; beforeEach(function () { diff --git a/src/test/attributes.ts b/src/test/attributes.ts index 6b5b394..775040f 100644 --- a/src/test/attributes.ts +++ b/src/test/attributes.ts @@ -1,10 +1,11 @@ import assert from 'assert' import { init } from '../snabbdom' import attributesModule from '../modules/attributes' +import h from '../h' + var patch = init([ attributesModule ]); -import h from '../h' describe('attributes', function () { var elm: any, vnode0: any; diff --git a/src/test/core.ts b/src/test/core.ts index bae62e9..ccb8e06 100644 --- a/src/test/core.ts +++ b/src/test/core.ts @@ -5,17 +5,18 @@ import { init } from '../snabbdom' import classModule from '../modules/class' import propsModule from '../modules/props' import eventListenersModule from '../modules/eventlisteners' -var patch = init([ - classModule, - propsModule, - eventListenersModule -]); 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' +var patch = init([ + classModule, + propsModule, + eventListenersModule +]); + function prop (name: string) { return function (obj: {[index: string]: T}) { return obj[name]; diff --git a/src/test/dataset.ts b/src/test/dataset.ts index cb9aef8..e0757d9 100644 --- a/src/test/dataset.ts +++ b/src/test/dataset.ts @@ -2,10 +2,11 @@ import assert from 'assert' import datasetModule from '../modules/dataset' import { init } from '../snabbdom' +import h from '../h' + var patch = init([ datasetModule ]); -import h from '../h' describe('dataset', function () { var elm: any, vnode0: any; diff --git a/src/test/eventlisteners.ts b/src/test/eventlisteners.ts index 7f4d090..d57b441 100644 --- a/src/test/eventlisteners.ts +++ b/src/test/eventlisteners.ts @@ -3,10 +3,11 @@ import { VNode } from '../vnode'; import { init } from '../snabbdom' import eventListenersModule from '../modules/eventlisteners' +import h from '../h' + var patch = init([ eventListenersModule ]); -import h from '../h' describe('event listeners', function () { var elm: any, vnode0: any; diff --git a/src/test/htmldomapi.ts b/src/test/htmldomapi.ts index 5611232..a2dbda7 100644 --- a/src/test/htmldomapi.ts +++ b/src/test/htmldomapi.ts @@ -3,6 +3,7 @@ import assert from 'assert' import { init } from '../snabbdom' import h from '../h' import attributesModule from '../modules/attributes' + var patch = init([ attributesModule ]); diff --git a/src/test/style.ts b/src/test/style.ts index c1e41d2..58536ee 100644 --- a/src/test/style.ts +++ b/src/test/style.ts @@ -2,11 +2,12 @@ import assert from 'assert' import { init } from '../snabbdom' import styleModule from '../modules/style' +import h from '../h' +import toVNode from '../tovnode' + var patch = init([ styleModule ]); -import h from '../h' -import toVNode from '../tovnode' describe('style', function () { var elm: any, vnode0: any; diff --git a/src/test/thunk.ts b/src/test/thunk.ts index ec8679e..945fc3b 100644 --- a/src/test/thunk.ts +++ b/src/test/thunk.ts @@ -1,12 +1,13 @@ import assert from 'assert' import { init } from '../snabbdom' -var patch = init([ -]); import h from '../h' import thunk from '../thunk' import { VNode } from '../vnode'; +var patch = init([ +]); + describe('thunk', function () { var elm: any, vnode0: any; beforeEach(function () {