如何解决错误“更漂亮/更漂亮:在vim上设置更漂亮时删除`··`“
我创建了一个NextJs项目,我想集成Prettier ans Eslint来帮助我。 这是我的配置文件:
.prettierrc
{
"trailingComma": "es5","semi": true,"singleQuote": true,"tabWidth": 2,"endOfLine": "auto"
}
.eslintrc
{
"plugins": ["prettier"],"extends": ["prettier"],"rules": {
"prettier/prettier": "error"
},"parserOptions": {
"ecmaVersion": 7,"sourceType": "module","ecmaFeatures": {
"jsx": true,}
}
}
我还有一个.editor配置文件
# EditorConfig is awesome: http://EditorConfig.org
2
3 # top-most EditorConfig file
4 root = true
5
6 # Unix-style newlines with a newline ending every file
7 [*]
8 end_of_line = lf
9 insert_final_newline = true
10 indent_style = space
11 indent_size = 4
12 charset = utf-8
13
14 [*.{js,json}]
15 indent_size = 2
16
17 [*.sql]
18 indent_size = 8
保存文件时出现错误
prettier/prettier: Delete `··`
有人可以帮我吗?
解决方法
.prettierrc
和 .editorconfig
之间存在冲突。 ESLint 只会遵循 .prettierrc
中的内容。在您的情况下,您的文件遵循 .editorconfig
规则(覆盖 .prettierrc
中的内容),但您的 ESLint 遵循 .prettierrc
规则。
在您的 .prettierrc
中,
"tabWidth": 2
在您的 .editorconfig
中,
indent_size = 4
您可以设置 "tabWidth": 4
或删除 indent_size = 4
来解决问题(取决于您喜欢 2 还是 4)。
其实这些参数在.editorconfig
end_of_line
indent_style
indent_size/tab_width
max_line_length
将与 .prettierrc
"endOfLine"
"useTabs"
"tabWidth"
"printWidth"
您可以让 .editorconfig
遵循 .prettierrc
默认或同步 .editorconfig
和 .prettierrc
以使事情正常工作。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。