簡體   English   中英

我需要刪除分號錯誤 ESLint + Prettier

[英]I need remove the semicolon error ESLint + Prettier

如何刪除分號規則?

我試圖刪除半規則,但我沒有成功。 當我刪除分號后保存文件時,lint 抱怨它丟失了,當我插入它時,它再次抱怨說要刪除。

我想保留分號

在此處輸入圖像描述

那是我的 .prettierrc 文件:

{
  "printWidth": 100,
  "singleQuote": true,
  "tabWidth": 4,
  "trailingComma": "es5",
  "endOfLine":"auto",
  "semi": true
}

這就是我的 .eslintrc 文件

{
    "parser": "babel-eslint",
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        }
    },
    "env": {
        "browser": true, 
        "node": true,
        "es6": true
    },
    "extends": [
        "airbnb",
        "plugin:prettier/recommended", 
        "plugin:react/recommended",
        "plugin:jsx-a11y/recommended"
    ],
    "plugins": ["prettier", "react", "react-hooks"],
    "rules": {
        "prettier/prettier": [
            "error",
            {
              "endOfLine": "auto"
            }
        ],
        "react-hooks/exhaustive-deps": "warn",
        "react-hooks/rules-of-hooks": "error",
        "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
        "react/jsx-indent-props": [2, 4],
        "react/jsx-indent": [2, 4],
        "react/jsx-one-expression-per-line": [0],
        "react/prefer-stateless-function": [1],
        "react/static-property-placement": [1, "property assignment"],
        "react/prop-types": "off"
    }
}

我通過將 .eslintrc 中更漂亮的規則配置設置為:

"rules": {
        "prettier/prettier": [
            "error",
            {
              "endOfLine": "off"
            }
        ],

同時保留.prettierrc:

"endOfLine": "auto"

注意:這只是為了解決您(和我)遇到的錯誤,但我看到的效果是“endOfLine”規則在使用漂亮格式時有效,但在運行 eslint 時無效。

你應該用false改變 semi

{
  "printWidth": 100,
  "singleQuote": true,
  "tabWidth": 4,
  "trailingComma": "es5",
  "endOfLine":"auto",
  "semi": false
}

暫無
暫無

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

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