3 Star 0 Fork 0

KittySnow/space-front

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
.eslintrc.ts.js 3.15 KB
一键复制 编辑 原始数据 按行查看 历史
KittySnow 提交于 2023-03-29 18:49 . init
module.exports = {
// https://zhuanlan.zhihu.com/p/453320319
'@typescript-eslint/array-type': [
'error',
{
default: 'array',
readonly: 'array',
},
], //支持使用 Array<T> 与 T[] 的形式声明数组类型
'@typescript-eslint/await-thenable': ['error'], // 只允许对异步函数、Promise、PromiseLike 使用 await 调用
'@typescript-eslint/ban-ts-comment': ['error'], // 禁止 @ts- 指令的使用,或者允许其在提供了说明的情况下被使用
'@typescript-eslint/ban-types': ['error'], // 禁止部分值被作为类型标注
'@typescript-eslint/consistent-type-assertions': [
'error',
{
assertionStyle: 'as',
objectLiteralTypeAssertions: 'never',
},
], // 支持通过 as 与 <> 两种不同的语法进行类型断言
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'], //TypeScript 支持通过 type 与 interface 声明对象类型
'@typescript-eslint/method-signature-style': ['error', 'property'], //方法签名的声明方式有 method 与 property 两种
'@typescript-eslint/no-extra-non-null-assertion': ['error'], //不允许额外的重复非空断言:
'@typescript-eslint/prefer-for-of': ['error'], //在你使用 for 循环遍历数组时,如果索引仅仅用来访问数组成员,则应该替换为 for...of。
'@typescript-eslint/prefer-nullish-coalescing': ['error'], //使用 ?? 而不是 ||
'@typescript-eslint/prefer-optional-chain': ['error'], //使用 a?.b 而不是 a && a.b
'@typescript-eslint/consistent-type-imports': ['error'], //使用 a?.b 而不是 a && a.b。
'@typescript-eslint/no-empty-interface': ['error'], //不允许定义空的接口
'@typescript-eslint/no-inferrable-types': ['error'], //不允许不必要的类型标注
'@typescript-eslint/no-non-null-asserted-optional-chain': ['error'], //不允许非空断言与可选链同时使用: foo?.bar!
'@typescript-eslint/no-throw-literal': ['error'], //不允许直接 throw 一个字符串
'@typescript-eslint/no-unnecessary-boolean-literal-compare': ['error'], //不允许对布尔类型变量的 === 比较,
'@typescript-eslint/no-unnecessary-type-arguments': ['error'], //不允许与默认值一致的泛型参数
'@typescript-eslint/no-unnecessary-type-assertion': ['error'], //不允许与实际值一致的类型断言
'@typescript-eslint/no-unnecessary-type-constraint': ['error'], //不允许与默认约束一致的泛型约束,
'@typescript-eslint/non-nullable-type-assertion-style': ['error'], //要求在类型断言仅起到去空值作用
'@typescript-eslint/prefer-as-const': ['error'], //对于常量断言,使用 as const 而不是 <const>
'@typescript-eslint/prefer-literal-enum-member': ['error'], //对于枚举成员值,只允许使用普通字符串、数字、null、正则,而不允许变量复制、模板字符串等需要计算的操作
'@typescript-eslint/prefer-ts-expect-error': ['error'], //使用 @ts-expect-error 而不是 @ts-ignore。
'@typescript-eslint/switch-exhaustiveness-check': ['error'], //switch 的判定条件为 联合类型 时,其每一个类型分支都需要被处理
"@typescript-eslint/no-var-requires": "0"
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/KittySnow/space-front.git
git@gitee.com:KittySnow/space-front.git
KittySnow
space-front
space-front
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385