{
"files": // 用于表示配置适用的文件范围的 glob 模式数组。在没有指定的情况下,应用默认配置
[
"**/*.ets", // 字符串类型
"**/*.js",
"**/*.ts"
],
"ignore": // 一个表示配置对象不应适用的文件的 glob 模式数组。如果没有指定,配置对象将适用于所有由 files 匹配的文件
[
"signature/**/*",
"hvigor/**/*",
"oh_modules/**/*"
],
"ruleSet": // 设置检查待应用的规则集, 当前仅支持IDE内置规则集all、recommended
[
"plugin:@typescript-eslint/recommended" // 快捷批量引入的规则集, 枚举类型:plugin:@typescript-eslint/all, plugin:@typescript-eslint/recommended
],
"rules": // 可以对ruleSet配置的规则集中特定的某些规则进行修改、去使能, 或者新增规则集以外的规则;ruleSet和rules共同确定了代码检查所应用的规则
{
// ruleId后面跟单独一个字符串时, 表示仅设置告警级别, 枚举值为: error, warn, off
"@typescript-eslint/no-unsafe-return": "error", // Disallows returning any from a function
"@typescript-eslint/adjacent-overload-signatures": "error", // Require that member overloads be consecutive
"@typescript-eslint/array-type": "warn", // Requires using either T[] or Array<T>for arrays
"@typescript-eslint/await-thenable": "error", // Disallows awaiting a value that is not a Thenable
"@typescript-eslint/ban-ts-comment": "error", // Bans @ts-<directive> comments from being used or requires descriptions after directive
"@typescript-eslint/ban-tslint-comment": "error", // Bans // tslint:<rule-flag> comments from being used
"@typescript-eslint/ban-types": "warn", // Bans specific types from being used
"@typescript-eslint/class-literal-property-style": "warn", // Ensures that literals on classes are exposed in a consistent style
"@typescript-eslint/consistent-indexed-object-style": "warn", // Enforce or disallow the use of the record type
"@typescript-eslint/consistent-type-assertions": // Enforces consistent usage of type assertions
[
"error",
{
"assertionStyle": "as",
"objectLiteralTypeAssertions": "never",
},
],
"@typescript-eslint/consistent-type-definitions": "warn", // Consistent with type definition either interface or type
"@typescript-eslint/consistent-type-imports": "error", // Enforces consistent usage of type imports
"@typescript-eslint/explicit-function-return-type": "error", // Require explicit return types on functions and class methods
"@typescript-eslint/explicit-member-accessibility": "warn", // Require explicit accessibility modifiers on class properties and methods
"@typescript-eslint/explicit-module-boundary-types": "error", // Require explicit return and argument types on exported functions' and classes' public class methods
"@typescript-eslint/member-delimiter-style": "warn", // Require a specific member delimiter style for interfaces and type literals
"@typescript-eslint/method-signature-style": "warn", // Enforces using a particular method signature syntax.
"@typescript-eslint/naming-convention": "off", // Enforces naming conventions for everything across a codebase
"@typescript-eslint/no-base-to-string": "warn", // Requires that .toString() is only called on objects which provide useful information when stringified
"@typescript-eslint/no-confusing-non-null-assertion": "warn", // Disallow non-null assertion in locations that may be confusing
"@typescript-eslint/no-confusing-void-expression": "error", // Requires expressions of type void to appear in statement position
"@typescript-eslint/no-dynamic-delete": "error", // Disallow the delete operator with computed key expressions
"@typescript-eslint/no-empty-interface": "error", // Disallow the declaration of empty interfaces
"@typescript-eslint/no-explicit-any": "error", // Disallow usage of the any type
"@typescript-eslint/no-extra-non-null-assertion": "error", // Disallow extra non-null assertion
"@typescript-eslint/no-for-in-array": "error", // Disallow iterating over an array with a for-in loop, 数组不用for-in,用for-of或者for-i
"@typescript-eslint/no-misused-new": "warn", // Enforce valid definition of new and constructor
"@typescript-eslint/no-misused-promises": "warn", // Avoid using promises in places not designed to handle them
"@typescript-eslint/no-this-alias": "error", // Disallow aliasing this
"@typescript-eslint/no-unnecessary-condition": "error", // Prevents conditionals where the type is always truthy or always falsy
"@typescript-eslint/no-unnecessary-type-assertion": "warn", // Warns if a type assertion does not change the type of an expression
"@typescript-eslint/no-unnecessary-type-constraint": "error", // Disallows unnecessary constraints on generic types
"@typescript-eslint/no-unsafe-argument": "error", // Disallows calling a function with an any type value
"@typescript-eslint/no-unsafe-assignment": "error", // Disallows assigning any to variables and properties
"@typescript-eslint/no-unsafe-call": "error", // Disallows calling an any type value
"@typescript-eslint/no-unsafe-member-access": "error", // Disallows member access on any typed variables
"@typescript-eslint/prefer-as-const": "warn", // Prefer usage of as const over literal type
"@typescript-eslint/prefer-for-of": "warn", // Prefer a ‘for-of’ loop over a standard ‘for’ loop if the index is only used to access the array being iterated
'@typescript-eslint/no-unused-vars': "warn", // Disallow unused variables
'@security/no-cycle': "error", // This rule ensures that there is no resolvable path back to this module via its dependencies
}
}