Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude all files under a directory in lint using angular CLI?

We can exclude node_modules in this way.

  "lint": [
        {
          "project": "src/main/webapp/app/file.json",
          "exclude": "**/node_modules/**"
        }
    ]

But how to exclude all files under a directory?

I tried below way. It is not working

"exclude": [
 "**/*whatever.pipe.ts", 
 "**/*whatever_else.component.ts"
]

So this is my current path for the directory "src/main/assets/js/ngx-typeahead"

I have to exclude all the files under this directory from linting.

How can i achieve that?

Any suggestions would be appreciated.

like image 578
Ramya S Avatar asked Oct 31 '25 15:10

Ramya S


1 Answers

You can do that by modifying your lint line inside tsconfig.json:

"lint": [
    {
        "exclude": [
            "src/main/assets/js/ngx-typeahead/**/*.ts", 
        ]
    }
]

This PATH/**/*.ts means all files under this path and any subdirectory inside with the extension .ts

And I believe "src/main/assets/js/ngx-typeahead/* will exclude all files under this path

Edit: Another option is to use tslint.json:

{
    "extends": "tslint:recommended",
    ......
    "linterOptions": { 
        "exclude": [
            "src/main/assets/js/ngx-typeahead/**/*.ts", 
        ]
    }
}

For more: https://palantir.github.io/tslint/usage/configuration/

Edit 2: I found this issue link for angular-cli specific linting, by providing what exactly you want to lint instead of linting the project with excludes!

inside .angular-cli.json provide lint option:

"lint": [{
      "files": "src/**/*.ts",
      "project": "src/tsconfig.app.json"
    },
    {
      "files": "src/**/*.ts",
      "project": "src/tsconfig.spec.json"
    },
    {
      "files": "src/**/*.ts",
      "project": "e2e/tsconfig.e2e.json"
    }
]
like image 191
Al-Mothafar Avatar answered Nov 03 '25 06:11

Al-Mothafar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!