4

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.

Ramya S
  • 2,954
  • 5
  • 14
  • 24

2 Answers2

7

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"
    }
]
Al-Mothafar
  • 7,949
  • 7
  • 68
  • 102
  • Hey thanks for answering. I dont know why above solution is not working for me – Ramya S Feb 20 '18 at 14:30
  • @al-mothafar is "exclude" used to completely exclude the files from the project? The OP is asking to exclude them only from lint. – Marco Altieri Sep 22 '18 at 11:06
  • @MarcoAltieri where I mention that I exclude files from the project? the exclude line logically is inside `tsconfig.json` file inside `"lint": [ ..... ]` so it will configure tslint, not the project. – Al-Mothafar Sep 22 '18 at 11:45
  • @al-mothafar I think your answer needs to be complete. If you are suggesting to add the exclude in the lint section, you should at least mention it. – Marco Altieri Sep 22 '18 at 11:49
  • @MarcoAltieri I have editied my answer, hope this helps – Al-Mothafar Sep 22 '18 at 11:54
0

Finally this works for me

"lint": [
    {
      "project": "src/main/webapp/app/tsconfig.app.json",
      "exclude": ["**/node_modules/**", "**/src/main/assets/js/ngx-typeahead**"]
    }
Ramya S
  • 2,954
  • 5
  • 14
  • 24