error Mixed spaces and tabs no-mixed-spaces-and-tabs

太过爱你忘了你带给我的痛 2022-09-08 13:56 439阅读 0赞

watermark_type_ZHJvaWRzYW5zZmFsbGJhY2s_shadow_50_text_Q1NETiBA5pyI55av_size_20_color_FFFFFF_t_70_g_se_x_16

"extends": "eslint:recommended"配置文件中的属性启用此规则。

大多数代码惯例要求使用制表符或空格来缩进。因此,如果单行代码与制表符和空格缩进,通常会出现错误。

此规则不允许使用混合空格和制表符进行缩进。

此规则的错误代码示例:

  1. /*eslint no-mixed-spaces-and-tabs: "error"*/
  2. function add(x, y) {
  3. // --->..return x + y;
  4. return x + y;
  5. }
  6. function main() {
  7. // --->var x = 5,
  8. // --->....y = 7;
  9. var x = 5,
  10. y = 7;
  11. }

此规则的正确代码示例:

  1. /*eslint no-mixed-spaces-and-tabs: "error"*/
  2. function add(x, y) {
  3. // --->return x + y;
  4. return x + y;
  5. }

这条规则有一个字符串选项。

  • "smart-tabs" 当后者用于对齐时允许混合空间和标签。

智能标签

此规则的正确代码示例包含以下"smart-tabs"选项:

  1. /*eslint no-mixed-spaces-and-tabs: ["error", "smart-tabs"]*/
  2. function main() {
  3. // --->var x = 5,
  4. // --->....y = 7;
  5. var x = 5,
  6. y = 7;
  7. }

代码出现问题:

添加这句:

/*eslint no-mixed-spaces-and-tabs: [“error”, “smart-tabs”]*/

  1. <template>
  2. <comp-setup>
  3. </comp-setup>
  4. </template>
  5. <script>
  6. /*eslint no-mixed-spaces-and-tabs: ["error", "smart-tabs"]*/
  7. import CompSetup from './components/setupview'
  8. export default {
  9. name: 'App',
  10. components: {
  11. CompSetup,
  12. }
  13. }
  14. </script>
  15. <style>
  16. </style>

参考地址:https://cloud.tencent.com/developer/section/1135716

发表评论

表情:
评论列表 (有 0 条评论,439人围观)

还没有评论,来说两句吧...

相关阅读