diff --git a/package.json b/package.json index 4dfcb90..77784ec 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "del-cli": "^1.1.0", "nyc": "^11.2.1", "tslint": "^5.8.0", - "tslint-xo": "^0.1.0", + "tslint-xo": "^0.2.0", "typescript": "^2.6.1" } } diff --git a/source/index.ts b/source/index.ts index 19ddf51..1583d7c 100644 --- a/source/index.ts +++ b/source/index.ts @@ -1,3 +1,3 @@ -import { ow } from './ow'; +import {ow} from './ow'; export = ow; diff --git a/source/lib/operators/not.ts b/source/lib/operators/not.ts index 074db7a..03a7c69 100644 --- a/source/lib/operators/not.ts +++ b/source/lib/operators/not.ts @@ -1,4 +1,4 @@ -import { Predicate, Validator, validatorSymbol } from '../predicates/predicate'; +import {Predicate, Validator, validatorSymbol} from '../predicates/predicate'; /** * Operator which inverts all the validations. diff --git a/source/lib/predicates/boolean.ts b/source/lib/predicates/boolean.ts index 1050efa..994c2f9 100644 --- a/source/lib/predicates/boolean.ts +++ b/source/lib/predicates/boolean.ts @@ -1,7 +1,6 @@ -import { Predicate, Context } from './predicate'; +import {Predicate, Context} from './predicate'; export class BooleanPredicate extends Predicate { - constructor(context?: Context) { super('boolean', context); } diff --git a/source/lib/predicates/number.ts b/source/lib/predicates/number.ts index b19ebc7..784779c 100644 --- a/source/lib/predicates/number.ts +++ b/source/lib/predicates/number.ts @@ -1,8 +1,7 @@ import * as is from '@sindresorhus/is'; -import { Predicate, Context } from './predicate'; +import {Predicate, Context} from './predicate'; export class NumberPredicate extends Predicate { - constructor(context?: Context) { super('number', context); } diff --git a/source/lib/predicates/predicate.ts b/source/lib/predicates/predicate.ts index ad248d2..88cafe0 100644 --- a/source/lib/predicates/predicate.ts +++ b/source/lib/predicates/predicate.ts @@ -1,5 +1,5 @@ import * as is from '@sindresorhus/is'; -import { not } from '../operators/not'; +import {not} from '../operators/not'; export interface Validator { message(value: T): string; @@ -13,10 +13,11 @@ export interface Context { export const validatorSymbol = Symbol('validators'); export abstract class Predicate { - constructor( type: string, - private context: Context = { validators: [] } + private context: Context = { + validators: [] + } ) { this.addValidator({ message: value => `Expected argument to be of type \`${type}\` but received type \`${is(value)}\``, diff --git a/source/lib/predicates/string.ts b/source/lib/predicates/string.ts index d7b70e5..7849b3e 100644 --- a/source/lib/predicates/string.ts +++ b/source/lib/predicates/string.ts @@ -1,8 +1,7 @@ import * as valiDate from 'vali-date'; -import { Predicate, Context } from './predicate'; +import {Predicate, Context} from './predicate'; export class StringPredicate extends Predicate { - constructor(context?: Context) { super('string', context); } diff --git a/source/ow.ts b/source/ow.ts index f1d6213..9f3b05a 100644 --- a/source/ow.ts +++ b/source/ow.ts @@ -1,8 +1,8 @@ -import { ArgumentError } from './lib/argument-error'; -import { Predicate, validatorSymbol } from './lib/predicates/predicate'; -import { StringPredicate } from './lib/predicates/string'; -import { NumberPredicate } from './lib/predicates/number'; -import { BooleanPredicate } from './lib/predicates/boolean'; +import {ArgumentError} from './lib/argument-error'; +import {Predicate, validatorSymbol} from './lib/predicates/predicate'; +import {StringPredicate} from './lib/predicates/string'; +import {NumberPredicate} from './lib/predicates/number'; +import {BooleanPredicate} from './lib/predicates/boolean'; export interface Ow { (value: any, predicate: Predicate): void; @@ -21,7 +21,7 @@ export interface Ow { } const main = (value: any, predicate: Predicate) => { - for (const { validator, message } of predicate[validatorSymbol]) { + for (const {validator, message} of predicate[validatorSymbol]) { if (!validator(value)) { // TODO: Modify the stack output to show the original `ow()` call instead of this `throw` statement throw new ArgumentError(message(value), main); diff --git a/tslint.json b/tslint.json index 55e9f36..4fa05e5 100644 --- a/tslint.json +++ b/tslint.json @@ -1,3 +1,6 @@ { - "extends": "tslint-xo" + "extends": "tslint-xo", + "rules": { + "completed-docs": [true, "methods"] + } }