当前位置: 首页 > 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下方

http://www.xdnf.cn/news/131635.html

相关文章:

  • 天机学堂day10作业,完善兑换优惠券功能
  • Python编程的真谛:超越语法,理解编程本质
  • version `GLIBCXX_3.4.32‘ not found 解决方法
  • Linux操作系统从入门到实战(三)Linux基础指令(上)
  • 基于风力推进器控制的小球实验装置设计与研究
  • 推荐一些实用的慢SQL优化方案
  • 2款常用文字提取软件
  • BGE-M3模型深度技术分析
  • Linux NIO 原理深度解析:从内核到应用的高性能 I/O 之道
  • 借助内核逻辑锁pagecache到内存
  • 协议CP锁死!EtherCAT×Modbus RTU网关让破烂王秒变赛博清洁工
  • maxscript根据音频创建动画表情
  • cdh平台管理与运维最佳实践
  • 【Linux网络编程】应用层协议HTTP(实现一个简单的http服务)
  • 如何理解计算机网卡完成数据传输的串并转换
  • linux离线部署open-metadata
  • PGSql查看表结构以及注释信息
  • system.img无法打包非PRODUCT_PACKAGES目标解析
  • BUUCTF-[GWCTF 2019]re3
  • DeepSeek/AI驱动的销售业绩倍增实战
  • RHCE 第三次作业 正向解析
  • # 构建词汇表:自然语言处理中的关键步骤
  • 浏览器f12可以搜索接口的入参 和返回内容
  • 【Langchain】RAG 优化:提高语义完整性、向量相关性、召回率--从字符分割到语义分块 (SemanticChunker)
  • netcore8.0项目部署到windows服务器中(或个人windows电脑),利用nginx反向代理
  • 【c++11】c++11新特性(下)(可变参数模板、default和delete、容器新设定、包装器)
  • Browser-use使用教程
  • 智慧联络中心SaaS平台Java项目面试实战
  • Linux:进程间通信---匿名管道
  • 数字域残留频偏的补偿原理