我制定了我的.eslintrc规则"quote-props": [2, "always"]。当我这样做时,eslint --fix它会正常工作。
但我用 Prettier 格式化我的代码。不幸的是,Prettier 没有always办法。因此,当我使用 Prettier 进行格式化时,结果总是会删除我的 quote 属性。as-needed|preserve|consistentquote-props
我如何告诉 Prettier 尊重这条规则?添加// prettier-ignore不是一个选项。
.eslintrc:
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"prettier",
"prettier/react"
], // Prettier or Prettier Plugins (here for React) must always be at the end
"env": {
"cypress/globals": true,
"node": true,
"browser": true,
"es6": true
},
"plugins": ["react", "cypress", "prettier"],
"settings": {
"react": {
"createClass": "createClass",
// Regex for Component Factory to use, default …Run Code Online (Sandbox Code Playgroud) 包.json
"eslintConfig": { "extends": [ "react-app", "react-app/jest" ] },
很长一段时间以来,我在使用Prettier和 Vue.js时遇到了一个特殊问题。似乎没有解决方案,所以我在这里发布一个问题作为最后的手段。如果您的 HTML 代码嵌套较深并且您printWidth在 Prettier 中启用了属性(默认情况下启用),则会出现此问题。
Prettier 2.1.2 Playground 链接
--parser vue
Run Code Online (Sandbox Code Playgroud)
输入:
<template>
<div>
<div>
<div>
<div>
<div>
<ol>
<li>
<router-link class="xyz-class abc-class" to="/home">Home</router-link>
</li>
<li>
<router-link class="xyz-class abc-class" to="/posts">Posts</router-link>
</li>
</ol>
</div>
</div>
</div>
</div>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
输出:
<template>
<div>
<div>
<div>
<div>
<div>
<ol>
<li>
<router-link class="xyz-class abc-class" to="/home"
>Home</router-link
>
</li>
<li>
<router-link class="xyz-class abc-class" to="/posts"
>Posts</router-link
>
</li>
</ol>
</div>
</div>
</div>
</div>
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
预期行为:
在我看来,这些中的任何一个都很好而且更整洁。
<template>
<div>
<div>
<div> …Run Code Online (Sandbox Code Playgroud) 我正在使用nuxtjs,并且安装eslint在我的项目上,并且在使用时npm run dev,我收到了大量的错误。我怎样才能解决这个问题:

节点版本:20.11.0 pnpm 版本:8.15.0 操作系统:Windows
我按照https://prettier.io/docs/en/install.html中的说明进行操作
pnpm exec husky install命令哈士奇有问题吗?如何设置更漂亮的 git hook?
感谢帮助
每次打开 VS Code 升级后,我都会得到一个Error loading workspace folders甚至所有扩展都不起作用
go [-e -json -compiled=true -test=true -export=false -deps=true -find=false -- builtin ibm.com/cloudbroker/order/...]: exit status 1: build flag -mod=readonly only valid when using modules
: packages.Load error[![enter image description here][1]][1]
Run Code Online (Sandbox Code Playgroud)
go 版本 go1.12.17 darwin/amd64 VsCode 版本:1.52.1 操作系统:Darwin x64 20.2.0
visual-studio-code vscode-settings prettier prettier-eslint prettier-vscode
我使用 Create React Apps 的 Typescript 模板创建了一个 React 项目,为 ESLint 添加了必要的插件6.8.0并将 ESLint 和更漂亮的配置在一起,但是每当我编辑.ts或.tsx文件时,我都会收到 ESLint 错误Delete ????``
我在 VSCode 中安装了 ESLint 和 Prettier 扩展
我检查了 SO 上的其他各种帖子,并尝试了提到的大部分设置,
我将此添加到我的.eslintrc.json文件中
"prettier/prettier": [
"error",
{
"endOfLine": "auto"
},
{ "usePrettierrc": true }
],
Run Code Online (Sandbox Code Playgroud)
这是我的 .prettierrc
{
"trailingComma": "es5",
"tabWidth": 2,
"useTabs": true,
"semi": true,
"singleQuote": true,
"jsxBracketSameLine": false,
"printWidth": 80,
"endOfLine": "auto"
}
Run Code Online (Sandbox Code Playgroud)
但是每当我在 .ts/.tsx 文件中创建一个新行时,我仍然会收到一个 lint 错误
我将 VSCode 设置中的所有内容更改为使用CRLF(我在 Windows 上) …
eslint -config-prettier和eslint-plugin-prettier都是用于将ESLint与Prettier集成的流行软件包。
然而,在阅读了他们的文档后,我明白两者都可以完成这项工作。但是,如果我们使用eslint-plugin-prettier,就会出现一些使用eslint-config-prettier不会发生的问题。此外,当使用eslint-plugin-prettier推荐配置时,它将在幕后使用eslint-config-prettier 。
在我看来,eslint-config-prettier比eslint-plugin-prettier有明显的优势 ,但eslint-plugin-prettier仍然很受欢迎,并且它在npm上每周的下载量确实很多。我错过了什么?使用eslint-plugin-prettier有什么好处?