Created
October 19, 2018 01:34
-
-
Save sin-tanaka/b18bf1b5b46bd685fee93bd26fb473b3 to your computer and use it in GitHub Desktop.
TSLint v5.7.0 時点で指定できる全 rules を網羅した。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
// tslint.json : https://palantir.github.io/tslint/ | |
{ | |
// Type Checking を有効にする (true) | |
"lintOptions": { | |
"typeCheck": true | |
}, | |
// カスタムルールの参照先 | |
"rulesDirectory": [ | |
"node_modules/codelyzer" | |
], | |
// TSLint Rules : https://palantir.github.io/tslint/rules/ https://azriton.github.io/2017/09/16/TypeScript%E3%81%AEtslint.json%E3%82%92%E8%AA%BF%E3%81%B9%E3%82%8B/ | |
"rules": { | |
// 関数のオーバーロードを強制する (true) | |
"adjacent-overload-signatures": true, | |
// 垂直方向の位置揃えを行わない (false) | |
"align": false, | |
// 配列の型定義を強制しない (false) | |
"array-type": false, | |
// アロー関数の仮引数にカッコを強制する (true) | |
"arrow-parens": true, | |
// Promise でない awaited な値を警告する (true) : 要 --type-check | |
"await-promise": true, | |
// 指定のオブジェクトの指定のメソッドの使用を禁止しない (false) | |
"ban": false, | |
// 指定の型の仕様を禁止する | |
"ban-types": false, | |
// 「() => { return x; }」という書き方を「() => x」と短く書くよう奨めない (false) | |
"arrow-return-shorthand": false, | |
// 1 + x; という記述より x + 1; という記述を推奨する (true) | |
"binary-expression-operand-order": true, | |
// コールシグネチャのみのインターフェース名やリテラル型は関数型を使用させる (true) | |
"callable-types": true, | |
// クラス名とインターフェース名がパスカルケースであること (true) | |
"class-name": true, | |
// 1行コメントのフォーマットを有効にする (true) | |
"comment-format": [ | |
true, | |
// スラッシュ2つの後にスペースかスラッシュを書いていること | |
"check-space" | |
], | |
// ドキュメンテーションコメントを強制化しない (false) : 強制させる内容が多くなるので外しておく | |
"completed-docs": [ | |
false | |
], | |
// if・for・do・while の制御構文にブレースがあること (true) | |
"curly": true, | |
// 循環的複雑度を指定する (true) | |
"cyclomatic-complexity": [ | |
true, | |
20 | |
], | |
// 廃止された API を使用している場合に警告する (true) : 要 --type-check | |
"deprecation": true, | |
// UTF-8 エンコーディングを強制する (true) | |
"encoding": true, | |
// 最終行に空行があること (true) | |
"eofline": true, | |
// ファイルのヘッダにコメントを強制しない (false) | |
"file-header": [ | |
false | |
], | |
// for-in ループ内で if ステートメントを使用していること (true) | |
"forin": true, | |
// import したくないものを指定する (true) | |
"import-blacklist": [ | |
true, | |
"rxjs" | |
], | |
// import ステートメントの間にスペースがあること (true) | |
"import-spacing": true, | |
// インデントが 2 スペースであること (true・"spaces"・2) | |
"indent": [ | |
true, | |
"spaces", | |
2 | |
], | |
// インターフェース名を I から始めない (false) | |
"interface-name": [ | |
false | |
], | |
// タイプリテラルより Interface 定義を推奨する (true) | |
"interface-over-type-literal": true, | |
// ドキュメンテーションコメントが「/**」で始まり JSDoc のフォーマットに即していること (true) | |
"jsdoc-format": true, | |
// ラベルを do・for・while・switch ステートメントにのみ付与することを許可する (true) | |
"label-position": true, | |
// 改行コードを LF に指定する (true) | |
"linebreak-style": [ | |
true, | |
"LF" | |
], | |
// default import の名前を default export と同じ名前にする (true) : 要 --type-check | |
"match-default-export-name": true, | |
// 1ファイルあたりの最大クラス数を 5 つまでとする (true) | |
"max-classes-per-file": [ | |
true, | |
5 | |
], | |
// 1ファイルあたりの最大行数を1000行にする | |
"max-file-line-count": [ | |
true, | |
1000 | |
], | |
// 1行の最大桁数を120桁にする (true・120) | |
"max-line-length": [ | |
true, | |
120 | |
], | |
// public・protected・private をメンバ (変数・メソッド) に付与することを強制しない (false) | |
"member-access": false, | |
// クラスメンバの順序を指定する (true) : public → private・static → instance な順 | |
"member-ordering": [ | |
true, | |
{ | |
"order": [ | |
"public-static-field", | |
"protected-static-field", | |
"private-static-field", | |
"static-field", | |
"public-static-method", | |
"protected-static-method", | |
"private-static-method", | |
"static-method", | |
"public-instance-field", | |
"protected-instance-field", | |
"private-instance-field", | |
"instance-field", | |
"public-constructor", | |
"protected-constructor", | |
"private-constructor", | |
"constructor", | |
"public-instance-method", | |
"protected-instance-method", | |
"private-instance-method", | |
"instance-method" | |
] | |
} | |
], | |
// ステートメントにおける return 文の手前に空行を開ける (true) : return 文のみのブロックの場合は空行が開かない | |
"newline-before-return": true, | |
// new の前後のカッコにスペースを開ける (true) | |
"new-parens": true, | |
// <Type> より as Type と書かせる (true) | |
"no-angle-bracket-type-assertion": true, | |
// any 型の使用を許容する (false) | |
"no-any": false, | |
// arguments.callee を使用していないこと (true) | |
"no-arg": true, | |
// ビット演算子を使用していないこと (true) | |
"no-bitwise": true, | |
// x === true のような Boolean との比較を冗長的に書かせない (true) : 要 --type-check | |
"no-boolean-literal-compare": true, | |
// do・while・if・for の条件部分で代入を許容しない (true) : for 文の変数宣言部分での代入は許容される | |
"no-conditional-assignment": true, | |
// 空行が2行以上続かないこと (true) | |
"no-consecutive-blank-lines": true, | |
// console の指定メソッドを使用していないこと (true) : console の全てのメソッドを Ban する | |
"no-console": true, | |
// String・Number・Boolean のコンストラクタを呼んでいないこと (true) | |
"no-construct": true, | |
// debugger を呼んでいないこと (true) | |
"no-debugger": true, | |
// ES2015 の Default Exports を禁止する (true) : 必ず Named Exports にする | |
"no-default-export": true, | |
// 同じモジュールからの import 文の重複を許容しない (true) | |
"no-duplicate-imports": true, | |
// コンストラクタで super() が2回登場していないこと (true) | |
"no-duplicate-super": true, | |
// 同じスコープ内で同名の変数を複数回宣言していないこと (true) | |
"no-duplicate-variable": true, | |
// 空のブロックを許容しない (true) | |
"no-empty": true, | |
// 空の Interface を許容しない (true) | |
"no-empty-interface": true, | |
// eval を許容しない (true) | |
"no-eval": true, | |
// 関数が返す Promise のハンドリングを厳格にする (true) : 要 --type-check | |
"no-floating-promises": true, | |
// 配列への for-in ループを禁止する (true) : 要 --type-check | |
"no-for-in-array": true, | |
// 副作用のある import を避ける (true) | |
"no-import-side-effect": true, | |
// String・Number・Boolean と分かる変数の定義時に型定義を書いてもエラーにしない (false) : true にすると型定義時にエラー扱いになる・true にする際は typedef の設定と競合しないよう注意 | |
"no-inferrable-types": [ | |
false, | |
// 関数の引数 | |
"ignore-params" | |
], | |
// 型に空のオブジェクト {} を使用しない (true) | |
"no-inferred-empty-object-type": true, | |
// 内部モジュールを使用していないこと (true) | |
"no-internal-module": true, | |
// テンプレートリテラルでない文字列に「${」が登場したら警告する (true) | |
"no-invalid-template-strings": true, | |
// クラスの外側で this を使用させない (true) | |
"no-invalid-this": true, | |
// String とコメント以外のおかしなスペースを検知する (true) | |
"no-irregular-whitespace": true, | |
// マジックナンバーを禁止する (true) : デフォルトで -1・0・1 は許容されている・配列に許容したい数値を列挙できる | |
"no-magic-numbers": [ | |
true | |
], | |
// 1ファイル内でマージできる namespace を許容しない (true) | |
"no-mergeable-namespace": true, | |
// new の使い方をチェックする (true) | |
"no-misused-new": true, | |
// 内部 module・namespace を禁止する (true) : declare namespace … のみ許容する | |
"no-namespace": [ | |
true, | |
"allow-declarations" | |
], | |
// null でないアサーションを許容しない (true) | |
"no-non-null-assertion": true, | |
// null キーワードの使用を禁止しない (false) | |
"no-null-keyword": false, | |
// 型リテラルが型アサーション式に書かれるのを禁止する (true) | |
"no-object-literal-type-assertion": true, | |
// クラス・コンストラクタでのパラメータ・プロパティを禁止する (true) | |
"no-parameter-properties": true, | |
// 引数への代入を許可しない (true) | |
"no-parameter-reassignment": true, | |
// reference コメントによる import を禁止する (true) : ES2015 形式の import 構文を使う | |
"no-reference": true, | |
// reference タグによる import を禁止する (true) : ES2015 形式の import 構文を使う | |
"no-reference-import": true, | |
// require を使って Import していないこと (true) | |
"no-require-imports": true, | |
// 包含関係にあるスコープで同名の変数を使用しないこと (true) | |
"no-shadowed-variable": true, | |
// 配列内の「空カンマ」を禁止する (true) : const items = [,]; といったものをエラーにする | |
"no-sparse-arrays": true, | |
// obj['key'] のようにオブジェクトのプロパティに文字列を使ってアクセスすることを許容する (false) | |
"no-string-literal": false, | |
// プレーンテキストの throw を禁止し、Error をスローさせる (true) | |
"no-string-throw": true, | |
// サブモジュールの import を許容する (false) | |
"no-submodule-imports": false, | |
// switch 文でフォールスルーを許容しない (true) | |
"no-switch-case-fall-through": true, | |
// ES2015 以前のような使い方をしている不必要な this を禁止する (true) | |
"no-this-assignment": true, | |
// 行末に不要な空白がないこと (true) | |
"no-trailing-whitespace": true, | |
// メソッドがメソッド呼び出しの外で使われることを警告しない (false) | |
"no-unbound-method": false, | |
// 「x => f(x) 」は「f」と省略させない (false) | |
"no-unnecessary-callback-wrapper": false, | |
// var や let を undefined で初期化させない (true) | |
"no-unnecessary-initializer": true, | |
// 不要な名前空間の指定を指摘する (true) | |
"no-unnecessary-qualifier": true, | |
// 型アサーションが式の型を変更しない場合に警告する : 要 --type-check | |
"no-unnecessary-type-assertion": true, | |
// 動的な any の利用を警告しない (false) : 要 --type-check | |
"no-unsafe-any": false, | |
// finally 句で return・continue・break・throws を許容しない (true) | |
"no-unsafe-finally": true, | |
// 代入も関数呼び出しもされていない式がないこと (true) | |
"no-unused-expression": true, | |
// 使われていない変数がないことをチェックしない (false) : 要 --type-check・競合するオプションの警告が出るため切る・コンパイル時にチェックできるので tsconfig.json で指定する | |
"no-unused-variable": false, | |
// 変数を宣言前に使用していないことをチェックしない (false) : 要 --type-check・標準で未定義のグローバル変数が Cannot find name エラーになるため切っておく | |
"no-use-before-declare": false, | |
// var を使わないこと (true) | |
"no-var-keyword": true, | |
// require の戻り値は import で受け var で受け取らないこと (true) | |
"no-var-requires": true, | |
// void な関数を式の形で呼び出すことを許容する (false) | |
"no-void-expression": false, | |
// 「0.1」のような小数を記載する時に「.1」と書かせない (true) | |
"number-literal-format": true, | |
// オブジェクトリテラルのキーを文字列にするかしないかの設定を行わない (false) : 場合によるので強制化しない | |
"object-literal-key-quotes": false, | |
// オブジェクトリテラルの省略記法を推奨させない (false) | |
"object-literal-shorthand": false, | |
// オブジェクトリテラルのキーをアルファベット順に並べることを強制しない (false) | |
"object-literal-sort-keys": false, | |
// 特定の予約語が同じ行に並んでいること (true) | |
"one-line": [ | |
true, | |
// 予約後の直後の開始ブレース | |
"check-open-brace", | |
// try の終了ブレースと同じ行に catch があること | |
"check-catch", | |
// catch の終了ブレースと同じ行に finally があること | |
"check-finally", | |
// if の終了ブレースと同じ行に else があること | |
"check-else", | |
// 予約語の前にスペースがあること | |
"check-whitespace" | |
], | |
// 複数の変数を同時に宣言させない (true) : for ループ内の宣言時のみ複数の宣言を許容する | |
"one-variable-per-declaration": [ | |
true, | |
"ignore-for-loop" | |
], | |
// アロー関数のみを強制しない (false) : 無名の function() が書けなくなるため無効化 | |
"only-arrow-functions": false, | |
// import の順序指定を行う (true) | |
"ordered-imports": [ | |
true, | |
{ | |
"import-sources-order": "lowercase-first", | |
"named-imports-order": "lowercase-first" | |
} | |
], | |
// if・else-if・else に同じ条件式が登場するのを許容する (false) | |
"prefer-conditional-expression": false, | |
// 可能な限り const を使用すること (true) | |
"prefer-const": true, | |
// 要素アクセスのためだけに index を使用している for ループは for-of を使うよう推奨させない (false) | |
"prefer-for-of": false, | |
// this を使用しないクラス・メソッドを指摘する (true) | |
"prefer-function-over-method": true, | |
// 「foo: () => void」ではなく「foo(): void」を推奨する (true) | |
"prefer-method-signature": true, | |
// Object.assing() ではなく分割代入を使うよう奨める (true) | |
"prefer-object-spread": true, | |
// 単純な比較の場合に if 文より switch 文を推奨させない (false) | |
"prefer-switch": false, | |
// 文字列結合を行っている String があればテンプレートリテラルを推奨する (true) | |
"prefer-template": true, | |
// Promise を返す関数に async の付与を強制しない (false) : 要 --type-check | |
"promise-function-async": false, | |
// シングルクォートを使用すること (true・"single") | |
"quotemark": [ | |
true, | |
"single" | |
], | |
// parseInt() の引数に基数を渡すこと (true) | |
"radix": true, | |
// + 演算子で結合する両者の型を一致させなくても良い (false) : 要 --type-check | |
"restrict-plus-operands": false, | |
// return undefined ではなく return と記述させる (true) : 要 --type-check | |
"return-undefined": true, | |
// 文末にセミコロンがあること (true) | |
"semicolon": [ | |
true, | |
"always" | |
], | |
// function の手前のカッコのスペース設定 (true) | |
"space-before-function-paren": [ | |
true, | |
"never" | |
], | |
// カッコの中にスペースを入れる設定をしない (false) | |
"space-within-parens": false, | |
// boolean 式を厳格にしない (false) : 要 --type-check | |
"strict-boolean-expressions": false, | |
// 常に true or false になる式を許容しない (true) : 要 --type-check | |
"strict-type-predicates": true, | |
// switch 文には default case があること (true) | |
"switch-default": true, | |
// switch 文の最後は break で終わること (true) | |
"switch-final-break": [ | |
true, | |
"always" | |
], | |
// カンマを最後に付けるかのルールを強制する (true) | |
"trailing-comma": [ | |
true, | |
{ | |
"multiline": "always", | |
"singleline": "always" | |
} | |
], | |
// 厳密等価演算子を使用すること (true) | |
"triple-equals": true, | |
// カンマ区切りで複数書かずセミコロンで終わらせる (true) | |
"type-literal-delimiter": true, | |
// 型定義を強制する (true) : アロー関数の仮引数と変数は指定しない | |
"typedef": [ | |
true, | |
// 関数の戻り値 (void も省略しないこと) : インスタンスメソッドと function 定義の両方で必要になる・Promise の場合に記述が面倒になるので避ける | |
"call-signature", | |
// Class のメンバ変数 : 型推論で十分な場合が多いがこれを入れると型推論を許容しないので冗長になる | |
"member-variable-declaration", | |
// 関数定義の仮引数 | |
"parameter", | |
// Interface のプロパティの戻り値 | |
"property-declaration" | |
], | |
// 型定義のスペースを指定する (true) | |
"typedef-whitespace": [ | |
true, | |
{ | |
"call-signature": "nospace", | |
"index-signature": "nospace", | |
"parameter": "nospace", | |
"property-declaration": "nospace", | |
"variable-declaration": "nospace" | |
} | |
], | |
// typeof 演算子を使用する時は文字列との比較をすること (true) | |
"typeof-compare": true, | |
// union か optional/rest で統合できるオーバーロードを警告する (true) | |
"unified-signatures": true, | |
// 明示的に指定された型引数がその型パラメータのデフォルトである場合に警告する (true) : 要 --type-check | |
"use-default-type-parameter": true, | |
// NaN との比較ではなく isNaN(myVar) を使うようにする (true) | |
"use-isnan": true, | |
// 変数名をチェックする (true) | |
"variable-name": [ | |
true, | |
// ロウワーキャメルケースかアッパースネークケースのみ許容する | |
"check-format", | |
// 予約語の使用を禁止する | |
"ban-keywords" | |
], | |
// 指定の位置にスペースがあること (true) | |
"whitespace": [ | |
true, | |
// if・else・for・while の直後 | |
"check-branch", | |
// 変数宣言のイコールの前後 | |
"check-decl", | |
// 演算子の前後 | |
"check-operator", | |
// import・export 文 | |
"check-module", | |
// カンマ・セミコロンの後 | |
"check-separator", | |
// 変数の型指定の前 | |
"check-type", | |
// 型キャストの型とキャストされる変数の間 | |
"check-typecast" | |
], | |
// Angular 用 | |
// -------------------------------------------------------------------------------- | |
"component-class-suffix": true, | |
"component-selector": [ | |
true, | |
"element", | |
"app", | |
"kebab-case" | |
], | |
"directive-class-suffix": true, | |
"directive-selector": [ | |
true, | |
"attribute", | |
"app", | |
"camelCase" | |
], | |
"invoke-injectable": true, | |
"use-host-property-decorator": true, | |
"use-input-property-decorator": true, | |
"use-output-property-decorator": true, | |
"no-access-missing-member": true, | |
"no-input-rename": true, | |
"no-output-rename": true, | |
"use-life-cycle-interface": true, | |
"use-pipe-transform-interface": true, | |
"templates-use-public": true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment