This document serves as a guide to help you migrate from TSLint. It lists all TSLint rules along side rules from the ESLint ecosystem that are the same or similar.
✅ = done
🌟 = in ESLint core
🔌 = in another plugin
🌓 = implementations differ or ESLint version is missing functionality
🛑 = unimplemented
[1] The ESLint rule only supports exact string matching, rather than regular expressions
[1] The ESLint rule also supports silencing with an extra set of parentheses (if ((foo = bar)) {}
)
[2] Only checks member expressions
[2] Missing support for blank-line-delimited sections
[1] Recommended config: ["error", { blankLine: "always", prev: "*", next: "return" }]
[2] Doesn't check other control flow statements, such as break
or continue
.
Rule listing is here.
Deprecated rules are excluded (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
). See the docs in the link above to find out what to use instead.
Relevant plugins: 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 |
tslint-microsoft-contrib rule |
ESLint rule | |
---|---|---|
prefer-array-literal |
🌓 | @typescript-eslint/no-array-constructor [1] |
prefer-type-cast |
🛑 | N/A |
[1] ESLint rule is slightly less strict, allowing new Array<Foo>()
and Array(2)
.
tslint-microsoft-contrib rule |
ESLint rule | |
---|---|---|
export-name |
🛑 | N/A (relevant plugin) |
function-name |
🛑 | N/A |
import-name |
🛑 | N/A (relevant plugin) |
informative-docs |
🛑 | N/A |
insecure-random |
🔌 | custom implementation |
max-func-body-length |
🌟 | max-statements |
no-banned-terms |
🌟 | no-caller & no-eval |
no-constant-condition |
🌟 | no-constant-condition |
no-control-regex |
🌟 | no-control-regex |
no-delete-expression |
✅ | @typescript-eslint/no-dynamic-delete |
no-empty-line-after-opening-brace |
🌟 | padded-blocks [1] or Prettier |
no-for-in |
🌟 | no-restricted-syntax [2] |
no-function-expression |
🌟 | func-style [3] |
no-invalid-regexp |
🌟 | no-invalid-regexp |
no-multiline-string |
🌟 | no-multi-str |
no-octal-literal |
🌟 | no-octal-escape , see also no-octal |
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 [4] |
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 [5] |
no-unnecessary-local-variable |
🛑 | N/A |
no-unnecessary-override |
🛑 | N/A |
no-unnecessary-semicolons |
🌟 | no-extra-semi or Prettier |
no-useless-files |
🛑 | N/A |
no-with-statement |
🌟 | no-with |
promise-must-complete |
🛑 | N/A |
underscore-consistent-invocation |
🔌 | lodash/chaining |
use-named-parameter |
🛑 | N/A |
use-simple-attributes |
🛑 | N/A |
[1] Enforces blank lines both at the beginning and end of a block
[2] Recommended config: ["error", "ForInStatement"]
[3] Recommended config: ["error", "declaration", { "allowArrowFunctions": true }]
[4] Recommended config: ["error", { "terms": ["BUG", "HACK", "FIXME", "LATER", "LATER2", "TODO"], "location": "anywhere" }]
[5] Does not check class fields.
tslint-microsoft-contrib rule |
ESLint rule | |
---|---|---|
no-disable-auto-sanitization |
🛑 | N/A |
no-document-domain |
🌓 | Use no-restricted-syntax |
no-http-string |
🛑 | N/A |
no-inner-html |
🛑 | N/A |
no-string-based-set-immediate |
🛑 | N/A |
no-string-based-set-interval |
🛑 | N/A |
no-string-based-set-timeout |
🛑 | N/A |
react-iframe-missing-sandbox |
🛑 | N/A |
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-document-write |
🌓 | Use no-restricted-syntax |
no-exec-script |
🌓 | Use no-restricted-syntax |
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 |
tslint-microsoft-contrib rule |
ESLint rule | |
---|---|---|
react-a11y-accessible-headings |
🌓 | jsx-a11y/heading-has-content [1] |
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 [2] |
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 |
react-anchor-blank-noopener |
🛑 | N/A |
[1] TSLint rule is more strict
[2] ESLint rule only reports for click handlers