首页 > 解决方案 > Prettier/VSCode 打破了语法

问题描述

我正在尝试用更漂亮的格式格式化 js 文件,似乎更漂亮正在破坏代码语法。我想实现这一点(预期结果),但出现红线。在保存时,我得到以下结果。运行代码时出现以下错误TypeError: {} is not a function错误图像)。我尝试了以下方法,但在我的情况下似乎都没有。

  1. 为什么我不断收到 Delete 'cr' [prettier/prettier]?
  2. Visual Studio Code [eslint] 在 Windows 上删除 'CR' [prettier/prettier]

我正在使用以下 .prettierrc.js

module.exports = {
  tabWidth: 2,
  bracketSpacing: true,
  endOfLine: "auto",
  jsxBracketSameLine: true,
  printWidth: 100,
  semi: false,
  singleQuote: false,
  trailingComma: "none"
}

在我的 .eslintrc.json 文件中,我为更漂亮设置了以下规则

"prettier/prettier": [
      "error",
      {
        "bracketSpacing": true,
        "endOfLine": "auto",
        "jsxBracketSameLine": true,
        "printWidth": 100,
        "semi": false,
        "singleQuote": false,
        "trailingComma": "none"
      }
    ],

我尝试将 LF 更改为 CRLF,反之亦然,出现在 vscode 的底部,但没有成功。我还缺少什么?

标签: prettierprettier-eslint

解决方案


推荐阅读