diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..4e3cbb5ec0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: go +go: + - 1.9.2 +cache: ccache +install: + - go get github.com/ry/v8worker2 + - cd `go env GOPATH`/src/github.com/ry/v8worker2 && ./tools/build.py + - make +script: + - make lint diff --git a/Makefile b/Makefile index 6ccc4781d5..6164ec8a4d 100644 --- a/Makefile +++ b/Makefile @@ -27,4 +27,8 @@ clean: distclean: clean -rm -rf node_modules/ -.PHONY: clean distclean +lint: node_modules + yarn lint + go vet + +.PHONY: lint clean distclean diff --git a/main.go b/main.go index 4612849db0..fe3ca39344 100644 --- a/main.go +++ b/main.go @@ -50,7 +50,6 @@ func loadAsset(w *v8worker2.Worker, path string) { func main() { worker := v8worker2.New(recv) loadAsset(worker, "dist/main.js") - loadMsg := &Msg{ Kind: Msg_LOAD, Argv: os.Args, @@ -63,5 +62,4 @@ func main() { if err != nil { panic(err) } - } diff --git a/main.ts b/main.ts index 3a6a043aba..eeba4702f0 100644 --- a/main.ts +++ b/main.ts @@ -1,5 +1,5 @@ //import * as ts from "typescript"; -import { main as pb } from "./msg.pb" +import { main as pb } from "./msg.pb"; import "./util"; import { TextDecoder } from "text-encoding"; @@ -16,14 +16,14 @@ function readFileSync(filename: string): string { throw Error(res.error); } const decoder = new TextDecoder("utf8"); - return decoder.decode(res.data) + return decoder.decode(res.data); } function load(argv: string[]): void { console.log("Load argv", argv); const inputFn = argv[1]; const source = readFileSync(inputFn); - console.log("source", source) + console.log("source", source); } V8Worker2.recv((ab: ArrayBuffer) => { diff --git a/package.json b/package.json index a4f93d7740..7ec00b9b91 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,14 @@ { "name": "deno", + "scripts": { + "lint": "tslint -p tsconfig.json" + }, "devDependencies": { "@types/text-encoding": "^0.0.32", "parcel-bundler": "^1.8.1", "protobufjs": "^6.8.6", "text-encoding": "^0.6.4", + "tslint": "^5.10.0", "typescript": "^2.8.3" } } diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000000..59d7bdaa8b --- /dev/null +++ b/tslint.json @@ -0,0 +1,61 @@ +{ + "rules": { + "array-type": [true, "array-simple"], + "arrow-return-shorthand": true, + "ban": [true, + ["fit"], + ["fdescribe"], + ["xit"], + ["xdescribe"], + ["fitAsync"], + ["xitAsync"], + ["fitFakeAsync"], + ["xitFakeAsync"] + ], + "ban-types": [true, + ["Object", "Use {} instead."], + ["String", "Use 'string' instead."], + ["Number", "Use 'number' instead."], + ["Boolean", "Use 'boolean' instead."] + ], + "class-name": true, + "curly": true, + "interface-name": [true, "never-prefix"], + "jsdoc-format": true, + "forin": false, + "label-position": true, + "max-line-length": [true, 80], + "new-parens": true, + "no-angle-bracket-type-assertion": true, + "no-any": true, + "no-construct": true, + "no-consecutive-blank-lines": true, + "no-debugger": true, + "no-default-export": true, + "no-inferrable-types": true, + "no-namespace": [true, "allow-declarations"], + "no-reference": true, + "no-require-imports": true, + "no-string-throw": true, + "no-unused-expression": true, + "no-unused-variable": true, + "no-var-keyword": true, + "object-literal-shorthand": true, + "only-arrow-functions": [true, "allow-declarations", "allow-named-functions"], + "prefer-const": true, + "quotemark": [true, "double"], + "radix": true, + "restrict-plus-operands": true, + "semicolon": [true, "always", "ignore-bound-class-methods"], + "switch-default": true, + "triple-equals": [true, "allow-null-check"], + "use-isnan": true, + "variable-name": [ + true, + "check-format", + "ban-keywords", + "allow-leading-underscore", + "allow-trailing-underscore" + ] + } +} diff --git a/util.ts b/util.ts index 4675152255..99fe798f46 100644 --- a/util.ts +++ b/util.ts @@ -9,9 +9,10 @@ const globalEval = eval; const _global = globalEval("this"); _global["console"] = { + // tslint:disable-next-line:no-any log(...args: any[]): void { const out: string[] = []; - for (let a of args) { + for (const a of args) { if (typeof(a) === "string") { out.push(a); } else { diff --git a/yarn.lock b/yarn.lock index d6e4f1bfa0..5874b85035 100644 --- a/yarn.lock +++ b/yarn.lock @@ -168,7 +168,7 @@ autoprefixer@^6.3.1: postcss "^5.2.16" postcss-value-parser "^3.2.3" -babel-code-frame@^6.26.0: +babel-code-frame@^6.22.0, babel-code-frame@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" dependencies: @@ -819,6 +819,10 @@ buffer@^4.3.0: ieee754 "^1.1.4" isarray "^1.0.0" +builtin-modules@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" + builtin-status-codes@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" @@ -864,7 +868,7 @@ chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.1.0, chalk@^2.4.1: +chalk@^2.1.0, chalk@^2.3.0, chalk@^2.4.1: version "2.4.1" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e" dependencies: @@ -987,7 +991,7 @@ command-exists@^1.2.6: version "1.2.6" resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.6.tgz#577f8e5feb0cb0f159cd557a51a9be1bdd76e09e" -commander@^2.11.0, commander@^2.9.0: +commander@^2.11.0, commander@^2.12.1, commander@^2.9.0: version "2.15.1" resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" @@ -1284,6 +1288,10 @@ detect-libc@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" +diff@^3.2.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" + diffie-hellman@^5.0.0: version "5.0.3" resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875" @@ -1586,7 +1594,7 @@ glob-parent@^3.1.0: is-glob "^3.1.0" path-dirname "^1.0.0" -glob@^7.0.5, glob@^7.1.2: +glob@^7.0.5, glob@^7.1.1, glob@^7.1.2: version "7.1.2" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: @@ -1973,7 +1981,7 @@ js-tokens@^3.0.0, js-tokens@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" -js-yaml@^3.10.0: +js-yaml@^3.10.0, js-yaml@^3.7.0: version "3.11.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.11.0.tgz#597c1a8bd57152f26d622ce4117851a51f5ebaef" dependencies: @@ -3015,7 +3023,7 @@ resolve-url@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" -resolve@^1.1.5, resolve@^1.4.0: +resolve@^1.1.5, resolve@^1.3.2, resolve@^1.4.0: version "1.7.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.7.1.tgz#aadd656374fd298aee895bc026b8297418677fd3" dependencies: @@ -3455,6 +3463,33 @@ trim-right@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" +tslib@^1.8.0, tslib@^1.8.1: + version "1.9.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8" + +tslint@^5.10.0: + version "5.10.0" + resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.10.0.tgz#11e26bccb88afa02dd0d9956cae3d4540b5f54c3" + dependencies: + 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.12.1" + +tsutils@^2.12.1: + version "2.27.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.27.0.tgz#9efb252b188eaa0ca3ade41dc410d6ce7eaab816" + dependencies: + tslib "^1.8.1" + tty-browserify@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"