diff --git a/.vscode/settings.json b/.vscode/settings.json index 4244981..1c7e639 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,5 @@ // Place your settings in this file to overwrite default and user settings. { - "typescript.tsdk": "node_modules/typescript/lib" + "typescript.tsdk": "node_modules/typescript/lib", + "tslint.configFile": "tslint.test.json" } diff --git a/CHANGELOG.md b/CHANGELOG.md index d7f1ed3..327dcda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ ### v0.1.1 +- Enforce TSLint rules (see #54). + - Use `rimraf` instead of `rm -rf` (see #46). - Update Prettier rules (see #45). diff --git a/package.json b/package.json index 21d274e..921b3bd 100644 --- a/package.json +++ b/package.json @@ -8,14 +8,18 @@ "test": "nyc mocha", "karma": "karma start --single-run", "autoformat": "prettier --config .prettierrc --write {src,test}/**/*.ts", - "tslint-check": "tslint-config-prettier-check ./tslint.json", + "tslint-check:src": "tslint-config-prettier-check ./tslint.json", + "tslint-check:test": "tslint-config-prettier-check ./tslint.test.json", + "tslint:src": "tslint --project tsconfig.json", + "tslint:test": "tslint --config tslint.test.json --project tsconfig.test.json", + "tslint": "npm run tslint-check:src && npm run tslint-check:test && npm run tslint:src && npm run tslint:test", "clean-up": "rimraf .nyc_output && rimraf coverage && rimraf lib", "compile": "tsc -d", "dev": "webpack", "build": "webpack --env.production", "prepare": "npm run clean-up && npm run compile", "prepublishOnly": "publish-please guard", - "publish-please": "npm run autoformat && npm run clean-up && npm run test && publish-please" + "publish-please": "npm run tslint && npm run autoformat && npm run clean-up && npm run test && publish-please" }, "nyc": { "include": [ diff --git a/src/robotlegs/bender/extensions/signalCommandMap/impl/SignalCommandMap.ts b/src/robotlegs/bender/extensions/signalCommandMap/impl/SignalCommandMap.ts index 329dacb..725dd19 100644 --- a/src/robotlegs/bender/extensions/signalCommandMap/impl/SignalCommandMap.ts +++ b/src/robotlegs/bender/extensions/signalCommandMap/impl/SignalCommandMap.ts @@ -11,7 +11,6 @@ import { IClass, IInjector, IContext, - ILogger, ICommandTrigger, ICommandMapper, ICommandUnmapper, @@ -38,8 +37,6 @@ export class SignalCommandMap implements ISignalCommandMap { private _triggerMap: CommandTriggerMap; - private _logger: ILogger; - /*============================================================================*/ /* Constructor */ /*============================================================================*/ @@ -49,7 +46,6 @@ export class SignalCommandMap implements ISignalCommandMap { */ constructor(@inject(IContext) context: IContext) { this._injector = context.injector; - this._logger = context.getLogger(this); this._triggerMap = new CommandTriggerMap(this.getKey, this.createTrigger.bind(this)); } diff --git a/test/entry.ts b/test/entry.ts index 89b2f60..279b972 100644 --- a/test/entry.ts +++ b/test/entry.ts @@ -1,4 +1,6 @@ +/// + import "reflect-metadata"; -import "bluebird/js/browser/bluebird"; -import "es6-symbol/implement"; -import "es6-map/implement"; +import "bluebird"; +import "es6-symbol"; +import "es6-map"; diff --git a/test/robotlegs/bender/extensions/signalCommandMap/impl/signalCommandMap.test.ts b/test/robotlegs/bender/extensions/signalCommandMap/impl/signalCommandMap.test.ts index e3e9018..12ec40e 100644 --- a/test/robotlegs/bender/extensions/signalCommandMap/impl/signalCommandMap.test.ts +++ b/test/robotlegs/bender/extensions/signalCommandMap/impl/signalCommandMap.test.ts @@ -7,13 +7,11 @@ import "../../../../../entry.ts"; -import sinon = require("sinon"); - import { assert } from "chai"; -import { ISignal, MonoSignal, OnceSignal, Signal, DeluxeSignal, PrioritySignal } from "@robotlegsjs/signals"; +import { ISignal, Signal } from "@robotlegsjs/signals"; -import { injectable, IContext, IInjector, ICommandMapper, ICommandUnmapper, Context, CommandMapper } from "@robotlegsjs/core"; +import { IContext, ICommandMapper, Context, CommandMapper } from "@robotlegsjs/core"; import { SignalCommandMap } from "../../../../../../src/robotlegs/bender/extensions/signalCommandMap/impl/SignalCommandMap"; @@ -22,13 +20,11 @@ import { NullCommand } from "../support/NullCommand"; describe("SignalCommandMap", () => { let signal: ISignal; let context: IContext; - let injector: IInjector; let subject: SignalCommandMap; beforeEach(() => { signal = new Signal(); context = new Context(); - injector = context.injector; subject = new SignalCommandMap(context); }); @@ -39,7 +35,6 @@ describe("SignalCommandMap", () => { } signal = null; context = null; - injector = null; subject = null; }); diff --git a/test/robotlegs/bender/extensions/signalCommandMap/impl/signalCommandMapIntegration.test.ts b/test/robotlegs/bender/extensions/signalCommandMap/impl/signalCommandMapIntegration.test.ts index 63f82e4..8d246b0 100644 --- a/test/robotlegs/bender/extensions/signalCommandMap/impl/signalCommandMapIntegration.test.ts +++ b/test/robotlegs/bender/extensions/signalCommandMap/impl/signalCommandMapIntegration.test.ts @@ -7,13 +7,9 @@ import "../../../../../entry.ts"; -import sinon = require("sinon"); - import { assert } from "chai"; -import { ISignal, MonoSignal, OnceSignal, Signal, DeluxeSignal, PrioritySignal } from "@robotlegsjs/signals"; - -import { injectable, IContext, IInjector, ICommandMapper, ICommandUnmapper, Context, CommandMapper } from "@robotlegsjs/core"; +import { IContext, IInjector, Context } from "@robotlegsjs/core"; import { ISignalCommandMap } from "../../../../../../src/robotlegs/bender/extensions/signalCommandMap/api/ISignalCommandMap"; import { SignalCommandMap } from "../../../../../../src/robotlegs/bender/extensions/signalCommandMap/impl/SignalCommandMap"; @@ -47,7 +43,7 @@ describe("SignalCommandMap", () => { reportedExecutions.push(itemClass); } - function commandExecutionCount(totalEvents: number = 1, oneshot: boolean = false, ...valueObjects): number { + function commandExecutionCount(totalEvents: number = 1, oneshot: boolean = false, ...valueObjects: any[]): number { let executeCount: number = 0; injector @@ -75,7 +71,7 @@ describe("SignalCommandMap", () => { return commandExecutionCount(totalEvents, true); } - function hookCallCount(...hooks): number { + function hookCallCount(...hooks: any[]): number { let callCount: number = 0; injector @@ -101,7 +97,7 @@ describe("SignalCommandMap", () => { return callCount; } - function commandExecutionCountWithGuards(...guards): number { + function commandExecutionCountWithGuards(...guards: any[]): number { let executionCount: number = 0; injector diff --git a/test/robotlegs/bender/extensions/signalCommandMap/impl/signalCommandTrigger.test.ts b/test/robotlegs/bender/extensions/signalCommandMap/impl/signalCommandTrigger.test.ts index af7906e..fbc494b 100644 --- a/test/robotlegs/bender/extensions/signalCommandMap/impl/signalCommandTrigger.test.ts +++ b/test/robotlegs/bender/extensions/signalCommandMap/impl/signalCommandTrigger.test.ts @@ -11,9 +11,9 @@ import sinon = require("sinon"); import { assert } from "chai"; -import { ISignal, MonoSignal, OnceSignal, Signal, DeluxeSignal, PrioritySignal } from "@robotlegsjs/signals"; +import { ISignal, Signal } from "@robotlegsjs/signals"; -import { injectable, IInjector, RobotlegsInjector, CommandMapper } from "@robotlegsjs/core"; +import { IInjector, RobotlegsInjector, CommandMapper } from "@robotlegsjs/core"; import { SignalCommandTrigger } from "../../../../../../src/robotlegs/bender/extensions/signalCommandMap/impl/SignalCommandTrigger"; @@ -150,7 +150,7 @@ describe("SignalCommandTrigger", () => { injector.bind(Signal).toConstantValue(signal); mapper = subject.createMapper(); mapper.toCommand(CallbackParametersCommand); - signal.dispatch.apply(signal, expected); + signal.dispatch.apply(signal, parameters); assert.deepEqual(actual, expected); }); diff --git a/test/robotlegs/bender/extensions/signalCommandMap/support/NullCommand.ts b/test/robotlegs/bender/extensions/signalCommandMap/support/NullCommand.ts index 912bfba..e336ee3 100644 --- a/test/robotlegs/bender/extensions/signalCommandMap/support/NullCommand.ts +++ b/test/robotlegs/bender/extensions/signalCommandMap/support/NullCommand.ts @@ -5,7 +5,7 @@ // in accordance with the terms of the license agreement accompanying it. // ------------------------------------------------------------------------------ -import { injectable, inject, named } from "inversify"; +import { injectable } from "inversify"; import { ICommand } from "@robotlegsjs/core"; diff --git a/tslint.json b/tslint.json index eb89414..bd53bec 100644 --- a/tslint.json +++ b/tslint.json @@ -32,7 +32,6 @@ "no-console": [ true, "debug", - "info", "time", "timeEnd", "trace" @@ -40,7 +39,8 @@ "no-construct": true, "no-debugger": true, "no-duplicate-variable": true, - "no-empty": true, + "no-empty": false, + "no-empty-interface": false, "no-eval": true, "no-inferrable-types": false, "no-shadowed-variable": true, @@ -49,10 +49,9 @@ "no-this-assignment": false, "no-unused-expression": true, "no-unused-variable": true, - "no-unreachable": true, "no-use-before-declare": true, "no-var-keyword": true, - "object-literal-sort-keys": true, + "object-literal-sort-keys": false, "ordered-imports": false, "only-arrow-functions": [ false ], "prefer-const": false, diff --git a/tslint.test.json b/tslint.test.json new file mode 100644 index 0000000..6942d31 --- /dev/null +++ b/tslint.test.json @@ -0,0 +1,8 @@ +{ + "extends": [ + "./tslint.json" + ], + "rules": { + "no-implicit-dependencies": false + } +}