k0pernikus
k0pernikus

Reputation: 66450

How to ignore *.d.ts files when using tslint?

I want to add tslint to my workflow. I installed it via:

npm install tslint tslint-config-ms-recommended --save-dev

And my tslint.json looks like:

{
    "extends": "tslint-config-ms-recommended"
}

Yet when I run:

./node_modules/.bin/tslint src/**/*.ts

it also checks a lot of definitely typed files, e.g.:

src/interfaces/highland.d.ts[621, 1]: space indentation expected
src/interfaces/highland.d.ts[622, 1]: space indentation expected
src/interfaces/highland.d.ts[635, 1]: space indentation expected

polluting the output.

I want to check only my *.ts files and am looking for a way to ignore the other types.

I saw that there was a --exclude option, yet it still shows the d.ts files when I run:

./node_modules/.bin/tslint src/**/*.ts --exclude src/**/*.d.ts

Upvotes: 2

Views: 7571

Answers (2)

k0pernikus
k0pernikus

Reputation: 66450

The exclude option either:

  • requires a =, so:
    • tslint src/**/*.ts --exclude=src/**/*.d.ts1
  • or requires wrapping the ignore part into quotes, so:
    • tslint src/**/*.ts --exclude "src/**/*.d.ts"
  • or a regex (thanks to fxlemire)
    • tslint src/**/*.ts --exclude src/**/*[^.d$].ts

will work as expected.

Upvotes: 9

punkbit
punkbit

Reputation: 7707

A very simple solution is to create a .eslintignore as follows:

*.d.ts

Include any other files you wish to ignore, for example:

node_modules
.storybook
dist
*.d.ts

Upvotes: 4

Related Questions