当前位置: 首页 > news >正文

vue3项目中eslint.config.ts配置rules

vue3项目中eslint.config.ts配置rules

1. 使用npm create vue@latest创建vue项目

默认的eslint.config.ts如下

import { globalIgnores } from 'eslint/config'
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
import pluginVue from 'eslint-plugin-vue'
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
// import { configureVueProject } from '@vue/eslint-config-typescript'
// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setupexport default defineConfigWithVueTs({name: 'app/files-to-lint',files: ['**/*.{ts,mts,tsx,vue}'],},globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),pluginVue.configs['flat/essential'],vueTsConfigs.recommended,skipFormatting,
)

2. 配置rules

之前我一直在第一个对象中写rules,一直不生效,最后发现要新增一个对象写rules,并且要放在vueTsConfigs.recommended下方,代码如下:

import { globalIgnores } from 'eslint/config'
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
import pluginVue from 'eslint-plugin-vue'
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
// import { configureVueProject } from '@vue/eslint-config-typescript'
// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setupexport default defineConfigWithVueTs({name: 'app/files-to-lint',files: ['**/*.{ts,mts,tsx,vue}'],},globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),pluginVue.configs['flat/essential'],vueTsConfigs.recommended,{rules: {'vue/multi-word-component-names': 'off','@typescript-eslint/no-explicit-any': 'off',},},skipFormatting,
)

注意:一定要放在vueTsConfigs.recommended下方

相关文章:

  • 18.ArkUI Video的介绍和使用
  • ECharts 地图开发入门
  • HD Tune Pro v6.10 简体中文汉化单文件版
  • C++_数据结构_详解红黑树
  • Winform(1.Winform控件学习)
  • 每天学一个 Linux 命令(31):md5sum
  • Linux安全模块:SELinux与AppArmor深度解析
  • ✨ Apifox:这玩意儿是接口界的“瑞士军刀”吧![特殊字符][特殊字符]
  • XYNU2024信安杯-REVERSE(复现)
  • kafka与flume的整合、spark-streaming
  • 量子加密通信技术及其应用:构建无条件安全的通信网络
  • 【合新通信】浸没式液冷光模块与冷媒兼容性测试技术报告
  • 【滑动窗口+哈希表/数组记录】Leetcode 3. 无重复字符的最长子串
  • 搜索二叉树-key的搜索模型
  • nc工具!Netcat:TCP/IP瑞士军刀!全参数详细教程!Kali Linux教程!
  • prometheus通过Endpoints自定义grafana的dashboard模块
  • 时序数据库IoTDB在航空航天领域的解决方案
  • 对Mac文字双击或三击鼠标左键没有任何反应
  • Mac 「brew」快速安装MySQL
  • 河道流量监测,雷达流量计赋能水安全智慧守护
  • 央行宣布优化两项支持资本市场的货币政策工具
  • 何立峰将访问瑞士、法国并举行中美经贸高层会谈、第十次中法高级别经济财金对话
  • 夜读丨最美的风景,在亲人的目光里
  • 上海飞银川客机触地复飞后备降西安,亲历者:不少乘客都吐了
  • 外交部:中欧关系50年发展最宝贵经验是相互尊重,求同存异
  • 五一车市消费观察:政策赋能、企业发力,汽车消费火热