首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >第31:9行:预期10个空格字符的缩进,但发现8个react/jsx缩进

第31:9行:预期10个空格字符的缩进,但发现8个react/jsx缩进
EN

Stack Overflow用户
提问于 2022-11-23 13:37:33
回答 1查看 14关注 0票数 0

当我正常使用npm start运行我的应用程序时,它工作得很好。但是,当我尝试使用npm run build.I创建一个生成目录和我的应用程序的产品生成时,会得到一个警告,即我应该有一个空格,缩进看起来通常是设置的:

错误

代码语言:javascript
复制
[eslint] 
src/App.js
  Line 9:2:    Expected indentation of 2 space characters but found 1    react/jsx-indent
  Line 10:2:   Expected indentation of 3 space characters but found 1    react/jsx-indent
  Line 11:9:   Expected indentation of 3 space characters but found 8    react/jsx-indent
  Line 12:9:   Expected indentation of 10 space characters but found 8   react/jsx-indent
  Line 14:9:   Expected indentation of 3 space characters but found 8    react/jsx-indent
  Line 15:9:   Expected indentation of 10 space characters but found 8   react/jsx-indent
  Line 25:9:   Expected indentation of 10 space characters but found 8   react/jsx-indent
  Line 27:11:  Expected indentation of 12 space characters but found 10  react/jsx-indent
  Line 29:25:  Expected indentation of 12 space characters but found 10  react/jsx-indent
  Line 31:9:   Expected indentation of 10 space characters but found 8   react/jsx-indent
  Line 31:9:   Expected closing tag to match indentation of opening      react/jsx-closing-tag-location

eslintrc.js

代码语言:javascript
复制
module.exports = {
  env: {
    browser: true,
    es6: true,
  },
  extends: [
    'plugin:react/recommended',
    'airbnb',
  ],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly',
  },
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    ecmaVersion: 2018,
    sourceType: 'module',
  },
  parser: 'babel-eslint',
  plugins: [
    'react',
  ],
  rules: {
    indent: 'off',
    "react/jsx-indent": [2, 2] ,
    'template-curly-spacing': 'off',
    'import/extensions': 0,
    'react/prop-types': 0,
    'linebreak-style': 0,
    'react/state-in-constructor': 0,
    'import/prefer-default-export': 0,
    'max-len': [
      2,
      250,
    ],
    'no-multiple-empty-lines': [
      'error',
      {
        max: 1,
        maxEOF: 1,
      },
    ],
    'no-underscore-dangle': [
      'error',
      {
        allow: [
          '_d',
          '_dh',
          '_h',
          '_id',
          '_m',
          '_n',
          '_t',
          '_text',
        ],
      },
    ],
    'object-curly-newline': 0,
    'react/jsx-filename-extension': 0,
    'react/jsx-one-expression-per-line': 0,
    'jsx-a11y/click-events-have-key-events': 0,
    'jsx-a11y/alt-text': 0,
    'jsx-a11y/no-autofocus': 0,
    'jsx-a11y/no-static-element-interactions': 0,
    'react/no-array-index-key': 0,
    'jsx-a11y/anchor-is-valid': [
      'error',
      {
        components: [
          'Link',
        ],
        specialLink: [
          'to',
          'hrefLeft',
          'hrefRight',
        ],
        aspects: [
          'noHref',
          'invalidHref',
          'preferButton',
        ],
        "import/no-extraneous-dependencies": ["error", {"devDependencies": true}]
      },
    ],
  },
};

我尝试过的。

在option

  • npm run lint -- --fix

  • disabling lint

  • Changing

中使用“react/jsx缩进”配置缩进设置的

EN

回答 1

Stack Overflow用户

发布于 2022-11-23 13:50:57

最后,通过使用更漂亮的格式来格式化app.js文件中的代码来修复它。因为我安装得更漂亮,所以我只使用了CTRL + SHIFT + P,然后搜索了format document

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74547690

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档