我正在使用应用程序路由器使用Next.js 13构建一个应用程序,但我遇到了格式化错误。下面是代码片段:
但是,在使用Prettier/ESLint保存文件后,格式将变得不正确:
问题在于Prettier/ESLint错误地格式化了“useClient”部分。
我的.prettierc文件:
{
"editorconfig": true,
"semi": false,
"trailingComma": "es5",
"singleQuote": true,
"arrowParens": "always"
}
我的.editorconfig文件:
root = true
[*]
indent_style = tab
indent_size = 3
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false
我的eslintrc:
{
"extends": ["next/core-web-vitals", "prettier"]
}
我的包.json:
{
"name": "tv-calendar",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@prisma/client": "4.15.0",
"@types/bcrypt": "^5.0.0",
"axios": "^1.4.0",
"bcrypt": "^5.1.0",
"jsonwebtoken": "^9.0.0",
"next": "13.4.4",
"react": "18.2.0",
"react-dom": "18.2.0",
"zod": "^3.21.4"
},
"devDependencies": {
"@types/jsonwebtoken": "^9.0.2",
"@types/node": "20.2.5",
"@types/react": "18.2.9",
"@types/react-dom": "18.2.4",
"autoprefixer": "10.4.14",
"eslint": "8.42.0",
"eslint-config-next": "13.4.4",
"eslint-config-prettier": "^8.8.0",
"postcss": "8.4.24",
"prisma": "^4.15.0",
"tailwindcss": "3.3.2",
"typescript": "5.1.3"
}
}
我对.prettierc文件做了一些修改,比如删除了“arrowParens”配置,但不幸的是,它没有产生预期的效果。
1条答案
按热度按时间wtzytmuj1#
只需将“使用客户端”移到文件顶部即可。通过这样做,您可以确保Prettier/ESLint导致的格式问题得到解决。