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.

2 Answers 2

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"
    }
]
Sign up to request clarification or add additional context in comments.

5 Comments

Hey thanks for answering. I dont know why above solution is not working for me
@al-mothafar is "exclude" used to completely exclude the files from the project? The OP is asking to exclude them only from lint.
@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 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.
@MarcoAltieri I have editied my answer, hope this helps
0

Finally this works for me

"lint": [
    {
      "project": "src/main/webapp/app/tsconfig.app.json",
      "exclude": ["**/node_modules/**", "**/src/main/assets/js/ngx-typeahead**"]
    }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.