1、“Expected indentation of 6 spaces but found 12”错误

运行Vue项目时如果发生Eslint语法检查报错,输出报错内容举例:

Expected indentation of 6 spaces but found 12,可能会是一堆,让人很头疼,如下图所示:

2、这个问题的解决办法:

Vue项目文件夹里找到“.eslintrc.js”文件并打开,其内容可能如下所示:

module.exports = {

  root: true,

  env: {

    node: true

  },

  extends: [

    'plugin:vue/vue3-essential',

    '@vue/standard'

  ],

  parserOptions: {

    parser: '@babel/eslint-parser'

  },

  rules: {

    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',

    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'

  }

}

在其“rules”内增加新规则,首先在图上的输出报错信息的右侧灰色的部分会看见所有的命令,indentcomma-dangleno-trailing-spaceseol-last,将这些分别增加到 rules”内,并设置为0,修改后的文件内容如下:

module.exports = {

  root: true,

  env: {

    node: true

  },

  extends: [

    'plugin:vue/vue3-essential',

    '@vue/standard'

  ],

  parserOptions: {

    parser: '@babel/eslint-parser'

  },

  rules: {

    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',

    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',

    'indent':0,

    'comma-dangle':0,

    'no-trailing-spaces':0,

    'eol-last':0

  }

}

修改后,保存,并且重新运行项目,问题应该就是解决了。

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐