quanyawei
2024-11-15 f752f50a484f63fc3786ab1c7ad563f3b17cce77
.eslintrc.js
@@ -1,59 +1,43 @@
module.exports = {
  root: true,
  parserOptions: {
    parser: 'babel-eslint',
    sourceType: 'module'
  },
  env: {
    browser: true,
    node: true,
    es6: true,
    es2021: true
  },
  extends: ['plugin:vue/recommended', 'eslint:recommended'],
  // add your custom rules here
  //it is base on https://github.com/vuejs/eslint-config-vue
  rules: {
    'eqeqeq': ['error', 'always'], // 强制使用三个等于号
    'semi': 0, // 语句可以不需要分号结尾
    'no-use-before-define': [1, 'nofunc'], // 未定义前不能使用
    'max-lines': ['error', { 'max': 2000, 'skipBlankLines': true }],
    'no-mixed-spaces-and-tabs': 'warn', // 禁止使用空格和tab混合缩进
    'newline-per-chained-call': ['error', { ignoreChainWithDepth: 1 }], // promise 以及 数组的链式操作需要另起一行
    'vue/attribute-hyphenation': ['error', 'always'], // prop变量使用破折号,而不是驼峰。这里做统一,不然以后全局修改prop有可能碰到要修改不全的情况
    'vue/html-indent': [
      'warn',
      2,
      {
        attribute: 1,
        baseIndent: 1,
        closeBracket: 0,
        alignAttributesVertically: true
  extends: ['standard', 'plugin:vue/recommended'],
  overrides: [
    {
      env: {
        node: true
      },
      files: ['.eslintrc.{js,cjs}'],
      parserOptions: {
        sourceType: 'script'
      }
    ],
    'curly': 2, // 必须使用 if(){} 中的{}
    'vue/prop-name-casing': ['warn', 'camelCase'], //建议使用驼峰命名
    'vue/this-in-template': ['error', 'never'], //不允许在template里面使用this
    'no-trailing-spaces': 1, //一行结束后面不要有空格
    'vue/max-attributes-per-line': [ // template里面写的一行多少个prop属性,单行3个,多余3个的必须每行写一个prop,不然不容易看
      'warn',
      {
        singleline: 3,
        multiline: {
          max: 1,
          allowFirstLine: false
        }
      }
    ],
    'no-catch-shadow': 'error', //禁止catch子句参数与外部作用域变量同名
    'vue/v-bind-style': ['error', 'shorthand'], // 必须使用:来绑定
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', // 只允许在开发环境中使用debugger
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-unused-vars': 0, // 禁止出现未使用过的变量
    'spaced-comment': 0 // 强制在注释中 // 或 /* 使用一致的空格
    }
  ],
  parserOptions: {
    ecmaVersion: 2021,
    sourceType: 'module',
    parser: 'babel-eslint',
    ecmaFeatures: {
      // 非 react 项目关闭 jsx 语法校验,默认为 true
      jsx: false
    }
  },
  globals: {
    'AMap': false,
    'AMapUI': false
    AMap: true,
    AMapUI: true
  },
  plugins: ['vue'],
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    camelcase: 'off',
    'comma-dangle': 'off',
    '@typescript-eslint/no-explicit-any': 'off',
    '@typescript-eslint/camelcase': 'off',
    '@typescript-eslint/no-empty-function': 'off',
    'lines-between-class-members': 'off',
    '@typescript-eslint/no-this-alias': 'off'
  }
}