我试图为tslint实现模式匹配器,但它会变得混乱。我确定正确指定了正则表达式,但VSC一直在突出显示不正确的文件。这是我的tasks.json文件:
{
"version": "0.1.0",
"command": "gulp",
"isShellCommand": true,
"args": [
],
"tasks": [
{
"taskName": "build",
"args": [],
"isBuildCommand": true,
"problemMatcher": [
{
"owner": "gulp",
"fileLocation": ["absolute"],
"pattern": {
"regexp": "^\\[[^>]* > ([^(]*)\\((\\d*),(\\d*)\\): (error) (.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
},
{
"owner": "gulp",
"fileLocation": ["relative", "${workspaceRoot}/src/"],
"pattern": {
"regexp": "^\\([a-z\\-]*\\) ([^\\[]*)\\[([\\d]*), ([\\d]*)\\]: (.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 1,
"message": 4
}
}
]
}
]
}
答案 0 :(得分:0)
在0.2.0版中解决。这是一个错误。
答案 1 :(得分:0)
你不仅需要理解正则表达式,而且还必须记得为json转义!
要从tslint
而不是gulp版本的直接输出中获得此功能,我必须使用:
^(.*\.ts)\[(\d+), (\d+)\]: (.*)$
在json中,这变为:
"problemMatcher": {
"owner": "tslint",
"fileLocation": [
"absolute"
],
"severity": "warning",
"pattern": {
"regexp": "^(.*\\.ts)\\[(\\d+), (\\d+)\\]: (.*)$",
"file": 1,
"line": 2,
"column": 3,
"message": 4
}
}