lint: Add TypeScript compiler as a linter.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2019-07-20 11:40:36 -07:00 committed by Tim Abbott
parent 40e8fd24ff
commit ecfb7c6a7f
8 changed files with 20 additions and 6 deletions

View File

@ -106,6 +106,8 @@ following checks:
- Running `mypy` to check static types in Python code. Our
[documentation on using mypy](../testing/mypy.html) covers mypy in
more detail.
- Running `tsc` to compile TypeScript code. Our [documentation on
TypeScript](typescript.html) covers TypeScript in more detail.
The rest of this document pertains to the checks that occur in `./tools/lint`.

View File

@ -32,11 +32,11 @@ The following resources are valuable for learning TypeScript:
## Type checking
TypeScript types are checked primarily via `webpack`, so you'll see
typing errors in red in your `run-dev.py` console as you do
development.
TODO: Document command for running the type check manually.
TypeScript types are checked by the TypeScript compiler, `tsc`, which
is run as part of our [lint checks](linters.html). You can run the
compiler yourself with `tools/run-tsc`, which will check all the
TypeScript files once, or `tools/run-tsc --watch`, which will
continually recheck the files as you edit them.
## Linting and style

View File

@ -60,6 +60,7 @@
"zxcvbn": "4.4.2"
},
"devDependencies": {
"@types/source-map": "0.5.2",
"@typescript-eslint/eslint-plugin": "^1.12.0",
"@typescript-eslint/parser": "^1.12.0",
"casperjs": "casperjs/casperjs",

View File

@ -7,6 +7,7 @@
// "incremental": true,
/* Basic options */
"noEmit": true,
"target": "es5",
"module": "es6",
"jsx": "preserve",

View File

@ -84,6 +84,8 @@ def run():
command.append('--force')
linter_config.external_linter('mypy', command, ['py'], pass_targets=False,
description="Static type checker for Python (config: mypy.ini)")
linter_config.external_linter('tsc', ['tools/run-tsc'], ['ts'], pass_targets=False,
description="TypeScript compiler (config: static/js/tsconfig.json)")
linter_config.external_linter('gitlint', ['tools/commit-message-lint'],
description="Checks commit messages for common formatting errors."
"(config: .gitlint)")

3
tools/run-tsc Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
ZULIP_PATH="$(dirname "$0")/.."
exec "$ZULIP_PATH/node_modules/.bin/tsc" --project "$ZULIP_PATH/static/js" "$@"

View File

@ -26,4 +26,4 @@ LATEST_RELEASE_ANNOUNCEMENT = "https://blog.zulip.org/2019/03/01/zulip-2-0-relea
# historical commits sharing the same major version, in which case a
# minor version bump suffices.
PROVISION_VERSION = '42.0'
PROVISION_VERSION = '42.1'

View File

@ -329,6 +329,11 @@
"@types/express-serve-static-core" "*"
"@types/mime" "*"
"@types/source-map@0.5.2":
version "0.5.2"
resolved "https://registry.yarnpkg.com/@types/source-map/-/source-map-0.5.2.tgz#973459e744cc7445c85b97f770275b479b138e08"
integrity sha512-++w4WmMbk3dS3UeHGzAG+xJOSz5Xqtjys/TBkqG3qp3SeWE7Wwezqe5eB7B51cxUyh4PW7bwVotpsLdBK0D8cw==
"@types/tapable@*":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.4.tgz#b4ffc7dc97b498c969b360a41eee247f82616370"