You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
initkoa/.eslintrc.cjs

66 lines
3.1 KiB

10 months ago
module.exports = {
"env": {
"browser": true,
"es2021": true,
"es2022": true,
"es2023": true,
},
"extends": ["eslint:recommended"],
"overrides": [
{
"env": {
"node": true
},
"files": [
".eslintrc.{js,cjs}"
],
"parserOptions": {
"sourceType": "script"
}
}
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"rules": {
indent: ['error', 4, { "SwitchCase": 1 }], // 用于指定代码缩进的方式,这里配置为使用四个空格进行缩进。
// 'linebreak-style': [0, 'error', 'windows'], // 用于指定换行符的风格,这里配置为使用 Windows 风格的换行符(\r\n)。
quotes: ['error', 'single'], // 用于指定字符串的引号风格,这里配置为使用单引号作为字符串的引号。
semi: ['error', 'always'], //用于指定是否需要在语句末尾添加分号,这里配置为必须始终添加分号。
"no-console": 2,//禁止使用console
"no-const-assign": 2,//禁止修改const声明的变量
"no-empty": 2,//块语句中的内容不能为空
"no-extra-parens": 2,//禁止非必要的括号
"no-extra-semi": 2,//禁止多余的冒号
"no-fallthrough": 1,//禁止switch穿透
"no-func-assign": 2,//禁止重复的函数声明
"no-inline-comments": 2,//禁止行内备注
"no-irregular-whitespace": 2,//不能有不规则的空格
"no-mixed-spaces-and-tabs": [2, false],//禁止混用tab和空格
"no-multi-spaces": 1,//不能用多余的空格
"no-multiple-empty-lines": [1, {"max": 2}],//空行最多不能超过2行
"no-nested-ternary": 0,//禁止使用嵌套的三目运算
"no-redeclare": 2,//禁止重复声明变量
"no-shadow": 2,//外部作用域中的变量不能与它所包含的作用域中的变量或参数同名
"no-trailing-spaces": 2,//一行结束后面不要有空格
"no-unexpected-multiline": 2,//避免多行表达式
"no-unused-vars": [2, {"vars": "all", "args": "after-used"}],//不能有声明后未被使用的变量或参数
"no-use-before-define": 2,//未定义前不能使用
"no-var": 2,//禁用var,用let和const代替
"arrow-parens": 0,//箭头函数用小括号括起来
"array-bracket-spacing": [2, "never"],//是否允许非空数组里面有多余的空格
"camelcase": 2,//强制驼峰法命名
"comma-style": [2, "last"],//逗号风格,换行时在行首还是行尾
"comma-spacing": ["error", {"before": false, "after": true}],//对象字面量中冒号的前后空格
"key-spacing": ["error", { "beforeColon": false, "afterColon": true }],// 冒号后面有空格
"lines-around-comment": 0,//行前/行后备注
"array-bracket-spacing": ["error", "always"],// 检查数组字面量中的元素之间的空格。
},
"globals": {
global: true,
Buffer: true,
process: true
}
}