.eslintrc.js 1.09 KB
// ESLint 配置
// https://eslint.vuejs.org/user-guide/#editor-integrations
module.exports = {
  extends: ['taro/vue3'],
  rules: {
    // 自定义规则
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'vue/multi-word-component-names': 'off', // 允许单词组件名
    'prefer-const': 'warn', // 建议使用 const
    'no-var': 'error', // 禁止使用 var
    eqeqeq: ['error', 'always'], // 必须使用 ===
    curly: ['error', 'all'], // 必须使用大括号
    'brace-style': ['error', '1tbs'], // 大括号风格
    indent: ['error', 2, { SwitchCase: 1 }], // 缩进
    quotes: ['error', 'single', { avoidEscape: true }], // 单引号
    semi: ['error', 'never'], // 不使用分号
    'comma-dangle': ['error', 'never'], // 不使用尾随逗号
    'space-before-function-paren': [
      'error',
      {
        anonymous: 'always',
        named: 'never',
        asyncArrow: 'always',
      },
    ],
  },
  globals: {
    // Taro 全局变量
    wx: 'readonly',
    Taro: 'readonly',
  },
}