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

使用 @antfu/eslint-config 配置 eslint (包含兼容uniapp方法)

  1. 安装 pnpm i -D eslint @antfu/eslint-config
  2. 创建 eslint.config.js 文件
// 如果没有在 page.json 配置 "type": "module" 
const antfu = require('@antfu/eslint-config').default
module.exports = antfu()

// 配置了 "type": "module" 
import antfu from '@antfu/eslint-config'
export default antfu()
  1. 创建 .vscode/settings.json 文件 配置保存自动修复 (如果不需要可以跳过)
{
  // Enable the ESlint flat config support
  "eslint.experimental.useFlatConfig": true,

  // Disable the default formatter, use eslint instead
  "prettier.enable": false,
  "editor.formatOnSave": false,

  // Auto fix
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit",
    "source.organizeImports": "never"
  },

  // Silent the stylistic rules in you IDE, but still auto fix them
  "eslint.rules.customizations": [
    { "rule": "style/*", "severity": "off" },
    { "rule": "*-indent", "severity": "off" },
    { "rule": "*-spacing", "severity": "off" },
    { "rule": "*-spaces", "severity": "off" },
    { "rule": "*-order", "severity": "off" },
    { "rule": "*-dangle", "severity": "off" },
    { "rule": "*-newline", "severity": "off" },
    { "rule": "*quotes", "severity": "off" },
    { "rule": "*semi", "severity": "off" }
  ],

  // Enable eslint for all supported languages
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact",
    "vue",
    "html",
    "markdown",
    "json",
    "jsonc",
    "yaml"
  ]
}
  1. 修改规则(适用于uniapp)
module.exports = antfu({
  overrides: {
    vue: {
      'vue/component-name-in-template-casing': ['error', 'PascalCase' | 'kebab-case', { registeredComponentsOnly: false, ignores: [] }],
    },
  },
})

解释:

  • vue/component-name-in-template-casing 为了解决在uniapp 里面驼峰命名组件无效的问题

http://www.kler.cn/news/108554.html

相关文章:

  • 社恐了怎么办?如何改变社交恐惧症?
  • 代码随想录算法训练营第23期day36|738.单调递增的数字、968.监控二叉树
  • request、response请求转发和重定向
  • C++面试题库
  • el-date-picker日期选择器奇怪的问题解决
  • github搜索技巧探索
  • 人工智能与航天技术的融合:未来发展的新趋势
  • 2015年亚太杯APMCM数学建模大赛B题城市公共交通服务水平动态评价模型求解全过程文档及程序
  • java spring boot 字符串判空
  • 黔院长 | 一文了解五脏的脏象!
  • 【计算机网络】(谢希仁第八版)第二章课后习题答案
  • PHP危险函数
  • Qt之实现支持多选的QCombobox
  • MySQL安装『适用于 CentOS 7』
  • 防止消息丢失与消息重复——Kafka可靠性分析及优化实践
  • 微机原理:汇编语言程序设计
  • 两数之和(C++解法)
  • 【Oracle】Navicat Premium 连接 Oracle的两种方式
  • 分类预测 | Matlab实现KOA-CNN-GRU-selfAttention多特征分类预测(自注意力机制)
  • Python——新建工程/引入本地库
  • 基于PHP的仓库库存管理系统设计与实现(源码+lw+部署文档+讲解等)
  • 【VR开发】【Unity】【VRTK】1-无代码VRVR开发介绍
  • SQL SELECT TOP, LIMIT, ROWNUM
  • 悟空crm安装搭建 报错[0] RedisException in Redis.php line 56问题处理办法
  • 若依ruoyi-nbcio如何做一个仿钉钉流程设计器的思考
  • SylixOS BSP开发(七)
  • vue源码分析(六)——vnode 和 createElement的使用和作用
  • SQL-正则表达式和约束
  • redis中的io多线程(线程池)
  • SQLSmith: Databend 如何利用随机化测试检测 Bug