@qes-test/eslint-config
Version:
ESLint configuration for QES projects
100 lines (70 loc) • 2.17 kB
Markdown
# @qes-test/eslint-config
一个基于 ESLint 的代码规范配置包,提供了完整的 TypeScript、Vue.js 和 Prettier 集成配置。
## 安装
```bash
npm install --save-dev @qes-test/eslint-config
```
## 使用方法
### 基本配置
在你的项目中创建 `eslint.config.mjs` 文件:
```javascript
import { defineConfig } from '@qes-test/eslint-config'
export default defineConfig([
{
// 你的自定义规则覆盖
rules: {
// 在这里添加或覆盖规则
}
}
])
```
### 与现有项目集成
如果你已经有 ESLint 配置,可以这样集成:
```javascript
import { defineConfig } from '@qes-test/eslint-config'
export default defineConfig([
// 使用基础配置
...(await defineConfig()),
{
// 项目特定的规则覆盖
rules: {
'vue/no-unused-vars': 'warn',
'@typescript-eslint/no-explicit-any': 'off'
}
}
])
```
## 特性
- ✅ **TypeScript 支持** - 完整的 TypeScript 语法检查和类型检查
- ✅ **Vue.js 支持** - Vue 3 组件规范和最佳实践
- ✅ **Prettier 集成** - 自动代码格式化
- ✅ **导入排序** - 自动排序 import 语句
- ✅ **代码质量** - 检测潜在的错误和代码质量问题
- ✅ **可扩展** - 易于自定义和扩展
## 包含的插件
- `@typescript-eslint/eslint-plugin` - TypeScript 语法检查
- `@typescript-eslint/parser` - TypeScript 解析器
- `eslint-plugin-vue` - Vue.js 组件规范
- `eslint-plugin-prettier` - Prettier 集成
- `eslint-config-prettier` - 禁用与 Prettier 冲突的规则
- `eslint-plugin-perfectionist` - 代码排序和格式化
- `eslint-plugin-command` - 注释命令支持
## 要求
- Node.js >= 16
- ESLint >= 8.0.0
- TypeScript >= 4.0.0 (如果使用 TypeScript)
## 配置说明
### TypeScript 配置
包包含了完整的 TypeScript 支持,包括:
- 类型检查 (`@typescript-eslint/typedef`)
- 严格的类型规则
- 导入/导出类型检查
### Vue.js 配置
针对 Vue 3 的优化配置:
- 组件结构规范
- 模板语法检查
- 组合式 API 支持
### Prettier 集成
自动格式化配置,确保代码风格一致。
## 许可证
MIT