1 Star 0 Fork 1

vill-v / eslint-config

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Villv Eslint Config

NPM Version NPM Downloads NPM License

  • prettier 为基础的 eslint 配置
  • 可以在 vue typescript markdown 工作
  • 会自动 对 import 进行排序
  • 自动切换对 vue@2 vue@3 的支持

从 1.0 版本开始 将使用 ESLint Flat config 进行重构

安装

pnpm add eslint prettier -D

pnpm add @vill-v/eslint-config -D

使用

eslint.config.js

ESM

import villv from '@vill-v/eslint-config'

export default villv()

CJS

const villv = require('@vill-v/eslint-config')

module.exports = villv()

Pipeline

1.1.0 版本起,使用 eslint-flat-config-utils#composer 替换了 villv() 工厂函数返回的结果,是您可以像 @antfu/eslint-config 使用 pipeline 语法更灵活的组合 eslint 配置

// eslint.config.js
import villv from '@vill-v/eslint-config'

export default villv()
  .prepend(
    // 在预制的配置前插入某些配置
  )
  // 通过插件名覆盖部分插件配置
  .override(
    'antfu/imports',
    {
      rules: {
        'import/order': ['error', { 'newlines-between': 'always' }],
      }
    }
  )
  // 重命名插件在规则定义时的前缀
  .renamePlugins({
    'old-prefix': 'new-prefix',
    // ...
  })
  /// ...

工作环境

  • node >=16.0.0
  • eslint >=8.56.0
  • prettier >=3.0.0
  • typescript >=5.0
  • vue >=2.0||>=3.0

配置项

使用 ESLint Flat config 之后,可以更加灵活的配置eslint 选项

你可以像这样覆盖各个插件的规则与配置

import villv from '@vill-v/eslint-config'

export default villv({
  vue: {
    overides: {
      'vue/no-v-html': 'error',
    },
  },
  // 可以定制根据特定 ignore 文件快捷让 eslint 忽略一些文件
  gitignore: {
    files: ['.gitignore', '.eslintignore', '.dockerignore'],
  },
})

详细的配置项请查看Options

您也可以在 villv 的基础上加上更多额外的自定义ESLint Flat config规则与插件

import villv from '@vill-v/eslint-config'
import react from 'eslint-plugin-react'

export default villv(
  {
    //。。。villv 内置插件的配置
  },
  {
    rules: {
      'no-undef': 'off',
    },
  },
  {
    plugin: {
      react,
    },
  }
)

其他代码规范

eslint config - eslint flat 风格的配置集合

prettier config - prettier 的默认配置

tsconfig - typescript tsconfig.json 基础配置

License

MIT License

MIT License Copyright (c) 2022 白鸢 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

vill-v个人eslint规则预设 展开 收起
TypeScript 等 2 种语言
MIT
取消

发行版 (34)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/vill-v/eslint-config.git
git@gitee.com:vill-v/eslint-config.git
vill-v
eslint-config
eslint-config
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891