簡體   English   中英

如何在 reactjs 項目中禁用更漂亮的錯誤以及 no-unsued-vars 錯誤

[英]How to disable prettier errors in reactjs project and also no-unsued-vars error

當我嘗試運行 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 ,它會eslint --fix解決這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM