Visual Studio 代码 - tslint - 模式匹配器

Visual Studio Code - tslint - pattern matcher

我试图为 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.2.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
    }
  }