我正在使用fork-ts-checker-webpack-plugin
,我想编写一个问题匹配器,它会在Webpack在后台重新编译时实时显示编译器返回的问题集。我在构建任务中尝试过这个问题匹配器:
{
"type": "shell",
"command": "webpack -w --config webpack.dev.js",
"label": "Webpack (Dev, Continuous)",
"group": "build",
"promptOnClose": true,
"isBackground": true,
"problemMatcher": {
"owner": "webpack",
"severity": "error",
"fileLocation": "absolute",
"source": "webpack typescript",
"background": {
"activeOnStart": true
},
"pattern": [
{
"regexp": "ERROR in (.*?)\\((\\d+),(\\d+)\\)",
"file": 1,
"line": 2,
"column": 3
},
{
"regexp": "[A-Za-z0-9-]+:(.*)",
"message": 2,
"code": 1
}
]
}
}
但这不起作用。
我的问题匹配器应该匹配这些行:
ERROR in I:/component/page/admin/reports/checkouts.vue(44,9): no-floating-promises: Promises must be handled appropriately ERROR in I:/component/page/admin/reports/fines.vue(66,9): no-floating-promises: Promises must be handled appropriately ERROR in I:/component/page/admin/users/user.vue(220,9): no-floating-promises: Promises must be handled appropriately ERROR in I:/component/page/admin/users/user.vue(232,9): no-floating-promises: Promises must be handled appropriately ERROR in I:/component/page/admin/users/user.vue(240,9): no-floating-promises: Promises must be handled appropriately ERROR in I:/component/page/admin/users/users.vue(40,9): no-floating-promises: Promises must be handled appropriately
为什么这不起作用?
答案 0 :(得分:0)
我的错误是我在第二行匹配器中实际上没有两个组,因此它无法正常工作。
有效的版本:
{
"type": "shell",
"command": "webpack -w --config webpack.dev.js",
"label": "Webpack (Dev, Continuous)",
"group": "build",
"promptOnClose": true,
"isBackground": true,
"problemMatcher": {
"owner": "Webpack (Dev, Continuous)",
"severity": "error",
"fileLocation": "absolute",
"source": "webpack-typescript",
"background": {
"activeOnStart": true,
"beginsPattern": "Type checking and linting in progress...",
"endsPattern": "Time: (\\d+)ms"
},
"pattern": [
{
"regexp": "ERROR in ([^\\(]*)\\((\\d+),(\\d+)\\):",
"file": 1,
"line": 2,
"column": 3
},
{
"regexp": "([A-Za-z0-9-]+):(.*)",
"message": 2,
"code": 1
}
]
}
}