aboutsummaryrefslogtreecommitdiffgithub
diff options
context:
space:
mode:
authorAustin Adams <git@austinjadams.com>2018-08-07 17:23:15 -0400
committerAustin Adams <git@austinjadams.com>2018-08-07 17:23:15 -0400
commit7acb27fbd6a32be47a96fc38d809d27688dae46b (patch)
tree99932448de7c41e9cb3ea199f1c6e933afb089d2
parent9cb367b865d0d4f89c475692c9b09019295ffe74 (diff)
downloadnovice-7acb27fbd6a32be47a96fc38d809d27688dae46b.tar.gz
novice-7acb27fbd6a32be47a96fc38d809d27688dae46b.tar.xz
Add linter
-rw-r--r--novice/cli.test.ts4
-rw-r--r--novice/cli.ts10
-rw-r--r--package-lock.json52
-rw-r--r--package.json11
-rw-r--r--tsconfig.json9
-rw-r--r--tslint.json11
6 files changed, 87 insertions, 10 deletions
diff --git a/novice/cli.test.ts b/novice/cli.test.ts
index edb1c9b..4a25cbf 100644
--- a/novice/cli.test.ts
+++ b/novice/cli.test.ts
@@ -2,8 +2,8 @@ import { Writable } from 'stream';
import main from './cli';
describe('cli', () => {
- let stderr;
- let stderrActual;
+ let stderr : Writable;
+ let stderrActual : string;
beforeEach(() => {
stderrActual = "";
diff --git a/novice/cli.ts b/novice/cli.ts
index ef4ea0c..cd843e6 100644
--- a/novice/cli.ts
+++ b/novice/cli.ts
@@ -1,12 +1,12 @@
import { Writable } from 'stream';
-function main(args: string[], stderr: Writable) : number {
- let subcommand = args[0];
+function main(args: string[], stderr: Writable): number {
+ const subcommand = args[0];
switch (subcommand) {
case 'asm':
if (args.length === 2) {
- let path = args[1];
+ const path = args[1];
return asm(path, stderr);
} else {
return usage(stderr);
@@ -16,12 +16,12 @@ function main(args: string[], stderr: Writable) : number {
}
}
-function usage(stderr: Writable) : number {
+function usage(stderr: Writable): number {
stderr.write('usage: novice asm <file>\n');
return 1;
}
-function asm(path: string, stderr: Writable) : number {
+function asm(path: string, stderr: Writable): number {
stderr.write('assembling ' + path + '\n');
return 0;
}
diff --git a/package-lock.json b/package-lock.json
index d5b7c95..c3f207b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -813,6 +813,12 @@
"delayed-stream": "~1.0.0"
}
},
+ "commander": {
+ "version": "2.17.1",
+ "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz",
+ "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==",
+ "dev": true
+ },
"compare-versions": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.3.0.tgz",
@@ -4796,6 +4802,52 @@
"lodash": "^4.17.10"
}
},
+ "tslib": {
+ "version": "1.9.3",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
+ "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==",
+ "dev": true
+ },
+ "tslint": {
+ "version": "5.11.0",
+ "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.11.0.tgz",
+ "integrity": "sha1-mPMMAurjzecAYgHkwzywi0hYHu0=",
+ "dev": true,
+ "requires": {
+ "babel-code-frame": "^6.22.0",
+ "builtin-modules": "^1.1.1",
+ "chalk": "^2.3.0",
+ "commander": "^2.12.1",
+ "diff": "^3.2.0",
+ "glob": "^7.1.1",
+ "js-yaml": "^3.7.0",
+ "minimatch": "^3.0.4",
+ "resolve": "^1.3.2",
+ "semver": "^5.3.0",
+ "tslib": "^1.8.0",
+ "tsutils": "^2.27.2"
+ },
+ "dependencies": {
+ "resolve": {
+ "version": "1.8.1",
+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz",
+ "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==",
+ "dev": true,
+ "requires": {
+ "path-parse": "^1.0.5"
+ }
+ }
+ }
+ },
+ "tsutils": {
+ "version": "2.29.0",
+ "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
+ "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
+ "dev": true,
+ "requires": {
+ "tslib": "^1.8.1"
+ }
+ },
"tunnel-agent": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
diff --git a/package.json b/package.json
index 9713a8e..3b10372 100644
--- a/package.json
+++ b/package.json
@@ -7,7 +7,8 @@
"build": "tsc -b",
"build:watch": "tsc -b -w",
"start": "node novice/main.js",
- "test": "jest --coverage"
+ "test": "jest --coverage",
+ "lint": "tslint -p tsconfig.json -c tslint.json 'novice/**/*.ts'"
},
"repository": {
"type": "git",
@@ -32,13 +33,19 @@
"json",
"node"
],
- "testEnvironment": "node"
+ "testEnvironment": "node",
+ "globals": {
+ "ts-jest": {
+ "enableTsDiagnostics": true
+ }
+ }
},
"devDependencies": {
"@types/jest": "^23.3.1",
"@types/node": "^10.5.7",
"jest": "^23.4.2",
"ts-jest": "^23.1.3",
+ "tslint": "^5.11.0",
"typescript": "^3.0.1"
}
}
diff --git a/tsconfig.json b/tsconfig.json
index 8dc1429..563ad8b 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,5 +1,12 @@
{
"compilerOptions": {
"strict": true
- }
+ },
+ "include": [
+ "novice/**/*.ts"
+ ],
+ "exclude": [
+ "node_modules",
+ "**/*.test.ts"
+ ]
}
diff --git a/tslint.json b/tslint.json
new file mode 100644
index 0000000..c02ae02
--- /dev/null
+++ b/tslint.json
@@ -0,0 +1,11 @@
+{
+ "defaultSeverity": "error",
+ "extends": [
+ "tslint:recommended"
+ ],
+ "jsRules": {},
+ "rules": {
+ "quotemark": [true, "single", "avoid-escape"]
+ },
+ "rulesDirectory": []
+}