百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
T

tslint-eslint-rules

> 编程语言
开源

使用缺失的 ESLint 规则来改进您的 TSLint

705 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

使用缺失的 ESLint 规则来改进您的 TSLint

DEPRECATED

I originally created this project because it was impossible to run ESLint on a TypeScript codebase. Today you can use https://github.com/typescript-eslint/typescript-eslint for that purpose, so this project is unmaintained and deprecated.

ESLint rules for TSLint

Improve your TSLint with the missing ESLint Rules

You want to code in TypeScript but miss all the rules available in ESLint?

Now you can combine both worlds by using this TSLint plugin!

Usage

Install from NPM to your Dev Dependencies

npm install --save-dev tslint-eslint-rules

Or install from Yarn to your Dev Dependencies

yarn add tslint-eslint-rules --dev

Configure TSLint to use tslint-eslint-rules:

In your tslint.json file, source the rules from this package, e.g:

{
  "rules": {
    "no-constant-condition": true
  },
  "rulesDirectory": [
    "node_modules/tslint-eslint-rules/dist/rules"
  ]
}

You can also add other tslint config packages to combine these rules with other custom community rules.

Configure your rules

In your tslint.json file, insert the rules as described below.

Rules (copied from the ESLint website)

The following tables shows all the existing ESLint rules and the similar rules available in TSLint. Please refer to the following icons as they provide the status of the rule.

Icon Description
:no_entry_sign: The rule is not applicable to Typescript.
:ballot_box_with_check: The rule is provided natively by TSLint.
:white_check_mark: The rule is available via tslint-eslint-rules.
:x: The rule is currently unavailable.

Possible Errors

The following rules point out areas where you might have made mistakes.

:grey_question: ESLint TSLint Description
:ballot_box_with_check: comma-dangle trailing-comma disallow or enforce trailing commas (recommended)
:ballot_box_with_check: no-cond-assign no-conditional-assignment disallow assignment in conditional expressions (recommended)
:ballot_box_with_check: no-console no-console disallow use of console in the node environment (recommended)
:white_check_mark: no-constant-condition no-constant-condition disallow use of constant expressions in conditions (recommended)
:white_check_mark: no-control-regex no-control-regex disallow control characters in regular expressions (recommended)
:ballot_box_with_check: no-debugger no-debugger disallow use of debugger (recommended)
:no_entry_sign: no-dupe-args Not applicable disallow duplicate arguments in functions (recommended)
:no_entry_sign: no-dupe-keys Not applicable disallow duplicate keys when creating object literals (recommended)
:white_check_mark: no-duplicate-case no-duplicate-case disallow a duplicate case label. (recommended)
:ballot_box_with_check: no-empty no-empty disallow empty statements (recommended)
:white_check_mark: no-empty-character-class no-empty-character-class disallow the use of empty character classes in regular expressions (recommended)
:white_check_mark: no-ex-assign no-ex-assign disallow assigning to the exception in a catch block (recommended)
:white_check_mark: no-extra-boolean-cast no-extra-boolean-cast disallow double-negation boolean casts in a boolean context (recommended)
:x: no-extra-parens no-extra-parens disallow unnecessary parentheses
:white_check_mark: no-extra-semi no-extra-semi disallow unnecessary semicolons (recommended)
:no_entry_sign: no-func-assign Not applicable disallow overwriting functions written as function declarations (recommended)
:white_check_mark: no-inner-declarations no-inner-declarations disallow function or variable declarations in nested blocks (recommended)
:white_check_mark: no-invalid-regexp no-invalid-regexp disallow invalid regular expression strings in the RegExp constructor (recommended)
:white_check_mark: no-irregular-whitespace ter-no-irregular-whitespace disallow irregular whitespace (recommended)
:no_entry_sign: no-negated-in-lhs Not applicable disallow negation of the left operand of an in expression (recommended)
:no_entry_sign: no-obj-calls Not applicable disallow the use of object properties of the global object (Math and JSON) as functions (recommended)
:white_check_mark: no-regex-spaces no-regex-spaces disallow multiple spaces in a regular expression literal (recommended)
:white_check_mark: no-sparse-arrays ter-no-sparse-arrays disallow sparse arrays (recommended)
:white_check_mark: no-unexpected-multiline no-unexpected-multiline Avoid code that looks like two expressions but is actually one
:no_entry_sign: no-unreachable Not applicable disallow unreachable statements after a return, throw, continue, or break statement (recommended)
:ballot_box_with_check: no-unsafe-finally no-unsafe-finally disallow control flow statements in finally blocks (recommended)
:ballot_box_with_check: use-isnan use-isnan disallow comparisons with the value NaN (recommended)
:white_check_mark: valid-jsdoc valid-jsdoc enforce valid JSDoc comments
:white_check_mark: valid-typeof valid-typeof Ensure that the results of typeof are compared against a valid string (recommended)

Best Practices

These are rules designed to prevent you from making mistakes. They either prescribe a better way of doing something or help you avoid footguns.

:grey_question: ESLint TSLint Description
:x: accessor-pairs accessor-pairs Enforces getter/setter pairs in objects
:x: array-callback-return array-callback-return Enforce return statements in callbacks of array’s methods
:x: block-scoped-var block-scoped-var treat var statements as if they were block scoped
:ballot_box_with_check: complexity cyclomatic-complexity specify the maximum cyclomatic complexity allowed in a program
:x: consistent-return consistent-return require return statements to either always or never specify values
:ballot_box_with_check: curly curly specify curly brace conventions for all control statements
:ballot_box_with_check: default-case switch-default require default case in switch statements
:x: dot-location dot-location enforces consistent newlines before or after dots
:x: dot-notation dot-notation encourages use of dot notation whenever possible
:ballot_box_with_check: eqeqeq triple-equals require the use of === and !==
:ballot_box_with_check: guard-for-in forin make sure for-in loops have an if statement
:ballot_box_with_check: no-alert ban disallow the use of alert, confirm, and prompt
can be achieved using the "ban": [true, ["alert"]] tslint rule
:ballot_box_with_check: no-caller no-arg disallow use of arguments.caller or arguments.callee
:x: no-case-declarations no-case-declarations disallow lexical declarations in case clauses
:x: no-div-regex no-div-regex disallow division operators explicitly at beginning of regular expression
:x: no-else-return no-else-return disallow else after a return in an if
:ballot_box_with_check: no-empty-function no-empty disallow use of empty functions
:x: no-empty-pattern no-empty-pattern disallow use of empty destructuring patterns
:x: [n

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言