Location>code7788 >text

Hongmeng high quality code static detection 200 articles a

Popularity:954 ℃/2024-11-12 12:49:14
  1. @typescript-eslint/adjacent-overload-signatures
  • It is recommended that the signatures of function overloads remain continuous
  1. @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.
  1. @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.
  1. @typescript-eslint/ban-ts-comment
  • Not allowed to use@ts-<directional>Formatting the notes, or requesting additional clarification following the notes
  1. @typescript-eslint/ban-tslint-comment
  • Not allowed to use//tslint:<rule-flag>Notes on the format
  1. @typescript-eslint/ban-types
  • Certain types are not allowed, such as type lowercase consistency, using string, boolean, number, etc. instead of String, Boolean, Number.
  1. @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.
  1. @typescript-eslint/class-literal-property-style
  • It is recommended that the literal properties in a class be consistent when exposed to the public
  1. @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.
  1. @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
  }
]
  1. @typescript-eslint/consistent-type-assertions
  • Forcing the use of consistent type assertions
  1. @typescript-eslint/default-param-last
  • Forces the default parameter to be at the end of the parameter list
  1. @typescript-eslint/explicit-member-accessibility
  • Access modifiers need to be explicitly defined on class properties and methods
  1. @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.
  1. @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.
  1. @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
  }
]
  1. @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"
      }
    ]
  }
]
  1. @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
  1. @typescript-eslint/member-ordering
  • Require a consistent style of ordering members in classes, interfaces, and type literals
  1. @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.
  1. @typescript-eslint/no-array-constructor
  • The "Array" constructor is not allowed.
  1. @typescript-eslint/no-base-to-string
  • Requires that the "toString()" method be called when an object provides useful information at the time of stringing.
  1. @typescript-eslint/no-confusing-non-null-assertion
  • Do not allow non-null assertions in potentially confusing locations
  1. @typescript-eslint/no-confusing-void-expression
  • Requires expressions of type void to appear in the proper place
  1. @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.
  1. @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.
  1. @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"
    ]
  }
]
  1. @typescript-eslint/no-empty-interface
  • Empty interface declarations are not allowed
  1. @typescript-eslint/no-extraneous-class
  • Classes are not allowed to be used as namespaces
  1. @typescript-eslint/no-extra-non-null-assertion
  • Do not allow redundant non-null assertions
  1. @typescript-eslint/no-extra-parens
  • Prohibition of unnecessary brackets
  1. @typescript-eslint/no-extra-semi
  • Prohibition of unnecessary semicolons
  1. @typescript-eslint/no-floating-promises
  • Require correct handling of Promise expressions, e.g. Promise must handle exceptions
  1. @typescript-eslint/no-implied-eval
  • Prohibit the use of methods like "eval()".
  1. @typescript-eslint/no-inferrable-types
  • Explicit type declarations are not allowed for variables or parameters initialized to numeric, string, or boolean values
  1. @typescript-eslint/no-invalid-this
  • Prohibit the use of this in contexts where the value of this is undefined.
  1. @typescript-eslint/no-invalid-void-type
  • Prohibit the use of void outside of return types or generic types.
  1. @typescript-eslint/no-loss-of-precision
  • Prohibition of the use of literal numbers with loss of precision
  1. @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
    ]
  }
]
  1. @typescript-eslint/no-misused-new
  • Requires correct definitions of "new" and "constructor".
  1. @typescript-eslint/no-misused-promises
  • Prohibit the use of Promise in incorrect locations
  1. @typescript-eslint/no-non-null-asserted-optional-chain
  • Prohibit the use of non-null assertions after optional chain expressions
  1. @typescript-eslint/no-non-null-assertion
  • Prohibit the use of non-null assertions with an exclamation point as a suffix
  1. @typescript-eslint/no-redeclare
  • Repeated variable declarations are prohibited, i.e., variables that have been previously declared are not allowed to be declared again.
  1. @typescript-eslint/no-require-imports
  • Prohibit importing dependencies using the "require()" syntax.
  1. @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"
  }
]
  1. @typescript-eslint/no-shadow
  • Prohibit the declaration of variables with the same name as externally scoped variables
  1. @typescript-eslint/no-throw-literal
  • Disable throwing literals as exceptions
  1. @typescript-eslint/no-unnecessary-boolean-literal-compare"
  • Prohibit direct comparisons between Boolean values and Boolean literals
  1. @typescript-eslint/no-unnecessary-condition
  • Expressions of type always true or always false are not allowed as judgment conditions
  1. @typescript-eslint/no-unnecessary-qualifier
  • Disable unnecessary namespace qualifiers