From a39f3b4deda74cb7cd69e063537cb55099440b38 Mon Sep 17 00:00:00 2001 From: Kane Date: Fri, 31 Mar 2023 22:12:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E8=BF=9B=E5=BA=A6=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/ts-practice/.eslintrc.cjs | 260 ++++++++++++++++-------- code/ts-practice/package-lock.json | 316 +++++++++++++++++++++-------- code/ts-practice/package.json | 14 +- code/ts-practice/src/type.ts | 10 +- 4 files changed, 424 insertions(+), 176 deletions(-) diff --git a/code/ts-practice/.eslintrc.cjs b/code/ts-practice/.eslintrc.cjs index b9c0f3d..c07786e 100644 --- a/code/ts-practice/.eslintrc.cjs +++ b/code/ts-practice/.eslintrc.cjs @@ -1,100 +1,190 @@ /* * @Author: Kane - * @Date: 2022-12-14 15:12:46 + * @Date: 2023-03-14 09:19:21 * @LastEditors: Kane - * @LastEditTime: 2023-03-06 14:25:14 * @FilePath: /ts-practice/.eslintrc.cjs - * @Description: - * - * Copyright (c) ${2022} by Kane, All Rights Reserved. + * @Description: eslint 配置文件 + * + * Copyright (c) ${2022} by Kane, All Rights Reserved. */ module.exports = { - root: true, - env: { //需要在 env 中指定运行的环境,这些环境其实就是一组预定义的全局变量,让 ESLint 知道当前环境存在这些全局变量 - node: true, - browser: true, - es2021: true, - }, - extends: [ - "eslint:recommended", - ], - // parser: "@babel/eslint-parser", - parserOptions: { - ecmaVersion: 2021, - sourceType: "module", - parser: "@babel/eslint-parser", - requireConfigFile: false, - }, - rules: { - "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", - "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off", - "no-unused-vars": "warn", - "semi": ["error", "always",], //控制行尾部分号 - "quotes": ["error", "double",], - "comma-dangle": ["error", { - "arrays": "always", - "objects": "always", - "imports": "never", - "exports": "never", - "functions": "never", - },], //数组和对象键值对最后一个逗号 - "comma-style": ["error", "last",], //逗号在行位 - "array-bracket-spacing": ["error", "never",], - "no-undef-init": "error", - "no-invalid-this": "error", - "no-use-before-define": "error", - "no-shadow-restricted-names": "error", //禁止对一些关键字或者保留字进行赋值操作,比如NaN、Infinity、undefined、eval、arguments等 - "comma-spacing": ["error", { "before": false, "after": true, },], - "brace-style": ["error", "allman", { "allowSingleLine": true, },], - "prefer-const": "warn", - }, - overrides: [ - { - files: ["*.ts",], - parser: "@typescript-eslint/parser", - parserOptions: { - project: "./tsconfig.json", - }, - plugins: ["@typescript-eslint",], - extends: [ - "standard-with-typescript", - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - ], - rules: { + root: true, + env: { // 需要在env中指定运行的环境,这些环境其实就是一组预定义的全局变量,让 ESLint 知道当前环境存在这些全局变量 + node: true, + browser: true, + es2021: true, + }, + parser:"espree", + parserOptions:{ + sourceType: "module", + ecmaVersion: 2021, + }, + extends:["eslint:recommended",], + rules:{ + indent: [ "warn", 4, ], + // 圆括号中的空格,为空不加空格,紧跟花括号、方括号、圆括号时也不加入空格 + "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", - "@typescript-eslint/indent": ["error", 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", - "@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", - },], //数组和对象键值对最后一个逗号 - "@typescript-eslint/quotes": ["error", "double",], - "@typescript-eslint/space-before-function-paren": "off", - "@typescript-eslint/strict-boolean-expressions": ["error", { - "allowString": false, + "no-unused-vars": "warn", + semi: [ "error", "always", ], // 控制行尾部分号 + quotes: [ "error", "double", ], + "comma-dangle": [ "error", { + arrays: "always", + objects: "always", + imports: "never", + exports: "never", + functions: "never", + },], // 数组和对象键值对最后一个逗号 + "comma-style": [ "error", "last", ], // 逗号在行位 + "array-bracket-spacing": [ "error", "always", { + singleValue: false, + objectsInArrays: false, + arraysInArrays: false, },], - "comma-style": ["error", "last",], //逗号在行位 - "array-bracket-spacing": ["error", "never",], "no-undef-init": "error", "no-invalid-this": "error", "no-use-before-define": "error", - "no-shadow-restricted-names": "error", //禁止对一些关键字或者保留字进行赋值操作,比如NaN、Infinity、undefined、eval、arguments等 + "no-shadow-restricted-names": "error", // 禁止对一些关键字或者保留字进行赋值操作,比如NaN、Infinity、undefined、eval、arguments等 + "comma-spacing": [ "error", { before: false, after: true, },], + "brace-style": [ "error", "allman", { allowSingleLine: true, },], "prefer-const": "warn", - "spaced-comment": "error", - "space-before-function-paren": "off", - }, + "space-before-function-paren": [ "error", { + anonymous: "always", + named: "never", + asyncArrow: "always", + },], }, - ], + overrides: [ + { + files: ["*.vue",], + parser: "vue-eslint-parser", + parserOptions: { + ecmaVersion: 2021, + sourceType: "module", + parser: { //