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 - Running `mypy` to check static types in Python code. Our
[documentation on using mypy](../testing/mypy.html) covers mypy in [documentation on using mypy](../testing/mypy.html) covers mypy in
more detail. 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`. 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 ## Type checking
TypeScript types are checked primarily via `webpack`, so you'll see TypeScript types are checked by the TypeScript compiler, `tsc`, which
typing errors in red in your `run-dev.py` console as you do is run as part of our [lint checks](linters.html). You can run the
development. compiler yourself with `tools/run-tsc`, which will check all the
TypeScript files once, or `tools/run-tsc --watch`, which will
TODO: Document command for running the type check manually. continually recheck the files as you edit them.
## Linting and style ## Linting and style

View File

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

View File

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

View File

@ -84,6 +84,8 @@ def run():
command.append('--force') command.append('--force')
linter_config.external_linter('mypy', command, ['py'], pass_targets=False, linter_config.external_linter('mypy', command, ['py'], pass_targets=False,
description="Static type checker for Python (config: mypy.ini)") 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'], linter_config.external_linter('gitlint', ['tools/commit-message-lint'],
description="Checks commit messages for common formatting errors." description="Checks commit messages for common formatting errors."
"(config: .gitlint)") "(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 # historical commits sharing the same major version, in which case a
# minor version bump suffices. # minor version bump suffices.
PROVISION_VERSION = '42.0' PROVISION_VERSION = '42.1'

View File

@ -329,6 +329,11 @@
"@types/express-serve-static-core" "*" "@types/express-serve-static-core" "*"
"@types/mime" "*" "@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@*": "@types/tapable@*":
version "1.0.4" version "1.0.4"
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.4.tgz#b4ffc7dc97b498c969b360a41eee247f82616370" resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.4.tgz#b4ffc7dc97b498c969b360a41eee247f82616370"