alioth/before/pac-auth/.eslintrc.js
2025-05-30 09:18:01 +08:00

90 lines
5.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
project: "tsconfig.json",
tsconfigRootDir: __dirname,
sourceType: "module"
},
plugins: ["@typescript-eslint/eslint-plugin", "prettier"],
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"prettier"
],
root: true,
env: {
node: true,
jest: true
},
ignorePatterns: [".eslintrc.js"],
rules: {
"max-len": ["error", {
"code": 160, // 指定最大代码长度
"ignoreStrings": true, // 忽略字符串中的字符长度
"ignoreUrls": true, // 忽略URL的长度
"ignoreComments": false, // 注释中的字符会计入长度限制
"ignoreTemplateLiterals": true, // 忽略模板字符串的长度
"tabWidth": 4 // 设置制表符的宽度
}],
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"indent": [
"error",
4,
{
SwitchCase: 1
}
], // 1 表示在 switch 语句中case 和 default 语句需要与 switch 的起始位置对齐,并且缩进一个级别(即 4 个空格)
// "curly": "error", // 所有的控制语句if, for, while 等)使用大括号括起来,即使它们只包含单个语句。
"quotes": ["error", "single"], // 强制使用一致的引号风格
"no-unused-expressions": "error", // 禁止使用未使用的表达式
"no-console": "error", // 禁止使用console
"semi": ["error", "always"], // 启用 semi 规则,要求语句后总是使用分号,并将其设置为错误
// "new-cap": "error", //要求使用 new 关键字创建的实例的构造函数名必须大写。
"no-const-assign": "error", //禁止给 const 声明的变量赋值
"no-duplicate-case": "error", // 禁止 switch 语句中出现重复的 case
"no-extra-parens": "error", // 限制不必要的括号
"no-fallthrough": "error", //:禁止 switch 语句中的穿透行为
"no-multi-spaces": "error", //禁止使用多个空格。
"no-trailing-spaces": "error", //:禁止行尾有空格。
"no-undef": "error", //:禁止使用未声明的变量。
"no-undef-init": "error", //禁止初始化变量时使用 undefined。
"no-empty": 2, //块语句中的内容不能为空
"no-extra-semi": 2, //禁止多余的冒号
"no-func-assign": 2, //禁止重复的函数声明
"no-inline-comments": 2, //禁止行内备注
"space-before-function-paren": [
"error",
{
// "always" - 要求在函数名和参数列表之间总是有空白。
// "never" - 禁止在函数名和参数列表之间有空格。
anonymous: "always", // "anonymous" - 指定匿名函数表达式前的空格要求("always" 或 "never")。
named: "never", // "named" - 指定具名函数表达式前的空格要求("always" 或 "never")。
asyncArrow: "always" // "asyncArrow" - 指定异步箭头函数前的空格要求("always" 或 "never"
}
],
"no-multiple-empty-lines": [1, { max: 2 }], //空行最多不能超过2行
"no-nested-ternary": 0, //禁止使用嵌套的三目运算
"no-redeclare": 2, //禁止重复声明变量
"no-shadow": 2, //外部作用域中的变量不能与它所包含的作用域中的变量或参数同名
// 'no-unused-vars': [2, { vars: 'all', args: 'after-used' }], //不能有声明后未被使用的变量或参数
"no-use-before-define": 2, //未定义前不能使用
"no-mixed-spaces-and-tabs": "error", // 禁止在代码中混用空格和制表符
"lines-around-comment": [
"error",
{
beforeBlockComment: true, // beforeBlockComment: 在块级注释(以 /* 开头)之前需要有空行。
afterBlockComment: false, // afterBlockComment: 在块级注释之后需要有空行。
beforeLineComment: true, // beforeLineComment: 在行注释(以 // 开头)之前需要有空行。
afterLineComment: false, // afterLineComment: 在行注释之后需要有空行。
allowBlockStart: true, // allowBlockStart: 允许块级注释紧跟在函数或块的开始。
allowClassStart: true, // allowClassStart: 允许块级注释紧跟在类定义的开始。
allowObjectStart: true, // allowObjectStart: 允许块级注释紧跟在对象字面量的开始。
allowArrayStart: true // allowArrayStart: 允许块级注释紧跟在数组字面量的开始。
}
]
}
};