当我使用
next dev
(来自 next.js 库的命令)时,很高兴看到我在监视/编译/服务“循环”中运行 next lint
时收到的警告。这可能吗?
这有点 hacky,但我的解决方案是始终在
next lint
之前运行 next dev
。我在我的package.json
中添加了一个新命令,如下所示:
"scripts": {
...
"dev-lint": "next lint && next dev"
},
现在,如果
next lint
通过(没有错误,只有警告),则运行 next dev
;否则,该过程将停止,直到错误被修复。
将这些设置添加到 package.json 并运行
npm run dev:ts
。这将确保在运行应用程序时检查和检查文件。
"scripts": {
...
"dev": "next dev",
"dev:ts": "yarn dev & yarn ts:watch",
"ts": "tsc --noEmit --incremental",
"ts:watch": "yarn ts --watch",
},