How to ignore/exclude some files/directory from linting in angular cli

前端 未结 3 1668
难免孤独
难免孤独 2021-02-03 18:27

Similar to this question

I am running the following command to linting my angular2 typeScript code.

ng lint

It is proving all the lint

相关标签:
3条回答
  • 2021-02-03 19:06

    Figured out it HAS to be a blob pattern..

    If you want multiple files/directories just use an array in your .angular-cli.json

    "exclude": [
     "**/*whatever.pipe.ts", 
     "**/*whatever_else.component.ts"
    ]
    
    0 讨论(0)
  • 2021-02-03 19:18

    Your angular-cli.json file would be like this-

    "lint": [
        {
          "project": "src/tsconfig.app.json",
          "exclude": "**/node_modules/**"
        },
        {
          "project": "src/tsconfig.spec.json",
          "exclude": "**/node_modules/**"
        },
        {
          "project": "e2e/tsconfig.e2e.json",
          "exclude": "**/node_modules/**"
        }
      ]
    

    You need to remove the lint path for "src/tsconfig.spec.json". So either remove the second object or comment it. Your updated lint array should be like this-

    "lint": [
        {
          "project": "src/tsconfig.app.json",
          "exclude": "**/node_modules/**"
        },
        {
          "project": "e2e/tsconfig.e2e.json",
          "exclude": "**/node_modules/**"
        }
      ]
    
    0 讨论(0)
  • 2021-02-03 19:24

    From Angular6+, .angular-cli.json has been replaced by angular.json, but you can still add the exclude path in its lint part.

    "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"      // excluded directories
            ]
          }
        }
    

    According to the angular-cli issue#5063, you can add the exclude path in .angular-cli.json like this:

    "lint": [
    {
      "project": "src/tsconfig.app.json",
      "exclude": "**/node_modules/**/*"   // the node_modules for example
    }]
    
    0 讨论(0)
提交回复
热议问题