【问题标题】:Visual Studio Code - tslint - pattern matcherVisual Studio Code - tslint - 模式匹配器
【发布时间】:2015-07-23 09:09:02
【问题描述】:

我尝试为 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
                }
            }
        ]
    }
]
}

【问题讨论】:

  • 我对此也很感兴趣。我不知道 VSC 有能力做到这一点。有没有为 vsc 设置代码突出显示的人对此有所了解?
  • 0.2.0 已修正,现在可以正常使用了。在 vs code 网页上查看有关如何添加新匹配器的描述(在任务下)。您还需要了解正则表达式才能做到这一点。
  • 去过那里,做到了,但我的匹配器不匹配任何东西......也许你可以帮助我? stackoverflow.com/questions/34055354/…

标签: visual-studio-code tslint


【解决方案1】:

在 0.2.0 版本中解决。这是一个错误。

【讨论】:

    【解决方案2】:

    你不仅要懂正则表达式,还要记得为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
        }
      }
    

    【讨论】:

      猜你喜欢
      • 2019-01-09
      • 2018-07-27
      • 1970-01-01
      • 2018-01-04
      • 2018-02-24
      • 2019-05-12
      • 2021-11-11
      • 2019-03-19
      • 1970-01-01
      相关资源
      最近更新 更多