:
{
"extends": "tslint:recommended"
}
는 팔란 기본값을 사용합니다. 나는베이스 라인으로 tslint-microsoft-contrib을 사용했다.
"extends": "tslint-microsoft-contrib",
확실히 모든 방식으로 도움이됩니다. 그러나 AngularJs TypeScript 코드의 경우 일부 규칙을 재구성하거나 해제해야합니다. 내가 함수 이름, member-ordering, no-import-side-effect 및 no-unsafe-any의 구성을 다음과 같이 변경했다 : 당신이 AngularJS와 구성 요소를 정의하는 방법에 따라
"function-name": [
true,
{
// allow public methods to start with $ for $onChanges
// and other Angular lifecycle hooks
"method-regex": "^[a-z$][\\w\\d]+$",
// otherwise unchanged
"private-method-regex": "^[a-z][\\w\\d]+$",
"protected-method-regex": "^[a-z][\\w\\d]+$",
"static-method-regex": "^[A-Z_\\d]+$",
"function-regex": "^[a-z][\\w\\d]+$"
}
],
// Variant ordering that places public statics before constructor
// So we can place AngularJs $inject just before the constructor
"member-ordering": [
true,
{
"order": [
"public-instance-field",
"protected-instance-field",
"private-instance-field",
"public-static-field",
"protected-static-field",
"private-static-field",
"constructor",
"public-static-method",
"protected-static-method",
"private-static-method",
"public-instance-method",
"protected-instance-method",
"private-instance-method"
]
}
],
// angular.module(...).component(...) is a side-effect
"no-import-side-effect": false,
// ng.IController, among others in @types/angular, uses "any"
// and is flagged by this rule
"no-unsafe-any": false,
을 false로 노 수입 부작용을 설정하지하지 않아도됩니다. TypeScript에서 AngularJs 구성 요소를 정의하는 최선의 방법에 대한 합의를 보지 못했습니다. AngularJs에서 Angular 2+로 마이그레이션하기위한 1 단계로 나열된 것이 유감입니다.
슬프게도, AngularJs가 모범 사례와 일치하도록 사용자 지정 tslint 규칙이 누락 될 수 있습니다. 생성 된 코드에서 eslint-plugin-angular을 실행하거나 이러한 규칙을 TypeScript로 변환하는 아이디어를 가지고 놀고 있습니다. 그러나 더 좋은 해결책은 Angular 2+로 이전하고 codelyzer을 사용하는 것입니다.