# eslint-config **Repository Path**: vill-v/eslint-config ## Basic Information - **Project Name**: eslint-config - **Description**: vill-v个人eslint规则预设 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2022-05-02 - **Last Updated**: 2025-08-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Villv Eslint Config [![NPM Version](https://img.shields.io/npm/v/%40vill-v%2Feslint-config?style=flat-square)](https://www.npmjs.com/package/@vill-v/eslint-config) [![NPM Downloads](https://img.shields.io/npm/dm/%40vill-v%2Feslint-config?style=flat-square)](https://www.npmjs.com/package/@vill-v/eslint-config) [![NPM License](https://img.shields.io/npm/l/%40vill-v%2Feslint-config?style=flat-square)](https://www.npmjs.com/package/@vill-v/eslint-config) - prettier 为基础的 eslint 配置 - 可以在 **vue typescript markdown** 工作 - 会自动 对 **import** 进行排序 - 自动切换对 **vue@2 vue@3** 的支持 - 需要 **eslint >=9.20.0** > 从 1.0 版本开始 将使用 [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new) 进行重构 > 从 3.0 版本开始,修改为 **ESM only** 需要 **eslint >=9.20.0** ## 安装 ```shell pnpm add eslint prettier -D pnpm add @vill-v/eslint-config -D ``` ## 使用 ### eslint.config.{js,mjs,ts,mts} ```ts import villv from '@vill-v/eslint-config' export default villv() ``` ## Pipeline 于 `1.1.0` 版本起,使用 [`eslint-flat-config-utils#composer`](https://github.com/antfu/eslint-flat-config-utils) 替换了 `villv()` 工厂函数返回的结果,是您可以像 [`@antfu/eslint-config`](https://github.com/antfu/eslint-config/tree/main?tab=readme-ov-file#pipeline) 使用 **pipeline** 语法更灵活的组合 eslint 配置 ```ts // 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 ^18.18.0 || >=20.0. - eslint >=9.20.0 - prettier >=3.0.0 - typescript >=5.0 - vue >=2.0||>=3.0 ## 配置项 使用 [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new) 之后,可以更加灵活的配置eslint 选项 你可以像这样覆盖各个插件的规则与配置 ```js 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](https://gitee.com/vill-v/code-lint/blob/master/packages/eslint-config-scope/src/types.ts) 您也可以在 `villv` 的基础上加上更多额外的自定义[ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new)规则与插件 ```js import react from 'eslint-plugin-react' import villv from '@vill-v/eslint-config' export default villv( { //。。。villv 内置插件的配置 }, { rules: { 'no-undef': 'off', }, }, { plugin: { react, }, } ) ``` ## 其他代码规范 [eslint config](https://gitee.com/vill-v/eslint-config) - eslint flat 风格的配置集合 [prettier config](https://gitee.com/vill-v/prettier-config) - prettier 的默认配置 [tsconfig](https://gitee.com/vill-v/tsconfig) - typescript tsconfig.json 基础配置 ## License [MIT License](./LICENSE)