新建的react项目,安装完 prettier 后,执行 npx prettier --write . 命令报如下错误:
[warn] jsxBracketSameLine is deprecated.
[error] Invalid rangeEnd value. Expected an integer, but received "Infinity".
prettier.json 文件配置如下:
{
"singleQuote": true,
"printWidth": 80,
"printWidth": 100,
}
.prettierignore 文件配置如下:
# Ignore artifacts:
build
coverage
# Ignore all HTML files:
*.html
**/.git
**/.svn
**/.hg
**/node_modules
有哪位大神可以帮忙解答吗?
猜测,你应该是配置了额外 perttier 配置,比如在cli里,或者eslint 集成了部分,找找相关文档,比如使用的cra生产的项目,可能使用了 plugin:prettier/recommended,而这里的配置和你这次安装的 prettier 版本不一致,好多配置废弃了(比如,jsxBracketSameLine),也有存在配置项使用不对的问题,导致出现了你这个错误。