From a54d3528a879400816bda0e51ffe4db46274ef3f Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 18 Apr 2017 13:52:56 +0100 Subject: [PATCH] Fix linter --- src/middleware/404.ts | 8 ++++---- src/middleware/basic-auth.ts | 5 +++-- src/middleware/logging.ts | 16 ++++++++-------- src/middleware/static-files.ts | 10 +++++----- tslint.json | 4 +++- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/middleware/404.ts b/src/middleware/404.ts index 4fe6100..cb9a43c 100644 --- a/src/middleware/404.ts +++ b/src/middleware/404.ts @@ -1,11 +1,11 @@ +import * as staticFile from 'connect-static-file'; import { Request, Response } from 'express'; -import * as staticFile from 'connect-static-file' import * as path from 'path'; -export default function handle404(serveDir : string) { +export default function handle404(serveDir: string) { const handle404Middleware = staticFile(path.join(serveDir, '.404.html')); - return function (request : Request, response : Response, next : Function) { + return function (request: Request, response: Response, next: Function) { response.statusCode = 404; return handle404Middleware(request, response, next); - } + }; } diff --git a/src/middleware/basic-auth.ts b/src/middleware/basic-auth.ts index e31f729..dce597a 100644 --- a/src/middleware/basic-auth.ts +++ b/src/middleware/basic-auth.ts @@ -1,8 +1,9 @@ import * as basicAuth from 'express-basic-auth'; -export default function basicAuthHandler(username : string, password : string) { +export default function basicAuthHandler(username: string, password: string) { return basicAuth({ - authorizer: (req_username : string, req_password : string) => req_username === username && req_password === password, + authorizer: + (reqUsername: string, reqPassword: string) => reqUsername === username && reqPassword === password, challenge: true }); } diff --git a/src/middleware/logging.ts b/src/middleware/logging.ts index 49e3809..a036dd7 100644 --- a/src/middleware/logging.ts +++ b/src/middleware/logging.ts @@ -1,17 +1,17 @@ -import * as winston from 'winston'; import * as expressWinston from 'express-winston'; +import * as winston from 'winston'; export default expressWinston.logger({ - transports: [ - new winston.transports.Console({ - colorize: true - }) - ], + colorize: true, meta: false, msg: '{{ req.url }} ' .concat('status:{{ res.statusCode }} ') .concat('useragent:{{ req.headers["user-agent"] }} ') .concat('time:{{ res.responseTime }}ms'), - colorize: true, - statusLevels: true + statusLevels: true, + transports: [ + new winston.transports.Console({ + colorize: true + }) + ], }); diff --git a/src/middleware/static-files.ts b/src/middleware/static-files.ts index ba98171..4d73cb6 100644 --- a/src/middleware/static-files.ts +++ b/src/middleware/static-files.ts @@ -1,19 +1,19 @@ import * as express from 'express'; -import * as serveIndex from 'serve-index'; import * as path from 'path'; +import * as serveIndex from 'serve-index'; -function isDirectory(url : string) : boolean { +function isDirectory(url: string): boolean { return /\/$/.test(url); } -export function indexHandle(request : express.Request, response : express.Response, next : Function) { +export function indexHandle(request: express.Request, response: express.Response, next: Function) { if (isDirectory(request.url)) { request.url = path.join(request.url, 'index.html'); } return next(); } -export function staticFileHandle(serveDir : string) { +export function staticFileHandle(serveDir: string) { return express.static(serveDir, { dotfiles: 'ignore', index: false, @@ -21,7 +21,7 @@ export function staticFileHandle(serveDir : string) { }); } -export function serveIndexHandle(serveDir : string) { +export function serveIndexHandle(serveDir: string) { return serveIndex(serveDir, { icons: true }); diff --git a/tslint.json b/tslint.json index 501c52d..797466b 100644 --- a/tslint.json +++ b/tslint.json @@ -2,6 +2,8 @@ "extends": "tslint:recommended", "rules": { "quotemark": [true, "single"], - "trailing-comma": [false] + "trailing-comma": false, + "only-arrow-functions": false, + "interface-name": false } }