vue3+TS+eslint9配置

记录eslint升级到9.x的版本之后遇到的坑

  1. 在 ESLint 9 中,配置方式发生了变化。Flat Config 格式(eslint.config.js 或 .ts)不再支持 extensions 选项。所以vscode编辑器中的 extensions 需要注释掉,要不然保存的时候不会格式化。
  1. eslint9 只支持eslint.config.js/eslint.config.ts的写法,使用vite默认生成的项目模板不能格式化
javascript 复制代码
import globals from 'globals'
import pluginJs from '@eslint/js'
import tseslint from 'typescript-eslint'
import pluginVue from 'eslint-plugin-vue'
import pluginPrettierRecommendedConfigs from 'eslint-plugin-prettier/recommended'
import parserVue from 'vue-eslint-parser';
export default [
  // eslint 默认推荐规则
  pluginJs.configs.recommended,
  // ts 默认推荐规则
  ...tseslint.configs.recommended,
  // vue3 基础推荐规则
  ...pluginVue.configs['flat/recommended'],
  // prettier 默认推荐规则
  pluginPrettierRecommendedConfigs,
  {
    languageOptions: {
      globals: {
        ...globals.browser,
        ...globals.es2020,
        ...globals.node,
      },
      ecmaVersion: 2020,
      parser: parserVue,
      parserOptions: {
        parser: tseslint.parser,
      },
    },
    rules: {
      // 覆盖 TypeScript 严格规则,允许显式 any
      '@typescript-eslint/no-explicit-any': 'off',
      'vue/multi-word-component-names': 'off',
      'vue/require-default-prop': 'off',
      '@typescript-eslint/no-unused-vars': 'off',
    },
  },
]
  1. eslint依赖项
  2. eslint 调试方式

    查看报错信息依次处理
相关推荐
笃行35026 分钟前
集中式与分布式,KingbaseES 的四种形态共用一套内核
前端
陈随易2 小时前
Vue 编译器换掉 source map,快了三四成
前端·后端·程序员
ZhengEnCi3 小时前
12 种高级 UI 交互效果及对应 AI 提示词:从按压回弹到底部抽屉的物理感教学
前端·css·交互设计
IT_陈寒6 小时前
Redis大key删除为什么会导致服务卡顿?我的线上事故复盘
前端·人工智能·后端
用户2705077725246 小时前
MCP 最小 Server 实测:3 个 JSON-RPC 报错与修法
前端
用户499335025076 小时前
一人VIP账号多人共用:Web 代理里的会话共享怎么实现
前端
用户老李6 小时前
无线电自学教程 05:第一台收音机——从矿石机到 SDR
前端
IPIPD7 小时前
Node.js请求遇到503怎么重试?先解析Retry-After,再做有上限退避
前端
葡萄城技术团队7 小时前
dsh-spreadjs-editor 的集成链路:把 SpreadJS Designer 嵌进 Agent 工作台
前端
FlyWIHTSKY7 小时前
vue2和vue3有什么区别,用法上有哪些区别
前端·javascript·vue.js