| 123456789101112131415161718192021222324252627282930313233343536373839 |
- module.exports = {
- root: true,
- env: {
- node: true,
- browser: true,
- es6: true
- },
- // 扩展规则
- extends: [
- 'plugin:vue/essential', // Vue 2 核心规则
- 'eslint:recommended', // ESLint 推荐规则
- 'plugin:prettier/recommended' // 整合 Prettier,使其作为 ESLint 规则运行
- ],
- parserOptions: {
- parser: '@babel/eslint-parser', // 使用 babel 解析器支持最新的 JS 语法
- ecmaVersion: 2020,
- sourceType: 'module'
- },
- rules: {
- // 自定义规则
- 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
- 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
- // Vue 相关规则
- 'vue/multi-word-component-names': 'off', // 允许单单词组件名(如 Home.vue),方便仿制
- 'vue/no-unused-components': 'warn',
- // Prettier 冲突处理
- 'prettier/prettier': [
- 'error',
- {
- singleQuote: true, // 使用单引号
- semi: false, // 不使用分号(符合 B 站前端常见的现代风格)
- trailingComma: 'none', // 不使用尾随逗号
- printWidth: 100 // 每行最大字符数
- }
- ]
- }
- }
|