ESLint : TSLint からの代替ルール
この文書は、TSLintからの移行を支援するためのガイドです。すべてのTSLintルールを、同じまたは類似のESLintエコシステムのルールと並べて一覧にしています。
TSLintの設定を最も近いESLintの設定に移行するツールについては、
tslint-to-eslint-config
を参照してください。
TSLint rules
✅ = 完了
🌟 = ESLintコアに含まれている
🔌 = 別のプラグインに含まれている
🌓 = 実装が異なるか、ESLintのバージョンに機能が不足している
🛑 = 未実装
TypeScript専用
TSLint rule | ESLint rule | |
---|---|---|
[adjacent-overload-signatures ] |
✅ | [@typescript-eslint/adjacent-overload-signatures ] |
[ban-ts-ignore ] |
✅ | [@typescript-eslint/ban-ts-comment ] |
[ban-types ] |
🌓 | [@typescript-eslint/no-restricted-types ][1]
|
[invalid-void ] |
✅ | [@typescript-eslint/no-invalid-void-type ] |
[member-access ] |
✅ | [@typescript-eslint/explicit-member-accessibility ] |
[member-ordering ] |
✅ | [@typescript-eslint/member-ordering ] |
[no-any ] |
✅ | [@typescript-eslint/no-explicit-any ] |
[no-empty-interface ] |
✅ | [@typescript-eslint/no-empty-object-type ] |
[no-import-side-effect ] |
🔌 | [import/no-unassigned-import ] |
[no-inferrable-types ] |
✅ | [@typescript-eslint/no-inferrable-types ] |
[no-internal-module ] |
✅ | [@typescript-eslint/prefer-namespace-keyword ] |
[no-magic-numbers ] |
✅ | [@typescript-eslint/no-magic-numbers ] |
[no-namespace ] |
✅ | [@typescript-eslint/no-namespace ] |
[no-non-null-assertion ] |
✅ | [@typescript-eslint/no-non-null-assertion ] |
[no-parameter-reassignment ] |
✅ | [no-param-reassign ][no-param-reassign] |
[no-reference ] |
✅ | [@typescript-eslint/triple-slash-reference ] |
[no-unnecessary-type-assertion ] |
✅ | [@typescript-eslint/no-unnecessary-type-assertion ] |
[no-var-requires ] |
✅ | [@typescript-eslint/no-var-requires ] |
[only-arrow-functions ] |
🔌 | [prefer-arrow/prefer-arrow-functions ] |
[prefer-for-of ] |
✅ | [@typescript-eslint/prefer-for-of ] |
[promise-function-async ] |
✅ | [@typescript-eslint/promise-function-async ] |
[typedef-whitespace ] |
✅ | [@typescript-eslint/type-annotation-spacing ] |
[typedef ] |
✅ | [@typescript-eslint/typedef ] |
[unified-signatures ] |
✅ | [@typescript-eslint/unified-signatures ] |
機能や特性
TSLint rule | ESLint rule | |
---|---|---|
[await-promise ] |
✅ | [@typescript-eslint/await-thenable ] |
[ban-comma-operator ] |
🌟 | [no-sequences ][no-sequences] |
[ban ] |
🌟 | [no-restricted-globals ][no-restricted-globals] & [no-restricted-properties ][no-restricted-properties] |
[curly ] |
🌟 | [curly ][curly] |
[forin ] |
🌟 | [guard-for-in ][guard-for-in] |
[function-constructor ] |
🌟 | [no-new-func ][no-new-func] |
[import-blacklist ] |
🌟 | [no-restricted-imports ][no-restricted-imports] |
[label-position ] |
🌟 | [no-unused-labels ][no-unused-labels] (similar) |
[no-arg ] |
🌟 | [no-caller ][no-caller] (also blocks arguments.caller ) |
[no-async-without-await ] |
✅ | [@typescript-eslint/require-await ] |
[no-bitwise ] |
🌟 | [no-bitwise ][no-bitwise] |
[no-conditional-assignment ] |
🌟 | [no-cond-assign ][no-cond-assign][2]
|
[no-console ] |
🌟 | [no-console ][no-console] (configuration works slightly differently) |
[no-construct ] |
🌟 | [no-new-wrappers ][no-new-wrappers] |
[no-debugger ] |
🌟 | [no-debugger ][no-debugger] |
[no-duplicate-super ] |
🌟 | [constructor-super ][constructor-super] |
[no-duplicate-switch-case ] |
🌟 | [no-duplicate-case ][no-duplicate-case] |
[no-duplicate-variable ] |
🌟 | [no-redeclare ][no-redeclare] |
[no-dynamic-delete ] |
✅ | [@typescript-eslint/no-dynamic-delete ] |
[no-empty ] |
🌟 | [no-empty ][no-empty] |
[no-eval ] |
🌟 | [no-eval ][no-eval] |
[no-floating-promises ] |
✅ | [@typescript-eslint/no-floating-promises ] |
[no-for-in-array ] |
✅ | [@typescript-eslint/no-for-in-array ] |
[no-implicit-dependencies ] |
🔌 | [import/no-extraneous-dependencies ] |
[no-inferred-empty-object-type ] |
🛑 | N/A |
[no-invalid-template-strings ] |
🌟 | [no-template-curly-in-string ][no-template-curly-in-string] |
[no-invalid-this ] |
🌟 | [no-invalid-this ][no-invalid-this] |
[no-misused-new ] |
✅ | [@typescript-eslint/no-misused-new ] |
[no-null-keyword ] |
🔌 | [no-null/no-null ] (doesn’t handle null type) |
[no-null-undefined-union ] |
🛑 | N/A |
[no-object-literal-type-assertion ] |
✅ | [@typescript-eslint/consistent-type-assertions ] |
[no-promise-as-boolean ] |
✅ | [@typescript-eslint/no-misused-promises ] |
[no-restricted-globals ] |
✅ | [no-restricted-globals ][no-restricted-globals] |
[no-return-await ] |
🌟 | [no-return-await ][no-return-await] |
[no-shadowed-variable ] |
🌟 | [no-shadow ][no-shadow] |
[no-sparse-arrays ] |
🌟 | [no-sparse-arrays ][no-sparse-arrays] |
[no-string-literal ] |
🌟 | [dot-notation ][dot-notation] |
[no-string-throw ] |
✅ | [@typescript-eslint/only-throw-error ] |
[no-submodule-imports ] |
🌓 | [import/no-internal-modules ] (slightly different) |
[no-switch-case-fall-through ] |
🌟 | [no-fallthrough ][no-fallthrough] |
[no-tautology-expression ] |
🛑 | N/A |
[no-this-assignment ] |
✅ | [@typescript-eslint/no-this-alias ] |
[no-unbound-method ] |
✅ | [@typescript-eslint/unbound-method ] |
[no-unnecessary-class ] |
✅ | [@typescript-eslint/no-extraneous-class ] |
[no-unsafe-any ] |
🌓 | [@typescript-eslint/no-unsafe-member-access ][3]
|
[no-unsafe-finally ] |
🌟 | [no-unsafe-finally ][no-unsafe-finally] |
[no-unused-expression ] |
🌟 | [no-unused-expressions ][no-unused-expressions] |
[no-unused-variable ] |
🌓 | [@typescript-eslint/no-unused-vars ] |
[no-use-before-declare ] |
✅ | [@typescript-eslint/no-use-before-define ] |
[no-var-keyword ] |
🌟 | [no-var ][no-var] |
[no-void-expression ] |
✅ | [@typescript-eslint/no-confusing-void-expression ] |
[prefer-conditional-expression ] |
🛑 | N/A |
[prefer-object-spread ] |
🌟 | [prefer-object-spread ][prefer-object-spread] |
[radix ] |
🌟 | [radix ][radix] |
[restrict-plus-operands ] |
✅ | [@typescript-eslint/restrict-plus-operands ] |
[static-this ] |
🛑 | N/A |
[strict-boolean-expressions ] |
✅ | [@typescript-eslint/strict-boolean-expressions ] |
[strict-string-expressions ] |
✅ | [@typescript-eslint/restrict-plus-operands ] & [@typescript-eslint/restrict-template-expressions ] |
[strict-type-predicates ] |
🛑 | N/A |
[switch-default ] |
🌟 | [default-case ][default-case] |
[triple-equals ] |
🌟 | [eqeqeq ][eqeqeq] |
[typeof-compare ] |
🌟 | [valid-typeof ][valid-typeof] |
[unnecessary-constructor ] |
🌟 | [no-useless-constructor ][no-useless-constructor] |
[use-default-type-parameter ] |
✅ | [@typescript-eslint/no-unnecessary-type-arguments ] |
[use-isnan ] |
🌟 | [use-isnan ][use-isnan] |
メンテナビリティ
TSLint rule | ESLint rule | |
---|---|---|
[cyclomatic-complexity ] |
🌟 | [complexity ][complexity] |
[deprecation ] |
✅ | [@typescript-eslint/no-deprecated ] |
[eofline ] |
🌟 | [eol-last ][eol-last] |
[indent ] |
✅ | [@typescript-eslint/indent ] or [Prettier] |
[linebreak-style ] |
🌟 | [linebreak-style ][linebreak-style] or [Prettier] |
[max-classes-per-file ] |
🌟 | [max-classes-per-file ][max-classes-per-file] |
[max-file-line-count ] |
🌟 | [max-lines ][max-lines] |
[max-line-length ] |
🌟 | [max-len ][max-len] or [Prettier] |
[no-default-export ] |
🔌 | [import/no-default-export ] |
[no-default-import ] |
🛑 | N/A |
[no-duplicate-imports ] |
🔌 | [import/no-duplicates ] |
[no-mergeable-namespace ] |
🛑 | N/A |
[no-require-imports ] |
✅ | [@typescript-eslint/no-require-imports ] |
[object-literal-sort-keys ] |
🌓 | [sort-keys ][sort-keys][4]
|
[prefer-const ] |
🌟 | [prefer-const ][prefer-const] |
[prefer-readonly ] |
✅ | [@typescript-eslint/prefer-readonly ] |
[trailing-comma ] |
🌓 | [comma-dangle ][comma-dangle] or [Prettier] |
スタイル
TSLint rule | ESLint rule | |
---|---|---|
[align ] |
🛑 | N/A |
[array-type ] |
✅ | [@typescript-eslint/array-type ] |
[arrow-parens ] |
🌟 | [arrow-parens ][arrow-parens] |
[arrow-return-shorthand ] |
🌟 | [arrow-body-style ][arrow-body-style] |
[binary-expression-operand-order ] |
🌟 | [yoda ][yoda] |
[callable-types ] |
✅ | [@typescript-eslint/prefer-function-type ] |
[class-name ] |
✅ | [@typescript-eslint/naming-convention ] |
[comment-format ] |
🌟 | [capitalized-comments ][capitalized-comments] & [spaced-comment ][spaced-comment] |
[comment-type ] |
🛑 | N/A |
[completed-docs ] |
🔌 | [jsdoc/require-jsdoc ] |
[encoding ] |
🛑 | N/A |
[file-header ] |
🔌 | [eslint-plugin-header ][plugin:header] or [-file-header ][plugin:file-header] |
[file-name-casing ] |
🔌 | [unicorn/filename-case ] |
[import-spacing ] |
🔌 | Use [Prettier] |
[increment-decrement ] |
🌟 | [no-plusplus ][no-plusplus] |
[interface-name ] |
✅ | [@typescript-eslint/interface-name-prefix ] |
[interface-over-type-literal ] |
✅ | [@typescript-eslint/consistent-type-definitions ] |
[jsdoc-format ] |
🌓 | [valid-jsdoc ][valid-jsdoc] or [eslint-plugin-jsdoc ][plugin:jsdoc] |
[match-default-export-name ] |
🛑 | N/A |
[newline-before-return ] |
🌟 | [padding-line-between-statements ][padding-line-between-statements][5]
|
[newline-per-chained-call ] |
🌟 | [newline-per-chained-call ][newline-per-chained-call] |
[new-parens ] |
🌟 | [new-parens ][new-parens] |
[no-angle-bracket-type-assertion ] |
✅ | [@typescript-eslint/consistent-type-assertions ] |
[no-boolean-literal-compare ] |
✅ | [@typescript-eslint/no-unnecessary-boolean-literal-compare ] |
[no-consecutive-blank-lines ] |
🌟 | [no-multiple-empty-lines ][no-multiple-empty-lines] |
[no-irregular-whitespace ] |
🌟 | [no-irregular-whitespace ][no-irregular-whitespace] with skipStrings: false
|
[no-parameter-properties ] |
✅ | [@typescript-eslint/parameter-properties ] |
[no-redundant-jsdoc ] |
🔌 | [jsdoc/no-types ] |
[no-reference-import ] |
✅ | [@typescript-eslint/triple-slash-reference ] |
[no-trailing-whitespace ] |
🌟 | [no-trailing-spaces ][no-trailing-spaces] |
[no-unnecessary-callback-wrapper ] |
🛑 | N/A and this might be unsafe (i.e. with forEach ) |
[no-unnecessary-else ] |
🌟 | [no-else-return ][no-else-return][6]
|
[no-unnecessary-initializer ] |
🌟 | [no-undef-init ][no-undef-init] |
[no-unnecessary-qualifier ] |
✅ | [@typescript-eslint/no-unnecessary-qualifier ] |
[number-literal-format ] |
🛑 | N/A |
[object-literal-key-quotes ] |
🌟 | [quote-props ][quote-props] |
[object-literal-shorthand ] |
🌟 | [object-shorthand ][object-shorthand] |
[one-line ] |
🌟 | [brace-style ][brace-style] or [Prettier] |
[one-variable-per-declaration ] |
🌟 | [one-var ][one-var] |
[ordered-imports ] |
🌓 | [import/order ] |
[prefer-function-over-method ] |
🌟 | [@typescript-eslint/class-methods-use-this ] |
[prefer-method-signature ] |
✅ | [@typescript-eslint/method-signature-style ] |
[prefer-switch ] |
🛑 | N/A |
[prefer-template ] |
🌟 | [prefer-template ][prefer-template] |
[prefer-while ] |
🛑 | N/A |
[quotemark ] |
🌟 | [quotes ][quotes] |
[return-undefined ] |
🛑 | N/A |
[semicolon ] |
🌓 | [@typescript-eslint/semi ] |
[space-before-function-paren ] |
🌟 | [space-before-function-paren ][space-after-function-paren] |
[space-within-parens ] |
🌟 | [space-in-parens ][space-in-parens] |
[switch-final-break ] |
🛑 | N/A |
[type-literal-delimiter ] |
✅ | [@typescript-eslint/member-delimiter-style ] |
[unnecessary-bind ] |
🌟 | [no-extra-bind ][no-extra-bind] |
[variable-name ] |
✅ | [@typescript-eslint/naming-convention ] |
[whitespace ] |
🔌 | Use [Prettier] |
tslint-microsoft-contrib
ルール
ルールの一覧は こちらです。
非推奨のルールは除外されています (missing-jsdoc
, missing-optional-annotation
, no-duplicate-case
, no-duplicate-parameter-names
, no-function-constructor-with-string-args
, no-increment-decrement
, no-empty-interfaces
, no-missing-visibility-modifiers
, no-multiple-var-decl
, no-reserved-keywords
, no-stateless-class
, no-var-self
, no-unnecessary-bind
, and valid-typeof
) 代わりに何を使用するかについては、上記のリンクのドキュメントを参照してください。
テスト
関連するプラグイン: chai-expect-keywords
, chai-expect
, chai-friendly
, mocha
, and jest
tslint-microsoft-contrib rule |
ESLint rule | |
---|---|---|
chai-prefer-contains-to-index-of |
🛑 | N/A |
chai-vague-errors |
🛑 | N/A |
mocha-avoid-only |
🔌 | [jest/no-focused-tests ] |
mocha-unneeded-done |
🛑 | N/A |
TypeScript
tslint-microsoft-contrib rule |
ESLint rule | |
---|---|---|
prefer-array-literal |
🌓 | [@typescript-eslint/no-array-constructor ][7]
|
prefer-type-cast |
🛑 | N/A |
その他
tslint-microsoft-contrib rule |
ESLint rule | |
---|---|---|
export-name |
🛑 | N/A ([relevant plugin][plugin:import]) |
function-name |
🛑 | N/A |
import-name |
🛑 | N/A ([relevant plugin][plugin:import]) |
informative-docs |
🛑 | N/A |
max-func-body-length |
🌟 | [max-statements ][max-statements] |
no-banned-terms |
🌟 | [no-caller ][no-caller] & [no-eval ][no-eval] |
no-constant-condition |
🌟 | [no-constant-condition ][no-constant-condition] |
no-control-regex |
🌟 | [no-control-regex ][no-control-regex] |
no-delete-expression |
✅ | [@typescript-eslint/no-dynamic-delete ] |
no-empty-line-after-opening-brace |
🌟 | [padded-blocks ][padded-blocks] [8] or [Prettier] |
no-for-in |
🌟 | [no-restricted-syntax ][no-restricted-syntax] [9]
|
no-function-expression |
🌟 | [func-style ][func-style] [10]
|
no-invalid-regexp |
🌟 | [no-invalid-regexp ][no-invalid-regexp] |
no-multiline-string |
🌟 | [no-multi-str ][no-multi-str] |
no-octal-literal |
🌟 | [no-octal-escape ][no-octal-escape], see also [no-octal ][no-octal] |
no-regex-spaces |
🌟 | [no-regex-spaces ][no-regex-spaces] |
no-relative-imports |
🛑 | N/A, Not recommended by the maintainers |
no-single-line-block-comment |
🛑 | N/A |
no-suspicious-comment |
🌟 | [no-warning-comments ][no-warning-comments] [11]
|
no-typeof-undefined |
🛑 | N/A (this actually has a valid use: checking if a variable is defined) |
no-unexternalized-strings |
🛑 | N/A |
no-unnecessary-field-initialization |
🌓 | [no-undef-init ][no-undef-init] [12]
|
no-unnecessary-local-variable |
🛑 | N/A |
no-unnecessary-override |
🛑 | N/A |
no-unnecessary-semicolons |
🌟 | [no-extra-semi ][no-extra-semi] or [Prettier] |
no-useless-files |
🛑 | N/A |
no-with-statement |
🌟 | [no-with ][no-with] |
promise-must-complete |
🛑 | N/A |
underscore-consistent-invocation |
🔌 | [lodash/chaining ] |
use-named-parameter |
🛑 | N/A |
use-simple-attributes |
🛑 | N/A |
セキュリティ
tslint-microsoft-contrib rule |
ESLint rule | |
---|---|---|
insecure-random |
🔌 | [desktop/insecure-random ] or [@microsoft/sdl/no-insecure-random ] |
no-disable-auto-sanitization |
🔌 | [@microsoft/sdl/no-msapp-exec-unsafe ] and [@microsoft/sdl/no-winjs-html-unsafe ] |
no-document-domain |
🌓 | Use [no-restricted-syntax ][no-restricted-syntax] or [@microsoft/sdl/no-document-domain ] |
no-http-string |
🔌 | [@microsoft/sdl/no-insecure-url ] |
no-inner-html |
🔌 | [@microsoft/sdl/no-inner-html ] and [@microsoft/sdl/no-html-method ] |
no-string-based-set-immediate |
🌓 | [@typescript-eslint/no-implied-eval ] |
no-string-based-set-interval |
🌓 | [@typescript-eslint/no-implied-eval ] |
no-string-based-set-timeout |
🌓 | [@typescript-eslint/no-implied-eval ] |
react-anchor-blank-noopener |
🔌 | [react/jsx-no-target-blank ] |
react-iframe-missing-sandbox |
🔌 | [@microsoft/sdl/react-iframe-missing-sandbox ] |
react-no-dangerous-html |
🔌 | [react/no-danger ] |
non-literal-fs-path |
🔌 | [security/detect-non-literal-fs-filename ] |
non-literal-require |
🔌 | [security/detect-non-literal-require ] |
possible-timing-attack |
🔌 | [security/detect-possible-timing-attacks ] |
ブラウザー
tslint-microsoft-contrib rule |
ESLint rule | |
---|---|---|
jquery-deferred-must-complete |
🛑 | N/A |
no-backbone-get-set-outside-model |
🛑 | N/A |
no-cookies |
🌓 | Use [no-restricted-syntax ][no-restricted-syntax] or [@microsoft/sdl/no-cookies ] |
no-document-write |
🌓 | Use [no-restricted-syntax ][no-restricted-syntax] or [@microsoft/sdl/no-document-write ] |
no-exec-script |
🌓 | Use [no-restricted-syntax ][no-restricted-syntax] or [@typescript-eslint/no-implied-eval ] |
no-jquery-raw-elements |
🛑 | N/A |
no-unsupported-browser-code |
🛑 | N/A |
react-this-binding-issue |
🛑 | N/A |
react-tsx-curly-spacing |
🔌 | [react/jsx-curly-spacing ] |
react-unused-props-and-state |
🌓 | [react/no-unused-state ] |
[13]
React A11y
tslint-microsoft-contrib rule |
ESLint rule | |
---|---|---|
react-a11y-accessible-headings |
🌓 | [jsx-a11y/heading-has-content ] [14]
|
react-a11y-anchors |
🔌 | [jsx-a11y/anchor-is-valid ] |
react-a11y-aria-unsupported-elements |
🔌 | [jsx-a11y/aria-unsupported-elements ] |
react-a11y-event-has-role |
🌓 | [jsx-a11y/no-static-element-interactions ] [15]
|
react-a11y-image-button-has-alt |
🔌 | [jsx-a11y/alt-text ] |
react-a11y-img-has-alt |
🔌 | [jsx-a11y/alt-text ] |
react-a11y-input-elements |
🛑 | N/A |
react-a11y-lang |
🔌 | [jsx-a11y/lang ] |
react-a11y-meta |
🛑 | N/A |
react-a11y-no-onchange |
🔌 | [jsx-a11y/no-onchange ] |
react-a11y-props |
🔌 | [jsx-a11y/aria-props ] |
react-a11y-proptypes |
🔌 | [jsx-a11y/aria-proptypes ] |
react-a11y-required |
🛑 | N/A |
react-a11y-role-has-required-aria-props |
🔌 | [jsx-a11y/role-has-required-aria-props ] |
react-a11y-role-supports-aria-props |
🔌 | [jsx-a11y/role-supports-aria-props ] |
react-a11y-role |
🔌 | [jsx-a11y/aria-role ] |
react-a11y-tabindex-no-positive |
🔌 | [jsx-a11y/tabindex-no-positive ] |
react-a11y-titles |
🛑 | N/A |
-
ESLintルールは、正規表現ではなく、正確な文字列マッチングのみをサポートしています。 ↩︎
-
ESLintルールは、追加の括弧を使ってサイレンシングをサポートしています(if ((foo = bar)) {}) ↩︎
-
メンバー式のみをチェックします ↩︎
-
空行で区切られたセクションのサポートが欠如している ↩︎
-
推奨設定: ["error", { blankLine: "always", prev: "*", next: "return" }] ↩︎
-
break や continue などの他の制御フロー文はチェックしません。 ↩︎
-
ESLintのルールはやや厳しさが緩和されており、new Array<Foo>()やArray(2)が許可されています。 ↩︎
-
ブロックの先頭と末尾に空行を強制します。 ↩︎
-
推奨設定:
["error", "ForInStatement"]
↩︎ -
推奨設定:
["error", "declaration", { "allowArrowFunctions": true }]
↩︎ -
推奨設定:
["error", { "terms": ["BUG", "HACK", "FIXME", "LATER", "LATER2", "TODO"], "location": "anywhere" }]
↩︎ -
クラスフィールドはチェックしません。 ↩︎
-
アクセシビリティ ↩︎
-
TSLintのルールはより厳格です ↩︎
-
ESLintのルールはクリックハンドラーに対してのみ報告します ↩︎
Discussion