Closed am11 closed 5 years ago
good suggestion. we'll look into it.
+1
For TSD I would like to generate this in the users typings folder when init-ing a new project.
+1
This is necessary to treat lint errors as blocking. I want my code to be linted, not vendor code.
+1
+1
+1 This is exactly the solution we need. We are getting a number of tslint errors on d.ts files. Being able to exclude both folders and specific files will be very important since we also do not want to lint code we didn't write.
I'm willing to give this a try but I'm not sure where to put it. Do we want this to be a cli-feature or do we want to support this in the library too? If in the library it is a bit weird because the lint() method returns a result object, so we need to return a kinda dummy empty result object. See here for a Work in Progress but yeah, not sure about the above stuff. https://github.com/DickvdBrink/tslint/compare/palantir:master...DickvdBrink:ignoreFile
We are using Visual Studio and the Web Essentials tooling. For us, the ideal workflow would be to specify a .tjshintignore file that would contain something like typings\
which would ignore all the d.ts files in that folder. I'm not exactly sure if Web Essentials is using the cli-feature or the library so it's hard for me to know. I'm actually now a bit confused, because I found this thread that seems to indicate a solution for this may already exist? https://github.com/madskristensen/WebEssentials2013/issues/617
I think they are using cli. https://github.com/madskristensen/WebEssentials2013/blob/aaa83c3f6f7c9b051d7ef34be8498c6b67f37fca/EditorExtensions/TypeScript/Linters/TsLintCompiler.cs
I think it is closed because someone created this issue, see quotes below:
Would you like to send them a feature request?
I see somebody already has. Thanks :-)
Ah, that makes sense. Misread that.
I think implementing it via the CLI is fine for now. folks using grunt-tslint can already exclude files via grunt's file/directory globbers.
We are also considering global exclusion for all node-based services in Web Essentials: https://github.com/madskristensen/WebEssentials2013/issues/589. Nonetheless, having that feature in tslint has its own significance.
Update: In web-essentials, the feature is shipped with nightly build v2.2.4.
any updates on this?
This seems like a relatively important feature that ought to be prioritized. Wanted to note interest in this feature from a SO question.
I don't especially think a .tslintignore
file is needed though, I prefer the simpler idea of adding a --exclude
CLI option.
Might be better to support this via tsconfig.json (#858) rather than re-implementing this in a CLI flag...
Hmm, the difficulty with that is that you may want to compile different files than you lint. So I could potentially see using tsconfig.json
and then also using --exclude
to not lint a few of the normally included files.
As opposed to CLI, would this not be a natural fit in the tslint.json file and then add an ignore check that parses the "ignorePaths" at https://github.com/palantir/tslint/blob/master/src/tslint.ts#L46?
+1
+1, a .tslintignore will be great
+1 for .tslintignore or add an option to ignore certain paths in tsconfig.json It could be similar to https://github.com/bbatsov/rubocop#includingexcluding-files
Do you need help implementing it?
As a first pass, we'll merge #1006 soon, which adds a simple CLI --exclude
option. Does that get you most of the way there? If you're using additional tooling on top of tslint
, then it probably has glob / exclude support (grunt / gulp / etc). How important is this to support in tslint.json
?
I no longer call tslint from NPM scripts but it may be important for those people who do since NPM does not provide (and I believe that it never will) a cross platform glob support.
I don't think it's a good idea to add options for files you want or don't want to lint in the tslint.json
file. It just doesn't seem like it fits there. It also isn't consistent with how jshint is configured. Yes, they are two different tools but they practically do the same thing. Since TS is a super set of JS there should be some consistency between the two. I'd rather have a .tslintignore
file (just like .jshintignore
) to maintain consistency between JS and TS. Keep it separate from tsconfig.json
since linting is not compiling.
+1 for the CLI option, it's a good start.
Wanted to mention that #1006 merged and was in a release a month or so ago, so if you're using the latest version of the TSLint CLI, you'll have an exclude
flag available for use.
+1
+1
+1
what are people +1'ing here? an --exclude
flag has been available in the CLI since v3.6 which allows you to exclude globs (files, paths, whatever).
@adidahiya It doesn't help with WebStorm, for example. There's no option to specify flags.
I understand, that it should be a feature request for WebStorm developers, but it's seems that it's super easy to implement on ts-lint side. And that is done for other linting libraries by default. So why not make it so?
@fyodorvi cool, I updated the issue title and description. We'd likely want to resolve the path of the .tslintignore
file the same way we resolve tslint.json
.
Pros / cons of a new file vs. making it a new field in tslint.json
?
There is a workaround for ones who want to use tslint with WebStorm:
You can put empty (with '{}' inside) tslint.json
file in your node_modules folder and enable 'Search for tslint.json` option in WS. That will completely reset all rules of tslint for node_modules folder, and it will be silent about vendor code (or you can add specific rules here if you want to)
I've been following this thread to be able to exclude files specifically using vscode (since before the name was changed to be .tslintignore specific). I wanted to let others know who are trying to integrate the exclude with vscode that there is a separate issue and recent PR for vscode-specific tslint excludes.
@adidahiya a field with an array of dirs or files inside tslint.json should suffice, i would rather not worry about another file to control this business when we already have a config file defined in a project.
@Karabur your workaround doesn't work for me, i even tried to add an empty rules object, am i missing something?
One file is enough. This would also fall in line with how tsconfig,json works.
An exclude
option in tslint.json
would be nice (only one file to use that way) and that is the name of the glob
ignore section of tsconfig.json
as well (yes tsconfig.json include / exclude now supports globs in TypeScript latest)
Anyone know what eslint does as I am sure they would have hit this too? :rose:
Right now, tslint.json
has no control over what is linted, it only controls how files are linted. In fact, depending on how you set things up, the TSLint CLI can actually lint different files by different rules all in the same run.
I'm not against an exclude
option in tslint.json
, but it might end up being a slight paradigm shift and would have to be thought about carefully.
P.S. Always happy to hear your feedback @basarat, was just reading your TS gitbook today 😉
I've just released a new version of alm with tslint intergrated with version 0.3.0
:heart:
After having it sit in my brain here is the summary of the design I've gone with for IDE integration and seems to work out beautifully:
tsconfig.json
are linted except for .d.ts
filestslint.json
should be determined using a findup
from tsconfig.json
. I've documented this here as well : https://basarat.gitbooks.io/alm/content/features/lint.html Feel free to use the ideas / source for any other IDE integrations :rose:
@basarat I think those choices sound perfect! I haven't tried alm yet, but I'll have to give it a try sometime soon 💻
Please stop posting +1 comments and use the built-in Github upvoting feature on the original issue description. I'm going to delete your +1 comments now.
Three years have passed, and this is still not implemented? How come, this is one of the most trivial and important features IMO.
Three years have passed, and this is still not implemented? How come, this is one of the most trivial and important features IMO.
It's OSS after all : if you want it, submit a PR.
The current problem for me is:
--exclude {node_modules,.git,cache}
The {}
operator does not works and I don't see any way how to exclude different directories...
@monolithed:
--exclude node_modules --exclude .git --exclude cache
should do what you want
Three years have passed, and this is still not implemented? How come, this is one of the most trivial and important features IMO.
It's OSS after all : if you want it, submit a PR.
I've submitted a PR: https://github.com/palantir/tslint/issues/2409
@abenhamdine any ideas whom I should ask to review?
Bumping a 3+ year old issue wanted by literally hundreds of people, with a working PR submitted, but no action for half a year.
Thanks for the bump. Note that the linked PR, #2409, is for a new config option in tslint.json
, which is not quite the same as the original issue (.tslintignore
file). It's a step in the right direction though; I've left some more CR comments.
+1 Options:
.tslintignore
to the folder to ignore. exclude
with a list of pathes / folders.
This would be nice.By the way, feature was released in tslint@5.8.0
Right. Example:
Create a folder in your project with name .vscode
and a file inside settings.json
.
{
"tslint.exclude": "**/app/models/**"
}
to ignore all files in /app/models/. Feel free to improve the expression. :)
+1
Update (2016/06/01)
--exclude
CLI flag is available since TSLint v3.6. This issue now tracks a feature request for a.tslintignore
file.Original issue
Cc: https://github.com/madskristensen/WebEssentials2013/issues/617
From JsHint docs, there are two flags for exclusion in cli options:
Please provide us the similar flags, so we can pass .tslintignore file to exclude files and folders when some batch / automated executor script runs lint on it.
See JsHint's implementation of this feature: cli.js#L182-L208 and its caller; gather function.