zl程序教程

您现在的位置是:首页 >  前端

当前栏目

vue3 - .eslintrc.js配置,包括开启debugger 等能力

Vue3JS配置 开启 能力 包括 debugger
2023-09-14 09:06:39 时间

在 package.json 文件 的 eslintConfig 配置部分加入

 "no-debugger": "off",
"no-console": "off",

意思为让eslint将debugger开启,并开启控制台

 也可以在  .eslintrc.js 文件 里添加,这是等效的,因为  .eslintrc.js是eslint的专属配置文件,同时其配置也可以写在 package.json 文件中

 

 

 

这是我常用的.eslintrc.js配置
module.exports = {
  root: true,
  env: {
    node: true,
    "vue/setup-compiler-macros": true
  },
  extends: [
    "plugin:vue/vue3-essential",
    "eslint:recommended",
    "@vue/typescript/recommended",
    "@vue/prettier"
  ],
  parserOptions: {
    ecmaVersion: 2020,
    ecmaFeatures: {
      jsx: true
    }
  },
  rules: {
    "no-console": "off",
    "no-debugger": "off",
    "generator-star-spacing": "off",
    "no-tabs": "off",
    "no-unused-vars": "off",
    "no-irregular-whitespace": "off",
    "@typescript-eslint/no-explicit-any": ["off"],
    "@typescript-eslint/no-var-requires": 0,
    "vue/multi-word-component-names": "off"
  }
};
View Code

 

意思如下

开启控制台
"
no-console": "off",
开启debugger
"no-debugger": "off",
关闭代码编写时以空格开头
"generator-star-spacing": "off",
开启代码编写时可写tab键
"no-tabs": "off",
开启var定义
"no-unused-vars": "off",
开启不规则空白
"no-irregular-whitespace": "off",
关闭泛型为any的报错
"@typescript-eslint/no-explicit-any": ["off"],
使用require()方法引入文件赋值给常量时,关闭报错
"@typescript-eslint/no-var-requires": 0,
关闭强制组件命名时必须多个并驼峰名称
"vue/multi-word-component-names": "off"