插入`··` 更漂亮/更漂亮 [英] Insert `··` prettier/prettier

查看:54
本文介绍了插入`··` 更漂亮/更漂亮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个安装了 prettier 和 eslint 的项目.问题是当我保存文件时,eslint 会自动更改文件的格式,并且似乎有些规则与 prettier 冲突.有什么解决办法?

I have a project that has both prettier and eslint installed. The problem is that when I save a file eslint automatically changes the format of the file and it seems some rules conflict with prettier. What is the solution?

这是更漂亮的格式:

保存后,文件变为:

这也是eslintrc文件

Also this is eslintrc file

{
  "parser": "@typescript-eslint/parser",
  "extends": [
    "plugin:react/recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:prettier/recommended",
    "prettier/@typescript-eslint"
  ],
  "rules": {
    "@typescript-eslint/explicit-function-return-type": "off",
    "@typescript-eslint/no-explicit-any": "off",
    "@typescript-eslint/ban-ts-ignore": "off",
    "@typescript-eslint/interface-name-prefix": "off",
    "@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }]
  },
  "overrides": [
    {
      "files": ["**/*.tsx"],
      "rules": {
        "react/prop-types": "off"
      }
    }
  ],
  "settings": {
    "react": {
      "version": "detect"
    }
  },
  "ignorePatterns": ["coverage/", "node_modules/", "src/serviceWorker.ts"]
}

推荐答案

未完全配置 ESlint 和 Prettier 会导致无数问题.为了避免所有这些,请按照如何在 VSCode 中使用带有 ESLint 和 TypeScript 的 Prettier ,还要删除 ESlint、Prettier 和 setting.json 的 VScod 配置文件中可能覆盖其他规则的任何额外设置.

Not fully configuring ESlint and Prettier can cause a myriad of issues. To avoid all of them follow the steps mentioned in How to use Prettier with ESLint and TypeScript in VSCode , also remove any extra setting in config files for ESlint, Prettier and setting.json for VScod that might override other rules.

重要提示:根据此处的答案:卸载 prettier-eslint 扩展.

Important: Based on the answer here: Uninstall prettier-eslint extension.

这篇关于插入`··` 更漂亮/更漂亮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆