@qiaer/eslint-config-vue2
@qiaer/eslint-config-vue2
面向 Vue 2 的 ESLint 可共享配置,继承 @qiaer/eslint-config,并启用 Vue 2 推荐规则。
特性
- 继承
@qiaer/eslint-config(Standard Style + ESLint 8) - 使用 vue-eslint-parser 解析
.vue单文件组件 - 启用 plugin:vue/recommended 推荐规则
- 针对
*.ts/*.vue关闭no-undef,测试目录放宽no-console - 自定义
vue/html-self-closing配置
安装
npm
npm install @qiaer/eslint-config-vue2 --save-dev
yarn
yarn add @qiaer/eslint-config-vue2 --dev
pnpm
pnpm add @qiaer/eslint-config-vue2 --save-dev
使用
在项目根目录的 .eslintrc.js、.eslintrc.json 或 .eslintrc 中扩展本配置。
.eslintrc.js
module.exports = {
extends: ['@qiaer/eslint-config-vue2'],
}
.eslintrc.json
{
"extends": "@qiaer/eslint-config-vue2"
}
覆盖规则
module.exports = {
extends: ['@qiaer/eslint-config-vue2'],
rules: {
'vue/multi-word-component-names': 'off',
},
}
主要规则
- vue/html-self-closing:void / 组件标签自闭合,普通 HTML 不自闭合;svg/math 任意。
- no-undef:在
*.ts、*.vue中关闭(由 TypeScript/编译器处理)。 - no-console:在
**/__tests__/**、**/gulpfile.ts中关闭。
命令行
npx eslint . --ext .js,.vue
npx eslint . --ext .js,.vue --fix
更新日志
v1.0.0-beta.0
- 依赖
@qiaer/eslint-config升级为 ^1.0.0-beta.0 - 升级 eslint-plugin-vue 至 ^9.22.0,新增 vue-eslint-parser ^9.4.3
- 移除 eslint-define-config,配置改为直接
module.exports - 增加 exports、files、engines,统一脚本为
--config=index.js - 完善 README(npm/yarn/pnpm、使用方式、规则说明)
说明:当前使用 file:../eslint-config 链接本地包,便于 Lerna 开发。发布前需将依赖改回版本号(如 ^1.0.0-beta.0)再执行 lerna publish,否则发布后的包无法正确安装。
许可证
MIT
Related Packages
Version History
| Version | Released | License |
|---|---|---|
| 0.1.3 | ISC |