[英]Line 31:9: Expected indentation of 10 space characters but found 8 react/jsx-indent
當我使用npm start
正常運行我的應用程序時,它工作正常。 但是當我嘗試使用npm run build
創建一個包含我的應用程序生產版本的構建目錄時。我收到一條警告,我應該有空格,縮進似乎通常設置:
錯誤
[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
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}]
},
],
},
};
我試過什么。
npm run lint -- --fix
最后通過使用 Prettier 格式化app.js
文件中的代碼來修復它。 因為我安裝了 prettier 我只是使用CTRL + SHIFT + P
然后搜索format document
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.