-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tslint] lint typescript code #19105
Conversation
d0e0866
to
6811044
Compare
96ccc5b
to
8d8b66b
Compare
💚 Build Succeeded |
for (const Linter of [Eslint, Tslint]) { | ||
const filesToLint = Linter.pickFilesToLint(log, files); | ||
if (filesToLint.length > 0) { | ||
await Linter.lintFiles(log, filesToLint); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This current implementation doesn't attempt to run tslint at all if there is an error from eslint, so if you have lint failures in both .js and .ts files, you won't know that until you attempt to commit again after fixing the .js files. It should probably run both commands and show the results from each.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the same is true for file casing issues and eslint. If there are casing issues eslint is never run.
I'll put up a separate PR that updates the precommit hook to clearly log errors from multiple tasks and collect those errors into an appropriate exit code, but I personally think it's out of the scope of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I failed to get this to pick up projects located in |
@weltenwort just like our current eslint setup this isn't intended to lint things in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
💔 Build Failed |
jenkins, test this |
💚 Build Succeeded |
* [tslint] lint typescript code * [tslint] filter projects when running specific project * [dev/ts] use more explicit types * [dev/ts] add note about why using glob * [dev/ts] rely on ts, use fewer getters
6.x/6.4: 37487a8 |
Fixes #18780
Adds TSLint integration.
Running
node scripts/tslint
will run the linter on all TypeScript "projects" (defined bytsconfig.json
files). This script is also run as a part of testing anywhere eslint is run.Rules
In order to avoid lengthy debate about which rules to enable we have enabled:
tslint:recommended
presetno-unused-variable
rule (requires type information so it's not a part of the preset)prettier
We can open issues and have discussions about evolving these selections as we go.
Along with the default rules, a custom rule to ensure that license headers are added to files in the
x-pack
directory is in use.To avoid a massive number of changes in this PR
tslint.yaml
files have been added to the existing TypeScript projects to disable any rules that have violations.Type Checking
TSLint deprecated the ability to type-check while linting, and it's currently providing a different output than we get with the build because it includes files that are not shipped with the build. Rather than block TypeScript integration on this I discussed the options with @azasypkin and we both agree that the type checking done at build time is sufficient as a final check that must pass before files can be committed, that editor integrations are okay for development, and that people can run the
tsc
directly if they want more comprehensive type checking during development: