- @typescript-eslint/adjacent-overload-signatures
- It is recommended that the signatures of function overloads remain continuous
- @typescript-eslint/await-thenable
- It is not allowed to use the await keyword for values that are not "Thenable" objects. Instead, you must use await for "Thenable" objects, such as Promise objects.
- @typescript-eslint/array-type
- When defining arrays, use a uniform style, e.g., both use T[] or both use Array
。
"@typescript-eslint/array-type": [
"error",
{
// array | array-simple | generic
"default": "array"
}
]
- When default is set to array, T[] is used uniformly; when generic is set, Array is used uniformly.
When set to array-simple, simple types use T[] and other types use Array.
- @typescript-eslint/ban-ts-comment
- Not allowed to use
@ts-<directional>
Formatting the notes, or requesting additional clarification following the notes
- @typescript-eslint/ban-tslint-comment
- Not allowed to use
//tslint:<rule-flag>
Notes on the format
- @typescript-eslint/ban-types
- Certain types are not allowed, such as type lowercase consistency, using string, boolean, number, etc. instead of String, Boolean, Number.
- @typescript-eslint/brace-style
- Requires that the left curly brace of a code block be on the same line as its corresponding statement or declaration.
- @typescript-eslint/class-literal-property-style
- It is recommended that the literal properties in a class be consistent when exposed to the public
- @typescript-eslint/comma-dangle
- Trailing commas are either allowed or prohibited, the last attribute of a class or the last element of an array is prohibited from trailing commas
"@typescript-eslint/comma-dangle": [
"error",
{
// never | always
"arrays": "never",
"objects": "never",
"imports": "never",
"exports": "never",
"functions": "never"
}
]
- A total of five types of arrays, objects, imports, exports and functions support configuration, the value set to never is prohibited trailing commas, set to always is allowed to trailing commas.
- @typescript-eslint/comma-spacing
- Force space styles before and after commas to be consistent, e.g., force no spaces before commas and spaces must be added after commas
"@typescript-eslint/comma-spacing": [
"error",
{
"before": false,
"after": true
}
]
- @typescript-eslint/consistent-type-assertions
- Forcing the use of consistent type assertions
- @typescript-eslint/default-param-last
- Forces the default parameter to be at the end of the parameter list
- @typescript-eslint/explicit-member-accessibility
- Access modifiers need to be explicitly defined on class properties and methods
- @typescript-eslint/func-call-spacing
- Prohibit or require a space between the function name and the parentheses following the function name
"@typescript-eslint/func-call-spacing": [
"error",
"never"
]
- When set to never, spaces are not allowed after the function name, and when set to always, spaces are allowed after the function name.
- @typescript-eslint/init-declarations
- Prohibit or require initialization in variable declarations
"@typescript-eslint/init-declarations": [
"error",
"always"
]
- When set to always, the declared variable must be initialized, and when set to never, the declared variable may not be initialized.
- @typescript-eslint/keyword-spacing
- Force consistent space styles before and after keywords, e.g. add spaces both before and after keywords
"@typescript-eslint/keyword-spacing": [
"error",
{
"before": true,
"after": true
}
]
- @typescript-eslint/lines-between-class-members
- Prohibit or require class members to be separated by blank lines, always for allowing blank lines, never for not allowing blank lines, as follows set blank lines after not adding blank lines, properties and methods before adding blank lines.
"@typescript-eslint/lines-between-class-members": [
"error",
{
enforce: [
{
blankLine: "never",
prev: "field",
next: "method"
}
]
}
]
- @typescript-eslint/member-delimiter-style
- Requires a specific separator between members in interfaces and type aliases, and supports three defined separators: semicolon, comma, no separator
- @typescript-eslint/member-ordering
- Require a consistent style of ordering members in classes, interfaces, and type literals
- @typescript-eslint/naming-convention
- Force identifiers to use a consistent naming style. For example, use big humps for class names and little humps for functions.
- @typescript-eslint/no-array-constructor
- The "Array" constructor is not allowed.
- @typescript-eslint/no-base-to-string
- Requires that the "toString()" method be called when an object provides useful information at the time of stringing.
- @typescript-eslint/no-confusing-non-null-assertion
- Do not allow non-null assertions in potentially confusing locations
- @typescript-eslint/no-confusing-void-expression
- Requires expressions of type void to appear in the proper place
- @typescript-eslint/no-dupe-class-members
- Duplicate class members are not allowed, i.e., member attributes that have already been declared are not allowed to be duplicated and declared again.
- @typescript-eslint/no-duplicate-imports
- Duplicate module imports are prohibited, i.e. modules that have already been imported are not allowed to be imported again.
- @typescript-eslint/no-empty-function
- Empty functions are not allowed. Supported whitelist configurations include functions, arrow functions, methods, constructors, and so on, configured as follows
"@typescript-eslint/no-empty-function": [
"error",
{
"allow": [
"functions",
"arrowFunctions",
"generatorFunctions",
"methods",
"generatorMethods",
"getters",
"setters",
"constructors",
"asyncFunctions",
"asyncMethods"
]
}
]
- @typescript-eslint/no-empty-interface
- Empty interface declarations are not allowed
- @typescript-eslint/no-extraneous-class
- Classes are not allowed to be used as namespaces
- @typescript-eslint/no-extra-non-null-assertion
- Do not allow redundant non-null assertions
- @typescript-eslint/no-extra-parens
- Prohibition of unnecessary brackets
- @typescript-eslint/no-extra-semi
- Prohibition of unnecessary semicolons
- @typescript-eslint/no-floating-promises
- Require correct handling of Promise expressions, e.g. Promise must handle exceptions
- @typescript-eslint/no-implied-eval
- Prohibit the use of methods like "eval()".
- @typescript-eslint/no-inferrable-types
- Explicit type declarations are not allowed for variables or parameters initialized to numeric, string, or boolean values
- @typescript-eslint/no-invalid-this
- Prohibit the use of this in contexts where the value of this is undefined.
- @typescript-eslint/no-invalid-void-type
- Prohibit the use of void outside of return types or generic types.
- @typescript-eslint/no-loss-of-precision
- Prohibition of the use of literal numbers with loss of precision
- @typescript-eslint/no-magic-numbers
- Magic numbers are forbidden. However, there are cases where we need to use numbers directly, such as when defining an enumeration, when fetching data from an array based on its index, or when defining certain values directly that are not magic numbers, as in the following examples
"@typescript-eslint/no-magic-numbers": [
"off",
{
"ignoreEnums": true,
"ignoreArrayIndexes": true,
"ignoreNumericLiteralTypes": true,
"ignore": [
-1,
0,
1
]
}
]
- @typescript-eslint/no-misused-new
- Requires correct definitions of "new" and "constructor".
- @typescript-eslint/no-misused-promises
- Prohibit the use of Promise in incorrect locations
- @typescript-eslint/no-non-null-asserted-optional-chain
- Prohibit the use of non-null assertions after optional chain expressions
- @typescript-eslint/no-non-null-assertion
- Prohibit the use of non-null assertions with an exclamation point as a suffix
- @typescript-eslint/no-redeclare
- Repeated variable declarations are prohibited, i.e., variables that have been previously declared are not allowed to be declared again.
- @typescript-eslint/no-require-imports
- Prohibit importing dependencies using the "require()" syntax.
- @typescript-eslint/no-restricted-syntax
- Specified (i.e. user-defined in the rule) syntax is not allowed. For example, it is not allowed to print the log directly, but to use our wrapped LogUtil to print the log instead.
"@typescript-eslint/no-restricted-syntax": [
"error".
{
"selector": "CallExpression[='']",
"message": "Don't use console directly to print logs, use LogUtil"
}
]
- @typescript-eslint/no-shadow
- Prohibit the declaration of variables with the same name as externally scoped variables
- @typescript-eslint/no-throw-literal
- Disable throwing literals as exceptions
- @typescript-eslint/no-unnecessary-boolean-literal-compare"
- Prohibit direct comparisons between Boolean values and Boolean literals
- @typescript-eslint/no-unnecessary-condition
- Expressions of type always true or always false are not allowed as judgment conditions
- @typescript-eslint/no-unnecessary-qualifier
- Disable unnecessary namespace qualifiers