gpt4 book ai didi

reactjs - 如何在 React js 项目中禁用更漂亮的错误以及 no-unused-vars 错误

转载 作者:行者123 更新时间:2023-12-05 09:31:49 24 4
gpt4 key购买 nike

当我尝试运行 reactjs 项目时,我不断收到这些错误

prettier/prettier
Line 23:39: Replace `'react-toastify'` with `"react-toastify"` prettier/prettier
Line 29:59: Delete `⏎` prettier/prettier

下面是我的.eslintrc.js

module.exports = {
parser: "babel-eslint",
env: {
es6: true,
node: true,
browser: true,
},
parserOptions: {
ecmaVersion: 6,
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
plugins: ["react"],
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:prettier/recommended",
]
};

下面是package.json

{
"name": "material-dashboard-react",
"version": "1.10.0",
"description": "Material Dashboard React. Coded by Creative Tim",
"private": false,
"main": "dist/index.js",
"dependencies": {
"@material-ui/core": "4.11.4",
"@material-ui/icons": "4.11.2",
"axios": "^0.21.1",
"chartist": "0.10.1",
"classnames": "2.3.1",
"history": "5.0.0",
"perfect-scrollbar": "1.5.1",
"prop-types": "15.7.2",
"react": "17.0.2",
"react-chartist": "0.14.4",
"react-dom": "17.0.2",
"react-router-dom": "5.2.0",
"react-scripts": "4.0.3",
"react-swipeable-views": "0.14.0",
"react-toastify": "^7.0.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && npm start",
"lint:check": "eslint . --ext=js,jsx; exit 0",
"lint:fix": "eslint . --ext=js,jsx --fix; exit 0",
"build-package-css": "cp src/assets/css/material-dashboard-react.css dist/material-dashboard-react.css",
"build-package": "npm run build-package-css && babel src --out-dir dist"
},
"repository": {
"type": "git",
"url": "git+https://github.com/creativetimofficial/material-dashboard-react.git"
},
"keywords": [],
"author": "Creative Tim <hello@creative-tim.com> (https://www.creative-tim.com/)",
"license": "MIT",
"bugs": {
"url": "https://github.com/creativetimofficial/material-dashboard-react/issues"
},
"homepage": "https://creativetimofficial.github.io/material-dashboard-react/#/dashboard",
"optionalDependencies": {
"@babel/core": "7.14.0",
"typescript": "4.2.4"
},
"devDependencies": {
"eslint-config-prettier": "8.3.0",
"eslint-plugin-prettier": "3.4.0",
"gulp": "4.0.2",
"gulp-append-prepend": "1.0.9",
"prettier": "2.2.1"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": []
}
}

最佳答案

如果你不想在你的 eslint 输出中出现 prettier 错误,只需删除它

"plugin:prettier/recommended",

Eslint 配置中的行。

但是,最好遵循这些建议——根据您的 IDE,您可以告诉它为您运行 eslint --fix,这将立即解决问题.

关于reactjs - 如何在 React js 项目中禁用更漂亮的错误以及 no-unused-vars 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68574204/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com