Skip to content
This repository has been archived by the owner on Dec 19, 2017. It is now read-only.

Commit

Permalink
🎨 Use tslint
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyWebb committed Jul 30, 2017
1 parent 3e13290 commit 5a5f1db
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 20 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"rollup-plugin-node-globals": "^1.1.0",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-ts": "^0.1.0",
"tape": "caseyWebb/tape"
"tape": "caseyWebb/tape",
"tslint": "^5.5.0"
}
}
6 changes: 2 additions & 4 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
} from './utils'

export class Context {
/* eslint-disable */
$child: Context
$parent: Context
_redirect: string
Expand All @@ -35,7 +34,6 @@ export class Context {
private _beforeNavigateCallbacks: Array<AsyncCallback> = []
private _appMiddlewareDownstream: Array<AsyncCallback> = []
private _routeMiddlewareDownstream: Array<AsyncCallback> = []
/* eslint-enable */

constructor(router: Router, $parent: Context, path: string, _with: { [key: string]: any } = {}) {
const route = router.resolveRoute(path)
Expand Down Expand Up @@ -114,7 +112,7 @@ export class Context {
}

async runBeforeNavigateCallbacks(): Promise<boolean> {
let ctx: Context = this // eslint-disable-line
let ctx: Context = this
let callbacks = []
while (ctx) {
callbacks = [...ctx._beforeNavigateCallbacks, ...callbacks]
Expand All @@ -133,7 +131,7 @@ export class Context {
}

render() {
let ctx: Context = this // eslint-disable-line
let ctx: Context = this

while (ctx) {
if (isUndefined(ctx._redirect)) {
Expand Down
2 changes: 0 additions & 2 deletions src/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ import { isFunction, isPlainObject, isString, isUndefined, map, reduce } from '.
export type RouteConfig = string | RouteMap | Middleware

export class Route {
/* eslint-disable */
path: string
component: string
middleware: Array<Middleware>
children: Array<Route>
keys

private regexp: RegExp
/* eslint-enable */

constructor(path: string, config: Array<RouteConfig>) {
const [component, middleware, children] = Route.parseConfig(config)
Expand Down
9 changes: 2 additions & 7 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
traversePath
} from './utils'

/* eslint-disable */
export interface Middleware {
(ctx: Context, done?: () => any): {
beforeRender?: AsyncCallback
Expand All @@ -28,10 +27,8 @@ export interface Plugin {
export interface RouteMap {
[name: string]: Array<RouteConfig>
}
/* eslint-enable */

export class Router {
/* eslint-disable */
private static routes: RouteMap = {}
private static events: {
click: string,
Expand Down Expand Up @@ -62,7 +59,6 @@ export class Router {
isRoot: boolean
ctx: Context
bound: boolean
/* eslint-enable */

constructor(
url: string,
Expand Down Expand Up @@ -206,8 +202,7 @@ export class Router {
if (this.isRoot) {
document.removeEventListener(Router.events.click, Router.onclick, false)
window.removeEventListener(Router.events.popstate, Router.onpopstate, false)
delete Router.head // eslint-disable-line
// this.ctx.runBeforeDispose().then(() => this.ctx.runAfterDispose())
delete Router.head
}
}

Expand Down Expand Up @@ -354,7 +349,7 @@ export class Router {
return mapValues(routes, (c) =>
map(Router.runPlugins(c), (routeConfig) =>
isPlainObject(routeConfig)
? Router.normalizeRoutes(routeConfig as RouteMap) // eslint-disable-line
? Router.normalizeRoutes(routeConfig as RouteMap)
: routeConfig))
}

Expand Down
2 changes: 0 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export { default as map } from 'lodash-es/map'
export { default as mapValues } from 'lodash-es/mapValues'
export { default as reduce } from 'lodash-es/reduce'

/* eslint-disable */
export type AsyncCallback = (done?: () => void) => Promise<any> | void
/* eslint-enable */

export async function sequence(callbacks: AsyncCallback[], ...args): Promise<{
count: number,
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "tslint:recommended",
"rules": {
"curly": true,
"quotemark": [true, "single"],
"semicolon": [true, "never"],
"trailing-comma": [true, "never"],
"object-literal-sort-keys": false,
"ordered-imports": [false],
"variable-name": [true, "allow-leading-underscore"]
}
}
39 changes: 37 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ code-point-at@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"

colors@^1.1.0:
colors@^1.1.0, colors@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63"

Expand Down Expand Up @@ -821,6 +821,10 @@ di@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/di/-/di-0.0.1.tgz#806649326ceaa7caa3306d75d985ea2748ba913c"

diff@^3.2.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-3.3.0.tgz#056695150d7aa93237ca7e378ac3b1682b7963b9"

diffie-hellman@^5.0.0:
version "5.0.2"
resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.2.tgz#b5835739270cfe26acf632099fded2a07f209e5e"
Expand Down Expand Up @@ -2588,6 +2592,10 @@ path-is-inside@^1.0.1, path-is-inside@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53"

path-parse@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1"

path-to-regexp@^1.2.1:
version "1.7.0"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.7.0.tgz#59fde0f435badacba103a84e9d3bc64e96b9937d"
Expand Down Expand Up @@ -2915,6 +2923,12 @@ resolve@^1.1.6, resolve@^1.1.7, resolve@~1.2.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.2.1.tgz#0fb2989c0a86a1c545ce918aa36a8809ff7356c5"

resolve@^1.3.2:
version "1.4.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.4.0.tgz#a75be01c53da25d934a98ebd0e4c4a7312f92a86"
dependencies:
path-parse "^1.0.5"

restore-cursor@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf"
Expand Down Expand Up @@ -3376,10 +3390,31 @@ tryit@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb"

tslib@^1.7.0:
tslib@^1.7.0, tslib@^1.7.1:
version "1.7.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.7.1.tgz#bc8004164691923a79fe8378bbeb3da2017538ec"

tslint@^5.5.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.5.0.tgz#10e8dab3e3061fa61e9442e8cee3982acf20a6aa"
dependencies:
babel-code-frame "^6.22.0"
colors "^1.1.2"
commander "^2.9.0"
diff "^3.2.0"
glob "^7.1.1"
minimatch "^3.0.4"
resolve "^1.3.2"
semver "^5.3.0"
tslib "^1.7.1"
tsutils "^2.5.1"

tsutils@^2.5.1:
version "2.8.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.8.0.tgz#0160173729b3bf138628dd14a1537e00851d814a"
dependencies:
tslib "^1.7.1"

tunnel-agent@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd"
Expand Down

0 comments on commit 5a5f1db

Please sign in to comment.