Swap out linter

This commit is contained in:
Jake Howard 2018-03-15 21:40:35 +00:00
parent 2e2e4c8b8f
commit 25c973303d
Signed by: jake
GPG key ID: 57AFB45680EDD477
10 changed files with 66 additions and 19 deletions

50
package-lock.json generated
View file

@ -546,6 +546,30 @@
"resolved": "https://registry.npmjs.org/docopt/-/docopt-0.6.2.tgz", "resolved": "https://registry.npmjs.org/docopt/-/docopt-0.6.2.tgz",
"integrity": "sha1-so6eIiDaXsSffqW7JKR3h0Be6xE=" "integrity": "sha1-so6eIiDaXsSffqW7JKR3h0Be6xE="
}, },
"doctrine": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-0.7.2.tgz",
"integrity": "sha1-fLhgNZujvpDgQLJrcpzkv6ZUxSM=",
"dev": true,
"requires": {
"esutils": "1.1.6",
"isarray": "0.0.1"
},
"dependencies": {
"esutils": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-1.1.6.tgz",
"integrity": "sha1-wBzKqa5LiXxtDD4hCuUvPHqEQ3U=",
"dev": true
},
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
"dev": true
}
}
},
"dont-sniff-mimetype": { "dont-sniff-mimetype": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/dont-sniff-mimetype/-/dont-sniff-mimetype-1.0.0.tgz", "resolved": "https://registry.npmjs.org/dont-sniff-mimetype/-/dont-sniff-mimetype-1.0.0.tgz",
@ -1729,6 +1753,32 @@
"tsutils": "2.22.2" "tsutils": "2.22.2"
} }
}, },
"tslint-config-dabapps": {
"version": "github:dabapps/tslint-config-dabapps#e73b8141b5675ae6c04aaea77ae9eda8a9db28dd",
"dev": true,
"requires": {
"tslint-eslint-rules": "4.0.0"
}
},
"tslint-eslint-rules": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/tslint-eslint-rules/-/tslint-eslint-rules-4.0.0.tgz",
"integrity": "sha1-Tg5Z7NVwHJpIxm7Ue9yvscY10ns=",
"dev": true,
"requires": {
"doctrine": "0.7.2",
"tslib": "1.9.0",
"tsutils": "1.9.1"
},
"dependencies": {
"tsutils": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-1.9.1.tgz",
"integrity": "sha1-ufmrROVa+WgYMdXyjQrur1x1DLA=",
"dev": true
}
}
},
"tsutils": { "tsutils": {
"version": "2.22.2", "version": "2.22.2",
"resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.22.2.tgz", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.22.2.tgz",

View file

@ -54,6 +54,7 @@
"supertest": "3.0.0", "supertest": "3.0.0",
"ts-node": "5.0.1", "ts-node": "5.0.1",
"tslint": "5.9.1", "tslint": "5.9.1",
"tslint-config-dabapps": "dabapps/tslint-config-dabapps#v0.3.0",
"typescript": "2.7.2" "typescript": "2.7.2"
} }
} }

View file

@ -1,5 +1,5 @@
import { docopt } from 'docopt'; import { docopt } from 'docopt';
import { Options } from './types'; import { IOptions } from './types';
const PKG = require('../package.json'); const PKG = require('../package.json');
@ -24,7 +24,7 @@ Options:
-o --open Open in browser after start. -o --open Open in browser after start.
`; `;
export default function getArgs() : Options { export default function getArgs() : IOptions {
const rawArgs = docopt(ARG_DATA, { const rawArgs = docopt(ARG_DATA, {
version: PKG.version, version: PKG.version,
help: true help: true

View file

@ -4,7 +4,7 @@ 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')); const handle404Middleware = staticFile(path.join(serveDir, '.404.html'));
return function(request: Request, response: Response, next: () => void) { return (request: Request, response: Response, next: () => void) => {
response.statusCode = 404; response.statusCode = 404;
return handle404Middleware(request, response, next); return handle404Middleware(request, response, next);
}; };

View file

@ -11,9 +11,9 @@ import basicAuthHandler from './middleware/basic-auth';
import { serveIndexHandle, indexHandle, staticFileHandle } from './middleware/static-files'; import { serveIndexHandle, indexHandle, staticFileHandle } from './middleware/static-files';
import handle404 from './middleware/404'; import handle404 from './middleware/404';
import { Options } from './types'; import { IOptions } from './types';
export default function createServer(opts : Options) : express.Application { export default function createServer(opts : IOptions) : express.Application {
const app = express(); const app = express();
app.use(helmet({ app.use(helmet({

View file

@ -1,5 +1,5 @@
export interface Options { export interface IOptions {
port: number; port: number;
allowed_ips: string[]; allowed_ips: string[];
basicAuth: string[]; basicAuth: string[];

View file

@ -1,10 +1,10 @@
import createServer from '../src/server'; import createServer from '../src/server';
import { Options } from '../src/types'; import { IOptions } from '../src/types';
import fetch from 'node-fetch'; import fetch from 'node-fetch';
export function runServer(opts: Object, url : string, callback: Function) { export function runServer(opts: Object, url : string, callback: Function) {
const app = createServer(opts as Options); const app = createServer(opts as IOptions);
const server = app.listen(1234, function () { const server = app.listen(1234, function () {
return fetch('http://0.0.0.0:1234' + url).then(function (response : any) { return fetch('http://0.0.0.0:1234' + url).then(function (response : any) {
server.close(); server.close();

View file

@ -2,7 +2,7 @@ import { expect } from 'chai';
import { runServer } from '../helpers'; import { runServer } from '../helpers';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import { Options } from '../../src/types'; import { IOptions } from '../../src/types';
describe('Static Files', function () { describe('Static Files', function () {
@ -50,7 +50,7 @@ describe('Static Files', function () {
serveDir: 'site/', serveDir: 'site/',
opbeat: false, opbeat: false,
open: false open: false
} as Options; } as IOptions;
it('Should allow directory listing', function (done) { it('Should allow directory listing', function (done) {
runServer(SERVER_CONFIG, '/', function (response : any) { runServer(SERVER_CONFIG, '/', function (response : any) {

View file

@ -2,7 +2,7 @@ import { expect } from 'chai';
import { runServer } from './helpers'; import { runServer } from './helpers';
import * as fs from 'fs'; import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import { Options } from '../src/types'; import { IOptions } from '../src/types';
const PKG = require('../package.json'); const PKG = require('../package.json');
@ -31,7 +31,7 @@ describe('Server', function () {
opbeat: false, opbeat: false,
open: false, open: false,
allowHttp: false allowHttp: false
} as Options; } as IOptions;
it('Should have no powered by header', function (done) { it('Should have no powered by header', function (done) {
runServer(SERVER_SETTINGS, '/index.html', function (response : any) { runServer(SERVER_SETTINGS, '/index.html', function (response : any) {

View file

@ -1,9 +1,5 @@
{ {
"extends": "tslint:recommended", "extends": [
"rules": { "tslint-config-dabapps"
"quotemark": [true, "single"], ]
"trailing-comma": false,
"only-arrow-functions": false,
"interface-name": false
}
} }