在.prettierrc文件中尾随逗号规则
我有一个 next。 eslint 。我想通过将其值设置为“ TrailingComma”
.prettierrc
文件包含以下内容:
// ".prettierrc"
{
"trailingComma": "all"
}
我正在使用 .eslintrc.json
文件以配置ESLINT,我已经配置了它以应用一对夫妇插件,并扩展插件的几个规则集。
This is an image of my file:
{
"next",
"next/core-web-vitals",
"prettier",
"eslint:recommended",
"plugin:jsx-a11y/recommended",
"plugin:prettier/recommended",
"plugin:typescript-eslint/recommended",
}
"comma-dangle": "off",
规则被证明会影响TrailComma规则,如错误消息中所述:
"prettier/prettier": ["error", {}, { "usePrettierrc": true }],
Prettier在我保存时似乎执行了,并且逗号添加到列表的末尾,但是我得到了以下错误消息(如图所示)。
我尝试将“ endofline”选项添加到.prettierrc
和.eslintrc.json
rule “ Prettier/Prettier” ,有人说它可以解决该问题,但没有解决问题。
如何防止尾逗号在编辑器中显示错误?
I have a Next.js project that is configured to use Prettier & ESLint. I want to enable the Prettier rule "trailingComma"
by setting its value to "all"
, such that the .prettierrc
file contains the following:
// ".prettierrc"
{
"trailingComma": "all"
}
I am using an .eslintrc.json
file to configure ESLint, and I have it configured to apply a couple of plug-ins, and to extend a couple of the plug-in's rule-sets.
This is an image of my file:
{
"next",
"next/core-web-vitals",
"prettier",
"eslint:recommended",
"plugin:jsx-a11y/recommended",
"plugin:prettier/recommended",
"plugin:typescript-eslint/recommended",
}
The following ESLint rule is the rule ESLint uses to configure commas:
"comma-dangle": "off",
This rule is shown to affect the trailingComma rule, as it is mentioned in the error message:
"prettier/prettier": ["error", {}, { "usePrettierrc": true }],
Prettier seems to execute when I save, and the commas are added to the end of the list, but then I get the following error message (shown in the image).
I tried adding the "endOfLine" option both to .prettierrc
and .eslintrc.json
rule "prettier/prettier"
, someone said that it would fix the issue, but it didn't fix it.
How can I keep the trailing commas from displaying errors in the editor?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论