tslint는 console.log에 대한 호출이 허용되지 않는다고 말합니다. 어떻게 허용합니까?
방금 typescript와 함께 create-react-app을 사용하기 시작했습니다.
create-react-app my-app --scripts-version=react-scripts-ts
기본 tslint.json 구성은 console.log ()를 허용하지 않습니다.
(현재로서는) 어떻게 console.log를 활성화 할 수 있습니까?
이에 대한 문서는 https://palantir.github.io/tslint/rules/no-console/에 있습니다. 그러나 그들은이 줄을 어디에 둘지 말하지 않습니다.
"no-console": [true, "log", "error"]
이 tslint.json 구성 파일 구문을 검색하고 찾았 으므로 다음을 시도했습니다.
"rules": {
"no-console": [true, "warning"]
}
경고 일 뿐인 로그 메시지를 얻으려는 시도. 그러나 그것은 작동하지 않았습니다.
내가 가지고있는 console.log () 줄 몇 개를 주석 처리했지만 앞으로이 작업을 수행 할 수 있기를 원합니다.
오류 메시지를 한 번만 방지하려면 // tslint:disable-next-line:no-console
호출 직전에 줄을 추가하십시오 console.log
.
규칙을 완전히 비활성화하려면 다음을 추가하십시오 tslint.json
(대부분 루트 폴더에 있음).
{
"rules": {
"no-console": false
}
}
자바 스크립트와 타이프 스크립트가 혼합 된 코드베이스로 여기에 오는 분들을 위해.
jsRules에서 'no-console'옵션을 정의해야 할 수도 있습니다. 자바 스크립트 파일을위한 jslints 규칙 객체는 javascript와 typescript를위한 별도의 규칙 객체가 있습니다.
//tslint.json
{
"extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"], //Example...
"rules": {
"no-console": false //Disable for typescript
},
"jsRules": {
"no-console": false //Disable for javascript
}
}
다음을 귀하의 tslint.json
{
"rules": {
"no-console": {
"severity": "warning",
}
}
}
콘솔 없음 규칙 (또는 해당 문제에 대한 다른 규칙)을 정의하는 올바른 구문이지만 오류가 아닌 경고 만 표시됩니다 (분명히 원하는대로 옵션을 변경).
"no-console": {
"severity": "warning",
"options": [
"log",
"error",
"debug",
"info",
"time",
"timeEnd",
"trace"
]
},
문서에 따르면 : https://eslint.org/docs/user-guide/getting-started#configuration
- "off"또는 0-규칙 해제
- "warn"또는 1-규칙을 경고로 설정 (종료 코드에 영향을주지 않음)
- "error" or 2 - turn the rule on as an error (exit code will be 1)
By the way, your correct setup would be
{
"rules": {
"no-console": false
}
}
'program story' 카테고리의 다른 글
분기를 전환 할 수없는 이유는 무엇입니까? (0) | 2020.10.16 |
---|---|
Android NDK (Native Development Kit) 란 무엇입니까? (0) | 2020.10.16 |
npm 오류! (0) | 2020.10.16 |
Django : ORM이 알고있는 모델 목록을 어떻게 찾을 수 있습니까? (0) | 2020.10.16 |
새로 추가 된 입력 요소에 집중 (0) | 2020.10.16 |