palantir / tslint

:vertical_traffic_light: An extensible linter for the TypeScript language
http://palantir.github.io/tslint/
Apache License 2.0
5.91k stars 889 forks source link

Feature: ".tslintignore" file to exclude globs #73

Closed am11 closed 5 years ago

am11 commented 10 years ago

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:

--exclude

Allows you to specify directories which you DON'T want to be linted.

--exclude-path

Allows you to provide your own .jshintignore file. For example, you can point JSHint to your .gitignore file and use it instead of default .jshintignore.

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.

ashwinr commented 10 years ago

good suggestion. we'll look into it.

Bartvds commented 10 years ago

+1

For TSD I would like to generate this in the users typings folder when init-ing a new project.

jyboudreau commented 10 years ago

+1

This is necessary to treat lint errors as blocking. I want my code to be linted, not vendor code.

wwwlicious commented 10 years ago

+1

maxvasil commented 10 years ago

+1

rwhepburn commented 10 years ago

+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.

DickvdBrink commented 10 years ago

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

rwhepburn commented 10 years ago

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

DickvdBrink commented 10 years ago

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 :-)

rwhepburn commented 10 years ago

Ah, that makes sense. Misread that.

ashwinr commented 10 years ago

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.

am11 commented 10 years ago

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.

pgrm commented 8 years ago

any updates on this?

jkillian commented 8 years ago

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.

adidahiya commented 8 years ago

Might be better to support this via tsconfig.json (#858) rather than re-implementing this in a CLI flag...

jkillian commented 8 years ago

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.

ghost commented 8 years ago

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?

aegyed91 commented 8 years ago

+1

shaharmor commented 8 years ago

+1, a .tslintignore will be great

lukaselmer commented 8 years ago

+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?

adidahiya commented 8 years ago

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?

ghost commented 8 years ago

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.

Healforgreen commented 8 years ago

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.

jkillian commented 8 years ago

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.

ollwenjones commented 8 years ago

+1

mchambaud commented 8 years ago

+1

fyodorvi commented 8 years ago

+1

adidahiya commented 8 years ago

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).

fyodorvi commented 8 years ago

@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?

adidahiya commented 8 years ago

@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?

Karabur commented 8 years ago

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)

ghost commented 8 years ago

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.

slayerfat commented 8 years ago

@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?

ghost commented 8 years ago

One file is enough. This would also fall in line with how tsconfig,json works.

basarat commented 8 years ago

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:

jkillian commented 8 years ago

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 😉

basarat commented 8 years ago

I've just released a new version of alm with tslint intergrated with version 0.3.0 :heart:

linter

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:

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:

jkillian commented 8 years ago

@basarat I think those choices sound perfect! I haven't tried alm yet, but I'll have to give it a try sometime soon 💻

adidahiya commented 7 years ago

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.

maksimluzik commented 7 years ago

Three years have passed, and this is still not implemented? How come, this is one of the most trivial and important features IMO.

abenhamdine commented 7 years ago

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.

monolithed commented 7 years ago

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...

jkillian commented 7 years ago

@monolithed:

--exclude node_modules --exclude .git --exclude cache

should do what you want

mmkal commented 7 years ago

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?

machineghost commented 7 years ago

Bumping a 3+ year old issue wanted by literally hundreds of people, with a working PR submitted, but no action for half a year.

adidahiya commented 7 years ago

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.

Domvel commented 6 years ago

+1 Options:

saitonakamura commented 6 years ago

By the way, feature was released in tslint@5.8.0

Domvel commented 6 years ago

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. :)

paranoidjk commented 6 years ago

+1