How to ignore a particular directory or file for tslint?
Solution 1
Update for tslint v5.8.0
As mentioned by Saugat Acharya, you can now update tslint.json CLI Options:
{
"extends": "tslint:latest",
"linterOptions": {
"exclude": [
"bin",
"lib/*generated.js"
]
}
}
More information in this pull request.
This feature has been introduced with tslint 3.6
tslint \"src/**/*.ts\" -e \"**/__test__/**\"
You can now add --exclude (or -e) see PR here.
CLI
usage: tslint [options] file ...
Options:
-c, --config configuration file
--force return status code 0 even if there are lint errors
-h, --help display detailed help
-i, --init generate a tslint.json config file in the current working directory
-o, --out output file
-r, --rules-dir rules directory
-s, --formatters-dir formatters directory
-e, --exclude exclude globs from path expansion
-t, --format output format (prose, json, verbose, pmd, msbuild, checkstyle) [default: "prose"]
--test test that tslint produces the correct output for the specified directory
-v, --version current version
you are looking at using
-e, --exclude exclude globs from path expansion
Solution 2
Currently using Visual Studio Code and the command to disable tslint is
/* tslint:disable */
Something to note. The disable above disables ALL tslint rules on that page. If you want to disable a specific rule you can specify one/multiple rules.
/* tslint:disable comment-format */
/* tslint:disable:rule1 rule2 rule3 etc.. */
Or enable a rule
/* tslint:enable comment-format */
More in depth on TSLint rule flags
Solution 3
In addition to Michael's answer, consider a second way: adding linterOptions.exclude to tslint.json
For example, you may have tslint.json
with following lines:
{
"linterOptions": {
"exclude": [
"someDirectory/*.d.ts"
]
}
}
Solution 4
Starting from tslint v5.8.0
you can set an exclude
property under your linterOptions
key in your tslint.json
file:
{
"extends": "tslint:latest",
"linterOptions": {
"exclude": [
"bin",
"**/__test__",
"lib/*generated.js"
]
}
}
More information on this here.
Solution 5
I had to use the **/* syntax to exclude the files in a folder:
"linterOptions": {
"exclude": [
"src/auto-generated/**/*",
"src/app/auto-generated/**/*"
]
},
Related videos on Youtube
user3330840
Updated on November 12, 2020Comments
-
user3330840 over 3 years
The IDE being used is WebStorm 11.0.3, the tslint is configured and works, but, it hangs because it tries to parse large *.d.ts library files.
Is there a way to ignore a particular file or directory?
-
Juan Henao over 7 yearsdo you know how to exclude multiple paths?
-
Markus Wagner over 7 yearsrepeat the exclude argument several times
-
Andres Elizondo over 6 yearsThis should be marked as the correct (and updated Nov-2017) answer.
-
JeB over 6 yearsSmall correction to the update: it should be
linterOptions
and notcliOptions
-
JeB over 6 yearsIt's also worth to mention that the glob patterns inside the exclude directory shall be relative to the
tslint.json
-
Saugat about 5 yearsThe correct way to do this is to replace
cliOptions
withlinterOptions
. -
Oz Lodriguez about 5 yearsfrom all of the answers, this is the only one that worked. thanks!
-
Dharman over 4 yearsWere you referring to some other answer, or did you simply wanted to provide an alternative answer to the question?