【问题标题】:I need remove the semicolon error ESLint + Prettier我需要删除分号错误 ESLint + Prettier
【发布时间】:2022-07-06 17:11:29
【问题描述】:

如何删除分号规则?

我尝试删除半规则,但没有成功。当我删除分号后保存文件时,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"
    }
}

【问题讨论】:

标签: javascript eslint prettier eslint-config-airbnb


【解决方案1】:

我通过将 .eslintrc 中更漂亮的规则配置设置为:

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

同时保留在 .prettierrc 中:

"endOfLine": "auto"

【讨论】:

    【解决方案2】:

    你应该用false更改semi

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

    【讨论】:

      猜你喜欢
      • 2021-05-06
      • 2019-12-12
      • 2019-12-24
      • 2021-09-14
      • 2018-09-18
      • 2021-10-05
      • 2017-11-25
      • 2018-07-25
      • 2020-06-06
      相关资源
      最近更新 更多