desktop_task_schedule/code/web/task_schedule/.eslintrc.cjs

201 lines
9.5 KiB
JavaScript
Raw Normal View History

2023-02-15 05:07:17 +00:00
/*
* @Author: Kane
2023-03-17 06:40:04 +00:00
* @Date: 2023-03-14 09:19:21
2023-02-15 05:07:17 +00:00
* @LastEditors: Kane
2023-03-04 16:37:24 +00:00
* @FilePath: /task_schedule/.eslintrc.cjs
2023-03-17 06:40:04 +00:00
* @Description: eslint 配置文件
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
2023-02-15 05:07:17 +00:00
*/
module.exports = {
2023-03-17 06:40:04 +00:00
root: true,
env: { // 需要在env中指定运行的环境这些环境其实就是一组预定义的全局变量让 ESLint 知道当前环境存在这些全局变量
node: true,
browser: true,
es2021: true,
},
parser:"espree",
2023-03-20 10:05:44 +00:00
parserOptions:{
sourceType: "module",
ecmaVersion: 2021,
},
extends:["eslint:recommended",],
rules:{
2023-03-31 15:58:41 +00:00
indent: ["warn", 4,],
2023-03-31 15:41:03 +00:00
// 圆括号中的空格,为空不加空格,紧跟花括号、方括号、圆括号时也不加入空格
2023-03-31 15:58:41 +00:00
"space-in-parens": ["error", "always", { exceptions: ["{}", "[]", "()", "empty",], },],
2023-03-04 16:37:24 +00:00
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
2023-03-17 06:40:04 +00:00
"no-unused-vars": "warn",
2023-03-31 15:58:41 +00:00
semi: ["error", "always",], // 控制行尾部分号
quotes: ["error", "double",],
"comma-dangle": ["error", {
2023-03-17 06:40:04 +00:00
arrays: "always",
objects: "always",
imports: "never",
exports: "never",
functions: "never",
},], // 数组和对象键值对最后一个逗号
2023-03-31 15:58:41 +00:00
"comma-style": ["error", "last",], // 逗号在行位
2023-03-17 06:40:04 +00:00
"no-undef-init": "error",
"no-invalid-this": "error",
"no-use-before-define": "error",
"no-shadow-restricted-names": "error", // 禁止对一些关键字或者保留字进行赋值操作比如NaN、Infinity、undefined、eval、arguments等
2023-03-31 15:58:41 +00:00
"comma-spacing": ["error", { before: false, after: true, },],
"array-bracket-spacing": ["error", "never", {
singleValue: false,
objectsInArrays: false,
arraysInArrays: false,
},],
"brace-style": ["error", "allman", { allowSingleLine: true, },],
2023-03-17 06:40:04 +00:00
"prefer-const": "warn",
2023-03-31 15:58:41 +00:00
"space-before-function-paren": ["error", {
2023-03-17 06:40:04 +00:00
anonymous: "always",
named: "never",
asyncArrow: "always",
},],
2023-02-28 10:48:14 +00:00
},
2023-03-17 06:40:04 +00:00
overrides: [
{
files: ["*.vue",],
parser: "vue-eslint-parser",
parserOptions: {
ecmaVersion: 2021,
sourceType: "module",
parser: { // <script>标签中的lang属性配置不同的parser
ts: "@typescript-eslint/parser",
js: "espree",
"<template>": "espree",
},
2023-08-25 12:47:36 +00:00
project: "./tsconfig.json",
extraFileExtensions: [".vue",],
},
plugins: ["eslint-plugin-vue",],
extends: [
"plugin:vue/vue3-essential",
"plugin:vue/recommended",
"eslint:recommended",
2023-08-25 12:47:36 +00:00
// "standard-with-typescript",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
],
rules: {
2023-03-31 15:58:41 +00:00
indent: ["warn", 4,],
2023-08-25 12:47:36 +00:00
"no-trailing-spaces": ["error", {"ignoreComments": true,},],
2023-03-31 15:41:03 +00:00
// 圆括号中的空格,为空不加空格,紧跟花括号、方括号、圆括号时也不加入空格
2023-03-31 15:58:41 +00:00
"space-in-parens": ["error", "always", { exceptions: ["{}", "[]", "()", "empty",], },],
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-unused-vars": "warn",
2023-08-25 12:47:36 +00:00
"semi-spacing": ["error", {"before": false, "after": true,},], // 控制行尾部分号
"quotes": ["error", "double",],
2023-03-31 15:58:41 +00:00
"comma-dangle": ["error", {
arrays: "always",
objects: "always",
imports: "never",
exports: "never",
functions: "never",
},], // 数组和对象键值对最后一个逗号
2023-03-31 15:58:41 +00:00
"comma-style": ["error", "last",], // 逗号在行位
"no-undef-init": "error",
"no-invalid-this": "error",
"no-use-before-define": "error",
"no-shadow-restricted-names": "error", // 禁止对一些关键字或者保留字进行赋值操作比如NaN、Infinity、undefined、eval、arguments等
2023-03-31 15:58:41 +00:00
"brace-style": ["error", "allman", { allowSingleLine: true, },],
"prefer-const": "warn",
2023-03-31 15:58:41 +00:00
"space-before-function-paren": ["error", {
anonymous: "always",
named: "never",
asyncArrow: "always",
},],
// vue
2023-03-31 15:58:41 +00:00
"vue/html-indent": ["error", 4,],
// typescript
2023-03-31 15:58:41 +00:00
"@typescript-eslint/indent": ["warn", 4,],
"@typescript-eslint/no-extra-semi": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/member-delimiter-style": "off",
2023-03-31 15:58:41 +00:00
"@typescript-eslint/semi": ["error", "always",], // 控制行尾部分号
"@typescript-eslint/brace-style": ["error", "allman", { allowSingleLine: true, },],
"@typescript-eslint/comma-dangle": ["error", {
arrays: "always",
objects: "always",
imports: "never",
exports: "never",
functions: "never",
},], // 数组和对象键值对最后一个逗号
2023-03-31 15:58:41 +00:00
"@typescript-eslint/quotes": ["error", "double",],
"@typescript-eslint/space-before-function-paren": "off",
2023-04-04 09:58:05 +00:00
// 方括号的空格问题
"comma-spacing": ["error", { before: false, after: true, },],
"@typescript-eslint/comma-spacing": ["off", { before: false, after: true, },], // 使用eslint的不用ts的
"array-bracket-spacing": ["error", "never", {
singleValue: false,
objectsInArrays: false,
arraysInArrays: false,
},],
},
},
2023-03-17 06:40:04 +00:00
{
files: ["*.ts",],
parser: "@typescript-eslint/parser",
parserOptions: {
project: "./tsconfig.json",
},
plugins: ["@typescript-eslint",],
extends: [
"eslint:recommended",
2023-08-25 12:47:36 +00:00
"standard-with-typescript",
2023-03-17 06:40:04 +00:00
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
],
rules: {
2023-08-25 12:47:36 +00:00
"no-trailing-spaces": ["error", {"ignoreComments": true,},],
2023-03-31 15:41:03 +00:00
// 圆括号中的空格,为空不加空格,紧跟花括号、方括号、圆括号时也不加入空格
2023-03-31 15:58:41 +00:00
"space-in-parens": ["error", "always", { exceptions: ["{}", "[]", "()", "empty",], },],
2023-03-17 06:40:04 +00:00
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
2023-07-11 02:49:14 +00:00
"@typescript-eslint/no-explicit-any": "warn",
2023-03-31 15:58:41 +00:00
"@typescript-eslint/indent": ["error", 4,],
2023-03-17 06:40:04 +00:00
"@typescript-eslint/no-extra-semi": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/member-delimiter-style": "off",
2023-03-31 15:58:41 +00:00
"@typescript-eslint/semi": ["error", "always",], // 控制行尾部分号
"@typescript-eslint/brace-style": ["error", "allman", { allowSingleLine: true, },],
"@typescript-eslint/comma-dangle": ["error", {
2023-03-17 06:40:04 +00:00
arrays: "always",
objects: "always",
imports: "never",
exports: "never",
functions: "never",
},], // 数组和对象键值对最后一个逗号
2023-03-31 15:58:41 +00:00
"@typescript-eslint/quotes": ["error", "double",],
2023-03-17 06:40:04 +00:00
"@typescript-eslint/space-before-function-paren": "off",
2023-03-31 15:58:41 +00:00
"@typescript-eslint/strict-boolean-expressions": ["error", {
2023-03-17 06:40:04 +00:00
allowString: false,
},],
2023-03-31 15:58:41 +00:00
"comma-style": ["error", "last",], // 逗号在行位
2023-04-04 09:58:05 +00:00
"comma-spacing": ["error", { before: false, after: true, },],
"@typescript-eslint/comma-spacing": ["off", { before: false, after: true, },], // 使用eslint的不用ts的
"array-bracket-spacing": ["error", "never", {
2023-03-31 15:41:03 +00:00
singleValue: false,
objectsInArrays: false,
arraysInArrays: false,
},],
2023-03-17 06:40:04 +00:00
"no-undef-init": "error",
"no-invalid-this": "error",
"no-use-before-define": "error",
"no-shadow-restricted-names": "error", // 禁止对一些关键字或者保留字进行赋值操作比如NaN、Infinity、undefined、eval、arguments等
"prefer-const": "warn",
"spaced-comment": "error",
"space-before-function-paren": "off",
2023-08-25 12:47:36 +00:00
"semi-spacing": ["error", {"before": false, "after": true,},],
2023-03-17 06:40:04 +00:00
},
},
],
2023-02-15 05:07:17 +00:00
};