| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- module.exports = {
- "root":true,
- "env": {
- "browser": true,
- "es2021": true
- },
- "extends": [
- "eslint:recommended",
- "plugin:vue/vue3-essential",
- "plugin:@typescript-eslint/recommended"
- ],
- "overrides": [
- ],
- "parser": "vue-eslint-parser",
- "parserOptions": {
- "ecmaVersion": "latest",
- "parser":"@typescript-eslint/parser",
- "sourceType": "module"
- },
- "ignorePatterns":[".eslintrc.cjs"],
- "plugins": [
- "vue",
- "@typescript-eslint"
- ],
- "rules": {
- "for-direction": "error", // for 循环迭代条件是否正确
- "vue/component-name-in-template-casing": ["error", "kebab-case", {
- "registeredComponentsOnly": false,
- "ignores": []
- }],
- "vue/no-use-v-if-with-v-for": ["error", {
- "allowUsingIterationVar": false
- }],
- "vue/require-v-for-key": "error",
- "vue/prop-name-casing": ["error", "camelCase"],
- // getter 函数中出现 return 语句
- "getter-return": "error",
- // getter 函数中出现 return 语句
- "no-async-promise-executor": "error",
- // getter 函数中出现 return 语句
- "no-compare-neg-zero": "error",
- "vue/max-attributes-per-line": [2, {
- singleline: 10,
- multiline: {
- max: 1
- }
- }],
- "vue/v-bind-style": ["error", "shorthand"],
- "vue/v-on-style": ["error", "shorthand"],
- "vue/no-v-model-argument": "off",
- "vue/no-multiple-template-root": "off",
- "vue/singleline-html-element-content-newline": "off",
- "vue/multiline-html-element-content-newline": "off",
- "vue/component-definition-name-casing": ["error", "PascalCase"],
- "vue/no-v-html": "off",
- // 强制 getter 和 setter 在对象中成对出现
- "accessor-pairs": 2,
- // 强制箭头函数的箭头前后使用一致的空格
- "arrow-spacing": [2, {
- before: true,
- after: true
- }],
- // 禁止或强制在代码块中开括号前和闭括号后有空格
- "block-spacing": [2, "always"],
- // 强制在代码块中使用一致的大括号风格
- "brace-style": [2, "1tbs", {
- allowSingleLine: true
- }],
- // 强制使用骆驼拼写法命名约定
- camelcase: [0, {
- properties: "always"
- }],
- // 要求或禁止末尾逗号
- "comma-dangle": [2, "never"],
- // 强制在逗号前后使用一致的空格
- "comma-spacing": [2, {
- before: false,
- after: true
- }],
- // 强制使用一致的逗号风格
- "comma-style": [2, "last"],
- // 要求在构造函数中有 super() 的调用
- "constructor-super": 2,
- // 强制所有控制语句使用一致的括号风格
- curly: [2, "multi-line"],
- "dot-location": [2, "property"], // 强制在点号之前和之后一致的换行
- "eol-last": 2, // 要求或禁止文件末尾存在空行
- eqeqeq: ["error", "always", { null: "ignore" }], // 要求使用 === 和 !==
- "generator-star-spacing": [2, {
- before: true,
- after: true
- }], // 强制 generator 函数中 * 号周围使用一致的空格
- "handle-callback-err": [2, "^(err|error)$"], // 要求回调函数中有容错处理
- indent: [2, 2, {
- SwitchCase: 1
- }], // 强制使用一致的缩进
- "jsx-quotes": [2, "prefer-single"], // 强制在 JSX 属性中一致地使用双引号或单引号
- "key-spacing": [2, {
- beforeColon: false,
- afterColon: true
- }], // 强制在对象字面量的属性中键和值之间使用一致的间距
- "keyword-spacing": [2, {
- before: true,
- after: true
- }], // 强制在关键字前后使用一致的空格
- "new-cap": [2, {
- newIsCap: true,
- capIsNew: false
- }], // 要求构造函数首字母大写
- "new-parens": 2, // 强制或禁止调用无参构造函数时有圆括号
- "no-array-constructor": 2, // 禁用 Array 构造函数
- "no-caller": 2, // 禁用 arguments.caller 或 arguments.callee
- "no-console": "off",
- "no-class-assign": 2, // 禁止修改类声明的变量
- "no-cond-assign": 2, // 禁止条件表达式中出现赋值操作符
- "no-const-assign": 2,
- "no-control-regex": 0, // 禁止在正则表达式中使用控制字符
- "no-delete-var": 2, // 禁止删除变量
- "no-dupe-args": 2, // 禁止 function 定义中出现重名参数
- "no-dupe-class-members": 2, // 禁止类成员中出现重复的名称
- "no-dupe-keys": 2, // 禁止对象字面量中出现重复的 key
- "no-duplicate-case": 2, // 禁止出现重复的 case 标签
- "no-empty-character-class": 2, // 禁止在正则表达式中使用空字符集
- "no-empty-pattern": 2, // 禁止使用空解构模式
- "no-eval": 2, // 禁用 eval()
- "no-ex-assign": 2, // 禁止对 catch 子句的参数重新赋值
- "no-extend-native": 2, // 禁止扩展原生类型
- "no-extra-bind": 2, // 禁止不必要的 .bind() 调用
- "no-extra-boolean-cast": 2, // 禁止不必要的布尔转换
- "no-extra-parens": [2, "functions"], // 禁止不必要的括号
- "no-fallthrough": 2, // 禁止 case 语句落空
- "no-floating-decimal": 2, // 禁止数字字面量中使用前导和末尾小数点
- "no-func-assign": 2, // 禁止对 function 声明重新赋值
- "no-implied-eval": 2, // 禁止使用类似 eval() 的方法
- "no-inner-declarations": [2, "functions"],
- "no-invalid-regexp": 2, // 禁止在嵌套的块中出现变量声明或 function 声明
- "no-irregular-whitespace": 2, // 禁止不规则的空白
- "no-iterator": 2, // 禁用 __iterator__ 属性
- "no-label-var": 2, // 不允许标签与变量同名
- "no-labels": [2, {
- allowLoop: false,
- allowSwitch: false
- }], // 禁用标签语句
- "no-lone-blocks": 2, // 禁用不必要的嵌套块
- "no-mixed-spaces-and-tabs": 2, // 禁止空格和 tab 的混合缩进
- "no-multi-spaces": 2, // 禁止使用多个空格
- "no-multi-str": 2, // 禁止使用多行字符串
- "no-multiple-empty-lines": [2, {
- max: 1
- }], // 禁止出现多行空行
- "no-global-assign": 2, // no-global-assign
- "no-unsafe-negation": 2, // 禁止对关系运算符的左操作数使用否定操作符
- "no-new-object": 2, // 禁用 Object 的构造函数
- "no-new-require": 2, // 禁止调用 require 时使用 new 操作符
- "no-new-symbol": 2, // 禁止 Symbolnew 操作符和 new 一起使用
- "no-new-wrappers": 2, // 禁止对 String,Number 和 Boolean 使用 new 操作符
- "no-obj-calls": 2, // 禁止把全局对象作为函数调用
- "no-octal": 2, // 禁用八进制字面量
- "no-octal-escape": 2, // 禁止在字符串中使用八进制转义序列
- "no-path-concat": 2, // 禁止对 __dirname 和 __filename 进行字符串连接
- "no-proto": 2, // 禁用 __proto__ 属性
- "no-redeclare": 2, // 禁止多次声明同一变量
- "no-regex-spaces": 2, // 禁止正则表达式字面量中出现多个空格
- "no-return-assign": [2, "except-parens"], // 禁止在 return 语句中使用赋值语句
- "no-self-assign": 2, // 禁止自我赋值
- "no-self-compare": 2, // 禁止自身比较
- "no-sequences": 2, // 禁用逗号操作符
- "no-shadow-restricted-names": 2, // 禁止将标识符定义为受限的名字
- "func-call-spacing": 2, // 要求或禁止在函数名和开括号之间有空格。
- "no-sparse-arrays": 2, // 禁用稀疏数组
- "no-this-before-super": 2, // 禁止在构造函数中,在调用 super() 之前使用 this 或 super
- "no-throw-literal": 2, // 禁止抛出异常字面量
- "no-trailing-spaces": 2, // 禁用行尾空格
- "no-undef": 2, // 禁用未声明的变量,除非它们在 /*global */ 注释中被提到
- "no-undef-init": 2, // 禁止将变量初始化为 undefined
- "no-unexpected-multiline": 2, // 禁止出现令人困惑的多行表达式
- "no-unmodified-loop-condition": 2, // 禁用一成不变的循环条件
- "no-unneeded-ternary": [2, {
- defaultAssignment: false
- }], // 禁止可以在有更简单的可替代的表达式时使用三元操作符
- "no-unreachable": 2, // 禁止在 return、throw、continue 和 break 语句之后出现不可达代码
- "no-unsafe-finally": 2, // 禁止在 finally 语句块中出现控制流语句
- "no-unused-vars": [2, {
- vars: "all",
- args: "none"
- }], // 禁止出现未使用过的变量
- "no-useless-call": 2, // 禁止不必要的 .call() 和 .apply()
- "no-useless-computed-key": 2, // 禁止在对象中使用不必要的计算属性
- "no-useless-constructor": 2, // 禁用不必要的构造函数
- "no-useless-escape": 0, // 禁用不必要的转义字符
- "no-whitespace-before-property": 2, // 禁止属性前有空白
- "no-with": 2, // 禁用 with 语句
- "one-var": [2, {
- initialized: "never"
- }], // 强制函数中的变量要么一起声明要么分开声明
- "operator-linebreak": [2, "after", {
- overrides: {
- "?": "before",
- ":": "before"
- }
- }], // 强制操作符使用一致的换行符
- "padded-blocks": [2, "never"], // 要求或禁止块内填充
- quotes: [2, "single", {
- avoidEscape: true,
- allowTemplateLiterals: true
- }], // 强制使用一致的反勾号、双引号或单引号
- semi: [2, "never"],
- "semi-spacing": [2, {
- before: false,
- after: true
- }], // 强制分号之前和之后使用一致的空格
- "space-before-blocks": [2, "always"],
- "space-before-function-paren": [2, "never"],
- "space-in-parens": [2, "never"],
- "space-infix-ops": 2,
- "space-unary-ops": [2, {
- words: true,
- nonwords: false
- }], // 强制在一元操作符前后使用一致的空格
- "spaced-comment": [2, "always", {
- markers: ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","]
- }], // 强制在注释中 // 或 /* 使用一致的空格
- "template-curly-spacing": [2, "never"], // 要求或禁止模板字符串中的嵌入表达式周围空格的使用
- "use-isnan": 2, // 要求使用 isNaN() 检查 NaN
- "valid-typeof": 2,
- "wrap-iife": [2, "any"],
- "yield-star-spacing": [2, "both"],
- yoda: [2, "never"], // 要求或禁止 “Yoda” 条件
- "prefer-const": [
- "error",
- {
- destructuring: "all",
- ignoreReadBeforeAssign: false
- }
- ], // 要求使用 const 声明那些声明后不再被修改的变量
- "no-debugger": process.env.NODE_ENV === "production" ? 2 : 0,
- "object-curly-spacing": [2, "always", {
- objectsInObjects: false
- }], // 强制在大括号中使用一致的空格
- "array-bracket-spacing": [2, "never"],
- "default-case": "off", // 要求 switch 语句中有 default 分支
- "no-plusplus": "off", // 禁用一元操作符 ++ 和 --
- "guard-for-in": "off",
- "max-len": "off", // 强制一行的最大长度
- "no-param-reassign": "off", // 禁止对 function 的参数进行重新赋值
- "import/no-unresolved": "off", // 确保导入指向一个可以解析的文件/模块
- "import/extensions": "off", // 确保在导入路径中统一使用文件扩展名
- "no-bitwise": "off", // 禁用按位运算符
- "@typescript-eslint/no-explicit-any": "off",
- "consistent-return": "off",
- "array-callback-return": "off",
- "import/no-extraneous-dependencies": "off",
- "no-restricted-syntax": "off",
- radix: "off", // 强制在 parseInt() 使用基数参数
- "linebreak-style": ["error", "unix"], // 强制使用一致的换行风格
- "import/prefer-default-export": "off", // 如果模块只输入一个名字,则倾向于默认输出
- "prefer-destructuring": "off", // 优先使用数组和对象解构
- "import/no-cycle": "off", // 禁止一个模块导入一个有依赖路径的模块回到自己身上
- "arrow-parens": "off", // 要求箭头函数的参数使用圆括号
- "no-continue": "off", // 禁用 continue 语句
- "no-prototype-builtins": "off", // 禁止直接调用 Object.prototypes 的内置属性
- "import/named": "off", // 确保命名导入与远程文件中的命名导出相对应
- "object-curly-newline": "off", // 强制大括号内换行符的一致性
- "func-names": "off", // 要求或禁止使用命名的 function 表达式
- "no-unused-expressions": "off", // 禁止出现未使用过的表达式
- "no-underscore-dangle": "off", // 禁止标识符中有悬空下划线
- "no-nested-ternary": "off", // 禁用嵌套的三元表达式
- "no-await-in-loop": "off", // 禁止在循环中出现 await
- "@typescript-eslint/no-empty-function": "off", // 不允许空函数
- "vue/html-indent": ["error", 2], // 在<template>中强制一致缩进
- "vue/multi-word-component-names": "off", // 组件命名必须为多词
- "vue/html-self-closing": ["error", {
- "html": {
- "void": "always",
- "normal": "always",
- "component": "always"
- },
- "svg": "always",
- "math": "always"
- }]
- }
- }
|