简体   繁体   中英

problemMatcher for Typescript in Webpack watch mode

I'm using fork-ts-checker-webpack-plugin , and I want to write a problem matcher that will display the set of problems returned by the compiler in real time as Webpack recompiles in the background. I've tried this problem matcher in my build task:

{
    "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
            }
        ]
    }
}

But this doesn't work.

My problem matcher is supposed to match lines like these:

 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 

Why isn't this working?

My error was that I didn't actually have two groups in the second line matcher, so it didn't work properly.

Version that works:

{
    "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
            }
        ]
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM