问题
我正在尝试用vercel部署我的git存储库。但是我的部署总是失败的,因为我用于测试的文件中存在林特错误。
,Vercel博士说:
默认情况下,Next.js将对页面/、components/、lib/和src/目录中的所有文件运行ESLint。Vercel Docs Link
因此,我将我的_tests文件夹从我的components文件夹中移出,这有助于本地下一个linter运行npm run lint,现在运行时没有任何错误,如果我正确的话,这应该反映Vercel部署构建的linter。
我的lint设置如下:
{
"extends": "next/core-web-vitals"
}但是,当推送到主分支并部署到vercel时,linter在_test文件夹中的文件上仍然存在错误。
文件夹结构
_tests // Here I moved my components and tests I don't want to have errors with as they're unfinished or only tests
.next
components
lib
node_modules
pages
....lint进程本地和Vercel不应该是相同的吗?如果不是,我如何在本地测试,就像在部署构建步骤中一样?我遗漏了什么?我已经查过所有关于埃林特的文件了。
发布于 2022-12-02 14:07:12
首先,我建议您不要在测试中忽略问题,因为测试是应用程序的一部分。因此,理想的世界解决方案是解决所有这些问题,并感到高兴。
但是,如果您仍然希望将某些代码从链接中排除出来,则可以使用ESLint ignorePatterns。配置.eslintrc.json可能如下所示:
{
"extends": "next/core-web-vitals",
"ignorePatterns": [
"_test/**"
]
}或者可以编写具有以下内容的.eslintignore文件:
_test/另一个可能的解决方案是在关掉林特中使用next build命令(默认情况下,维塞尔这个命令用于构建您的应用程序)。为此,您需要将此添加到您的next.config.js中。
const nextConfig = {
...
eslint: {
ignoreDuringBuilds: false,
},
};https://stackoverflow.com/questions/73963527
复制相似问题