[javascript] How to ignore a particular directory or file for tslint?

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?

This question is related to javascript ide typescript webstorm tslint

The answer is


I had to use the **/* syntax to exclude the files in a folder:

    "linterOptions": {
        "exclude": [
          "src/auto-generated/**/*",
          "src/app/auto-generated/**/*"
        ]
    },

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


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"
    ]
  }
}

There are others who encountered the problem. Unfortunately, there is only an open issue for excluding files: https://github.com/palantir/tslint/issues/73

So I'm afraid the answer is no.


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.


Can confirm that on version tslint 5.11.0 it works by modifying lint script in package.json by defining exclude argument:

"lint": "ng lint --exclude src/models/** --exclude package.json"

Cheers!!


linterOptions is currently only handled by the CLI. If you're not using CLI then depending on the code base you're using you'll need to set the ignore somewhere else. webpack, tsconfig, etc


As an addition

To disable all rules for the next line // tslint:disable-next-line

To disable specific rules for the next line: // tslint:disable-next-line:rule1 rule2...

To disable all rules for the current line: someCode(); // tslint:disable-line

To disable specific rules for the current line: someCode(); // tslint:disable-line:rule1


add the section in your code example

"linterOptions": {
"exclude": [
  "node_modules/**/*.",
  "db/**/*.",
  "integrations/**/*."
]

},


Examples related to javascript

need to add a class to an element How to make a variable accessible outside a function? Hide Signs that Meteor.js was Used How to create a showdown.js markdown extension Please help me convert this script to a simple image slider Highlight Anchor Links when user manually scrolls? Summing radio input values How to execute an action before close metro app WinJS javascript, for loop defines a dynamic variable name Getting all files in directory with ajax

Examples related to ide

How can I view the Git history in Visual Studio Code? How to ignore a particular directory or file for tslint? How do I completely rename an Xcode project (i.e. inclusive of folders)? Where is the visual studio HTML Designer? How to disable gradle 'offline mode' in android studio? Android studio Error "Unsupported Modules Detected: Compilation is not supported for following modules" Android Studio was unable to find a valid Jvm (Related to MAC OS) QtCreator: No valid kits found Difference between WebStorm and PHPStorm package android.support.v4.app does not exist ; in Android studio 0.8

Examples related to typescript

TS1086: An accessor cannot be declared in ambient context Element implicitly has an 'any' type because expression of type 'string' can't be used to index Angular @ViewChild() error: Expected 2 arguments, but got 1 Typescript: No index signature with a parameter of type 'string' was found on type '{ "A": string; } Understanding esModuleInterop in tsconfig file How can I solve the error 'TS2532: Object is possibly 'undefined'? Typescript: Type 'string | undefined' is not assignable to type 'string' Typescript: Type X is missing the following properties from type Y length, pop, push, concat, and 26 more. [2740] Can't perform a React state update on an unmounted component TypeScript and React - children type?

Examples related to webstorm

How to import js-modules into TypeScript file? How to ignore a particular directory or file for tslint? Difference between WebStorm and PHPStorm How can I fix WebStorm warning "Unresolved function or method" for "require" (Firefox Add-on SDK) What is the .idea folder? Can IntelliJ IDEA encapsulate all of the functionality of WebStorm and PHPStorm through plugins? What to gitignore from the .idea folder?

Examples related to tslint

How to use `@ts-ignore` for a block In Typescript, what is the ! (exclamation mark / bang) operator when dereferencing a member? tslint / codelyzer / ng lint error: "for (... in ...) statements must be filtered with an if statement" How to ignore a particular directory or file for tslint?