From 12cb57ea101caa32cad33d11eb0d3acb2dd44245 Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Thu, 7 Mar 2019 21:20:00 +0100 Subject: [PATCH] refactor: Use default TSLint configuration --- types/tape-async/index.d.ts | 34 ++++----- .../tape-async/test/tape-async.async.test.ts | 8 +- .../test/tape-async.generators.test.ts | 16 ++-- types/tape-async/test/tape-async.test.ts | 36 ++++----- types/tape-async/tslint.json | 74 +------------------ 5 files changed, 43 insertions(+), 125 deletions(-) diff --git a/types/tape-async/index.d.ts b/types/tape-async/index.d.ts index be104ec2b4..94447163db 100644 --- a/types/tape-async/index.d.ts +++ b/types/tape-async/index.d.ts @@ -9,13 +9,11 @@ import tapeSync = require("tape"); export = tape; -declare function tape(name: string, cb: tape.TestCase): void +declare function tape(name: string | tape.TestOptions, cb: tape.TestCase): void; declare function tape(name: string, opts: tape.TestOptions, cb: tape.TestCase): void; declare function tape(cb: tape.TestCase): void; -declare function tape(opts: tape.TestOptions, cb: tape.TestCase): void; declare namespace tape { - interface TestCase { (test: Test): void | Iterator | PromiseLike; } @@ -23,45 +21,41 @@ declare namespace tape { /** * Available opts options for the tape function. */ - interface TestOptions extends tapeSync.TestOptions { - } + type TestOptions = tapeSync.TestOptions; /** * Options for the createStream function. */ - interface StreamOptions extends tapeSync.StreamOptions { - } + type StreamOptions = tapeSync.StreamOptions; /** * Generate a new test that will be skipped over. */ - export function skip(name: string, cb: tape.TestCase): void; - export function skip(name: string, opts: tape.TestOptions, cb: tape.TestCase): void; - export function skip(cb: tape.TestCase): void; - export function skip(opts: tape.TestOptions, cb: tape.TestCase): void; + function skip(name: string | TestOptions, cb: TestCase): void; + function skip(name: string, opts: TestOptions, cb: TestCase): void; + function skip(cb: TestCase): void; /** * The onFinish hook will get invoked when ALL tape tests have finished right before tape is about to print the test summary. */ - export function onFinish(cb: () => void): void; + function onFinish(cb: () => void): void; /** * Like test(name?, opts?, cb) except if you use .only this is the only test case that will run for the entire process, all other test cases using tape will be ignored. */ - export function only(name: string, cb: tape.TestCase): void; - export function only(name: string, opts: tape.TestOptions, cb: tape.TestCase): void; - export function only(cb: tape.TestCase): void; - export function only(opts: tape.TestOptions, cb: tape.TestCase): void; + function only(name: string | TestOptions, cb: TestCase): void; + function only(name: string, opts: TestOptions, cb: TestCase): void; + function only(cb: TestCase): void; /** * Create a new test harness instance, which is a function like test(), but with a new pending stack and test state. */ - export function createHarness(): typeof tape; + function createHarness(): typeof tape; /** * Create a stream of output, bypassing the default output stream that writes messages to console.log(). * By default stream will be a text stream of TAP output, but you can get an object stream instead by setting opts.objectMode to true. */ - export function createStream(opts?: tape.StreamOptions): NodeJS.ReadableStream; + function createStream(opts?: StreamOptions): NodeJS.ReadableStream; interface Test extends tapeSync.Test { /** @@ -69,7 +63,7 @@ declare namespace tape { * cb(st) will only fire when t finishes. * Additional tests queued up after t will not be run until all subtests finish. */ - test(name: string, cb: tape.TestCase): void; - test(name: string, opts: TestOptions, cb: tape.TestCase): void; + test(name: string, cb: TestCase): void; + test(name: string, opts: TestOptions, cb: TestCase): void; } } diff --git a/types/tape-async/test/tape-async.async.test.ts b/types/tape-async/test/tape-async.async.test.ts index bb8e226009..4a6a53792c 100644 --- a/types/tape-async/test/tape-async.async.test.ts +++ b/types/tape-async/test/tape-async.async.test.ts @@ -2,10 +2,10 @@ import tape = require("tape-async"); -var name: string; -var cb: (test: tape.Test) => Promise; -var opts: tape.TestOptions; -var t: tape.Test; +let name: string; +let cb: (test: tape.Test) => Promise; +let opts: tape.TestOptions; +let t: tape.Test; tape(cb); tape(name, cb); diff --git a/types/tape-async/test/tape-async.generators.test.ts b/types/tape-async/test/tape-async.generators.test.ts index bf279030ef..940f207b5c 100644 --- a/types/tape-async/test/tape-async.generators.test.ts +++ b/types/tape-async/test/tape-async.generators.test.ts @@ -2,17 +2,17 @@ import tape = require("tape-async"); -var name: string; -var cb: (test: tape.Test) => IterableIterator; -var opts: tape.TestOptions; -var t: tape.Test; +let name: string; +let cb: (test: tape.Test) => IterableIterator; +let opts: tape.TestOptions; +let t: tape.Test; tape(cb); tape(name, cb); tape(opts, cb); tape(name, opts, cb); -tape(name, function* (test: tape.Test): IterableIterator { +tape(name, function*(test: tape.Test): IterableIterator { t = test; }); @@ -26,12 +26,12 @@ tape.only(name, cb); tape.only(opts, cb); tape.only(name, opts, cb); -tape(name, function* (test: tape.Test): IterableIterator { - test.test(name, function* (st: tape.Test): IterableIterator { +tape(name, function*(test: tape.Test): IterableIterator { + test.test(name, function*(st: tape.Test): IterableIterator { t = st; }); - test.test(name, opts, function* (st: tape.Test): IterableIterator { + test.test(name, opts, function*(st: tape.Test): IterableIterator { t = st; }); }); diff --git a/types/tape-async/test/tape-async.test.ts b/types/tape-async/test/tape-async.test.ts index 060da063be..71e06fffdb 100644 --- a/types/tape-async/test/tape-async.test.ts +++ b/types/tape-async/test/tape-async.test.ts @@ -1,9 +1,9 @@ import tape = require("tape-async"); -var name: string; -var cb: (test: tape.Test) => void; -var opts: tape.TestOptions; -var t: tape.Test; +let name: string; +let cb: (test: tape.Test) => void; +let opts: tape.TestOptions; +let t: tape.Test; tape(cb); tape(name, cb); @@ -26,14 +26,12 @@ tape.only(name, opts, cb); tape.onFinish(() => {}); - -var sopts: tape.StreamOptions; -var rs: NodeJS.ReadableStream; +let sopts: tape.StreamOptions; +let rs: NodeJS.ReadableStream; rs = tape.createStream(); rs = tape.createStream(sopts); - -var htest: typeof tape; +let htest: typeof tape; htest = tape.createHarness(); class CustomException extends Error { @@ -42,19 +40,17 @@ class CustomException extends Error { } } - tape(name, (test: tape.Test) => { + let num: number; + let ms: number; + let value: any; + let actual: any; + let expected: any; + let err: any; + let fn = () => {}; + let msg: string; - var num: number; - var ms: number; - var value: any; - var actual: any; - var expected: any; - var err: any; - var fn = function() {}; - var msg: string; - - var exceptionExpected: RegExp | (() => void); + let exceptionExpected: RegExp | (() => void); test.plan(num); test.end(); diff --git a/types/tape-async/tslint.json b/types/tape-async/tslint.json index b5f5694bcd..f610afbb19 100644 --- a/types/tape-async/tslint.json +++ b/types/tape-async/tslint.json @@ -1,83 +1,11 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, "indent": [ true, "tabs" ], - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "prefer-const": false } }