当我正常使用npm start运行我的应用程序时,它工作得很好。但是,当我尝试使用npm run build.I创建一个生成目录和我的应用程序的产品生成时,会得到一个警告,即我应该有一个空格,缩进看起来通常是设置的:
错误
[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-locationeslintrc.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}]
},
],
},
};我尝试过的。
在option
npm run lint -- --fix
中使用“react/jsx缩进”配置缩进设置的
发布于 2022-11-23 13:50:57
最后,通过使用更漂亮的格式来格式化app.js文件中的代码来修复它。因为我安装得更漂亮,所以我只使用了CTRL + SHIFT + P,然后搜索了format document
https://stackoverflow.com/questions/74547690
复制相似问题