programing

tslint에 대해 특정 디렉토리 또는 파일을 무시하는 방법

css3 2023. 3. 6. 21:22

tslint에 대해 특정 디렉토리 또는 파일을 무시하는 방법

사용하고 있는 IDE는 WebStorm 11.0.3이며 tslint는 설정되어 동작하지만 큰 *.d.ts 라이브러리 파일을 해석하려고 하기 때문에 행업합니다.

특정 파일 또는 디렉토리를 무시하는 방법이 있습니까?

tslint v5.8.0 업데이트

Saugat Accharya에서 설명한 바와 같이 tslint.json CLI 옵션을 업데이트할 수 있습니다.

{
  "extends": "tslint:latest",
  "linterOptions": {
      "exclude": [
          "bin",
          "lib/*generated.js"
      ]
  }
}

요청에 대한 자세한 내용은 다음과 같습니다.


이 기능은 tslint 3.6에서 도입되었습니다.

tslint \"src/**/*.ts\" -e \"**/__test__/**\"

여기서 --exclude(또는 -e)를 추가할 수 있습니다.여기서 PR을 참조해 주세요.

CLI

usage: tslint [options] file ...

Options:

-c, --config          configuration file
--force               return status code 0 even if there are lint errors
-h, --help            display detailed help
-i, --init            generate a tslint.json config file in the current working directory
-o, --out             output file
-r, --rules-dir       rules directory
-s, --formatters-dir  formatters directory
-e, --exclude         exclude globs from path expansion
-t, --format          output format (prose, json, verbose, pmd, msbuild, checkstyle)  [default: "prose"]
--test                test that tslint produces the correct output for the specified directory
-v, --version         current version

를 사용하려고 합니다.

-e, --exclude         exclude globs from path expansion

현재 Visual Studio 코드와 tslint를 사용하지 않도록 설정하는 명령은 다음과 같습니다.

/* tslint:disable */

주의할 게 있어요.위의 disable은 해당 페이지의 모든 tslint 규칙을 디세블로 합니다.특정 규칙을 비활성화하려면 하나 또는 여러 규칙을 지정할 수 있습니다.

/* tslint:disable comment-format */
/* tslint:disable:rule1 rule2 rule3 etc.. */

또는 규칙을 유효하게 합니다.

/* tslint:enable comment-format */

TSLint 규칙 플래그의 상세

Michael의 답변 외에 두 번째 방법인 tslint.json에 linterOptions.exclude를 추가합니다.

예를 들어 다음과 같은 경우가 있습니다.tslint.json다음 행이 표시됩니다.

{
  "linterOptions": {
    "exclude": [
      "someDirectory/*.d.ts"
    ]
  }
}

시작점tslint v5.8.0를 설정할 수 있습니다.exclude고객님의 소유의linterOptions키를 누르다tslint.json파일:

{
  "extends": "tslint:latest",
  "linterOptions": {
      "exclude": [
          "bin",
          "**/__test__",
          "lib/*generated.js"
      ]
  }
}

자세한 내용은 여기를 참조하십시오.

폴더 내의 파일을 제외하려면 **/* 구문을 사용해야 했습니다.

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

추가로서

다음 줄에 대한 모든 규칙을 실행 중지하려면 // tslint:disable-next-line

다음 줄에 대해 특정 규칙을 비활성화하려면:// tslint:disable-next-line:rule1 rule2...

현재 행의 모든 규칙을 비활성화하려면:someCode(); // tslint:disable-line

현재 행의 특정 규칙을 비활성화하려면:someCode(); // tslint:disable-line:rule1

문제가 발생한 다른 사용자가 있습니다.유감스럽게도 파일 제외에 관한 미해결 문제는 https://github.com/palantir/tslint/issues/73 뿐입니다.

유감스럽지만 대답은 '아니오'입니다

linterOptions는 현재 CLI에서만 처리됩니다.CLI 를 사용하지 않는 경우는, 사용하고 있는 코드 베이스에 따라서는, ignore 를 다른 장소에서 설정할 필요가 있습니다.webpack, tsconfig 등

버전 tslint 5.11.0에서는 패키지의 보풀스크립트를 수정함으로써 동작하는 것을 확인할 수 있습니다.exclude 인수를 정의하여 json:

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

건배!!

코드 예제에 섹션 추가

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

언급URL : https://stackoverflow.com/questions/34578677/how-to-ignore-a-particular-directory-or-file-for-tslint