vue error Expected indentation of 2 spaces but found 4 indent

发布于:2025-02-16 ⋅ 阅读:(136) ⋅ 点赞:(0)

问题的原因在于eslint的风格样式缩进检测,eslint给出的规则是2个缩进,但我们通常是4个缩进,这就造成了报错。

关闭eslint的缩进不同报错:.eslintrc.js

'indent':'off',

全部配置:

module.exports = {
  root: true,
  parserOptions: {
    parser: '@babel/eslint-parser',
    sourceType: 'module',
    ecmaVersion: 2021,
    requireConfigFile: false
  },
  env: {
    browser: true,
    node: true,
    es6: true
  },
  extends: ['plugin:vue/vue3-recommended', 'eslint:recommended'],
  rules: {
    'vue/require-prop-types':'off',
    'vue/multi-word-component-names': 'off',
    'no-unused-vars': 'warn',
    'vue/no-v-html': 'off',
    'vue/require-default-prop': 'off',
    'vue/require-explicit-emits': 'off',
    'vue/html-self-closing': 'off',
    'vue/singleline-html-element-content-newline': 'off',
    'vue/multiline-html-element-content-newline': 'off',
    'vue/html-closing-bracket-newline': ['error', {
      'singleline': 'never',
      'multiline': 'always'
    }],
    'vue/html-indent': ['error', 2, {
      'attribute': 1,
      'baseIndent': 1,
      'closeBracket': 0,
      'alignAttributesVertically': true,
      'ignores': []
    }],
    'max-len': ['error', {
      'code': 145,
      'ignoreUrls': true,
      'ignoreStrings': true,
      'ignoreTemplateLiterals': true,
      'ignoreRegExpLiterals': true,
      'ignoreComments': true
    }],
    // 'indent': ['error', 2, {
    //   'SwitchCase': 1,
    //   'VariableDeclarator': 1,
    //   'outerIIFEBody': 1,
    //   'MemberExpression': 1,
    //   'FunctionDeclaration': { 'parameters': 1, 'body': 1 },
    //   'FunctionExpression': { 'parameters': 1, 'body': 1 },
    //   'CallExpression': { 'arguments': 1 },
    //   'ArrayExpression': 1,
    //   'ObjectExpression': 1,
    //   'ImportDeclaration': 1,
    //   'flatTernaryExpressions': false,
    //   'ignoreComments': false
    // }],
    'indent':'off',
    // 'semi': ['error', 'never'],
    // 'no-extra-semi': 'error',
    'comma-dangle': ['error', 'never'],
    'no-debugger': 'off',
    'vue/no-v-model-argument': 'off',
    
    "prettier/prettier": "off",
    "vue/html-closing-bracket-newline":'off',
    "vue/max-attributes-per-line":'off',
    "vue/html-indent":'off',
    'vue/v-on-event-hyphenation': 'off',
    'vue/first-attribute-linebreak': ['error',{
        singleline: 'ignore',
        multiline: 'ignore',
      },
    ],
    "vue/attributes-order":'off',
    "no-unused-vars":"off",
    // "vue/no-deprecated-v-on-native-modifier":"off",
    "no-dupe-keys":"off",
    "vue/no-deprecated-slot-attribute":"off",
    "comma-dangle":"off"
  }
}


网站公告

今日签到

点亮在社区的每一天
去签到