diff --git a/js/main.ts b/js/main.ts index d2d61f419c..5b32c60494 100644 --- a/js/main.ts +++ b/js/main.ts @@ -1,6 +1,7 @@ +// tslint:disable-next-line:no-reference /// -import { deno as pb } from "./msg.pb"; import * as ts from "typescript"; +import { deno as pb } from "./msg.pb"; const globalEval = eval; const window = globalEval("this"); @@ -8,7 +9,7 @@ const window = globalEval("this"); window["denoMain"] = () => { deno.print(`ts.version: ${ts.version}`); const res = deno.pub("startDeno2", emptyArrayBuffer()); - //deno.print(`after`); + // deno.print(`after`); const resUi8 = new Uint8Array(res); deno.print(`before`); const msg = pb.Msg.decode(resUi8); diff --git a/js/package.json b/js/package.json index 60199e6093..3451843c94 100644 --- a/js/package.json +++ b/js/package.json @@ -2,15 +2,17 @@ "devDependencies": { "@types/base64-js": "^1.2.5", "@types/source-map-support": "^0.4.1", + "espree": "^3.5.3", + "jsdoc": "^3.5.5", + "minimist": "^1.2.0", "parcel-bundler": "^1.8.1", "protobufjs": "^6.8.6", - "typescript": "^2.9.1", - - "jsdoc": "^3.5.5", "tmp": "0.0.33", - "uglify-js": "^2.8.29", - "espree": "^3.5.3", - "minimist": "^1.2.0" + "tslint": "^5.10.0", + "tslint-eslint-rules": "^5.3.1", + "tslint-no-circular-imports": "^0.5.0", + "typescript": "^2.9.1", + "uglify-js": "^2.8.29" }, "browserslist": [ "chrome 69" diff --git a/js/yarn.lock b/js/yarn.lock index 412b8c005c..8daa08843a 100644 --- a/js/yarn.lock +++ b/js/yarn.lock @@ -200,7 +200,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: @@ -855,6 +855,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" @@ -917,7 +921,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: @@ -1056,6 +1060,10 @@ commander@^2.11.0, commander@^2.9.0: version "2.15.1" resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" +commander@^2.12.1: + version "2.16.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.16.0.tgz#f16390593996ceb4f3eeb020b31d78528f7f8a50" + commander@~2.13.0: version "2.13.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c" @@ -1349,6 +1357,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" @@ -1357,6 +1369,13 @@ diffie-hellman@^5.0.0: miller-rabin "^4.0.0" randombytes "^2.0.0" +doctrine@0.7.2: + version "0.7.2" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-0.7.2.tgz#7cb860359ba3be90e040b26b729ce4bfa654c523" + dependencies: + esutils "^1.1.6" + isarray "0.0.1" + dom-serializer@0: version "0.1.0" resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.1.0.tgz#073c697546ce0780ce23be4a28e293e40bc30c82" @@ -1515,6 +1534,10 @@ estraverse@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" +esutils@^1.1.6: + version "1.1.6" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-1.1.6.tgz#c01ccaa9ae4b897c6d0c3e210ae52f3c7a844375" + esutils@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" @@ -1669,7 +1692,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: @@ -2060,7 +2083,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.12.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1" dependencies: @@ -3150,6 +3173,12 @@ resolve@^1.1.5, resolve@^1.4.0: dependencies: path-parse "^1.0.5" +resolve@^1.3.2: + version "1.8.1" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26" + dependencies: + path-parse "^1.0.5" + ret@~0.1.10: version "0.1.15" resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" @@ -3603,6 +3632,55 @@ 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.9.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8" + +tslib@^1.7.1, tslib@^1.8.0, tslib@^1.8.1: + version "1.9.3" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" + +tslint-eslint-rules@^5.3.1: + version "5.3.1" + resolved "https://registry.yarnpkg.com/tslint-eslint-rules/-/tslint-eslint-rules-5.3.1.tgz#10dec4361df0b3e4385d91ff8e0226bda4ec2ad4" + dependencies: + doctrine "0.7.2" + tslib "1.9.0" + tsutils "2.8.0" + +tslint-no-circular-imports@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/tslint-no-circular-imports/-/tslint-no-circular-imports-0.5.0.tgz#dce659c024165fc1bdd39a6f01479eb4be33cffe" + +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.8.0: + version "2.8.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.8.0.tgz#0160173729b3bf138628dd14a1537e00851d814a" + dependencies: + tslib "^1.7.1" + +tsutils@^2.12.1: + version "2.27.1" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.27.1.tgz#ab0276ac23664f36ce8fd4414daec4aebf4373ee" + 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" diff --git a/tools/lint.sh b/tools/lint.sh index 5822a1cb6c..54bc43f94e 100755 --- a/tools/lint.sh +++ b/tools/lint.sh @@ -1,6 +1,5 @@ #!/bin/sh # TODO(ry) Rewrite this script in python for portability to Windows. -# TODO(ry) Call tslint here too. set -e cd `dirname "$0"`/.. ./third_party/cpplint/cpplint.py \ @@ -9,3 +8,4 @@ cd `dirname "$0"`/.. src/*.cc \ src/*.h \ src/include/*.h +node ./js/node_modules/.bin/tslint -p . diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000000..1974d758aa --- /dev/null +++ b/tslint.json @@ -0,0 +1,108 @@ +{ + "extends": [ + "tslint-eslint-rules", "tslint-no-circular-imports" + ], + "rules": { + "align": [ + true, + // TODO "arguments", + // TODO "elements", + "members", + "parameters", + "statements" + ], + "array-bracket-spacing": [true, "never"], + "array-type": [true, "array-simple"], + "arrow-return-shorthand": true, + "ban": [true, + {"name": "parseInt", "message": "tsstyle#type-coercion"}, + {"name": "parseFloat", "message": "tsstyle#type-coercion"}, + {"name": "Array", "message": "tsstyle#array-constructor"} + ], + "ban-types": [true, + ["Object", "Use {} instead."], + ["String", "Use 'string' instead."], + ["Number", "Use 'number' instead."], + ["Boolean", "Use 'boolean' instead."] + ], + "brace-style": [true, "1tbs", { "allowSingleLine": true }], + "block-spacing": [true, "always"], + "class-name": true, + "comment-format": [true, "check-space"], + "curly": [true, "ignore-same-line"], + "eofline": true, + "forin": true, + "ter-func-call-spacing": true, + "indent": [true, "spaces", 2], + "interface-name": [true, "never-prefix"], + "jsdoc-format": true, + "label-position": true, + "linebreak-style": [true, "LF"], + "max-line-length": { "options": [80] }, + "member-access": [true, "no-public"], + "new-parens": true, + "no-angle-bracket-type-assertion": true, + //"no-any": true, + "no-arg": true, + "no-conditional-assignment": true, + "no-consecutive-blank-lines": true, + "no-construct": true, + "no-debugger": true, + "no-default-export": true, + "no-duplicate-variable": true, + "no-inferrable-types": true, + "no-irregular-whitespace": true, + "no-namespace": [true, "allow-declarations"], + "no-multi-spaces": true, + "no-reference": true, + "no-string-throw": true, + "no-trailing-whitespace": true, + "no-unused-expression": true, + "no-var-keyword": true, + "object-literal-shorthand": true, + "object-literal-sort-keys": [true, "match-declaration-order"], + "one-line": [true, "check-catch", "check-finally", "check-else"], + //"only-arrow-functions": [true, "allow-declarations", "allow-named-functions"], + "ordered-imports": true, + "quotemark": [true, "double"], + "prefer-const": true, + "radix": true, + // https://github.com/buzinas/tslint-eslint-rules/issues/318 + // "space-before-blocks": true, + "space-before-function-paren": false, + "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" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-module", + "check-separator", + "check-rest-spread", + "check-type", + "check-typecast", + "check-type-operator", + "check-preblock" + ] + }, + "jsRules": { + "max-line-length": { "options": [80] }, + "linebreak-style": [true, "LF"], + "indent": [true, "spaces", 2] + }, + "linterOptions": { + "exclude": [ + "js/msg.pb.js" + ] + } +}