You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/problem-matchers.md
+14-4Lines changed: 14 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,17 @@
1
1
# Problem Matchers
2
+
2
3
Problem Matchers are a way to scan the output of actions for a specified regex pattern and surface that information prominently in the UI. Both [GitHub Annotations](https://developer.github.com/v3/checks/runs/#annotations-object-1) and log file decorations are created when a match is detected.
3
4
4
5
## Single Line Matchers
5
6
6
7
Let's consider the ESLint compact output:
8
+
7
9
```
8
10
badFile.js: line 50, col 11, Error - 'myVar' is defined but never used. (no-unused-vars)
9
11
```
12
+
10
13
We can define a problem matcher in json that detects input in that format:
14
+
11
15
```json
12
16
{
13
17
"problemMatcher": [
@@ -33,31 +37,34 @@ The following fields are available for problem matchers:
33
37
34
38
```
35
39
{
36
-
owner: An ID field that can be used to remove or replace the problem matcher. **required**
40
+
owner: an ID field that can be used to remove or replace the problem matcher. **required**
41
+
severity: indicates the default severity, either 'warning' or 'error' case-insensitive. Defaults to 'error'
37
42
pattern: [
38
43
{
39
-
regexp: The regex pattern that provides the groups to match against **required**
44
+
regexp: the regex pattern that provides the groups to match against **required**
40
45
file: a group number containing the file name
46
+
fromPath: a group number containing a filepath used to root the file (e.g. a project file)
41
47
line: a group number containing the line number
42
48
column: a group number containing the column information
43
49
severity: a group number containing either 'warning' or 'error' case-insensitive. Defaults to `error`
44
50
code: a group number containing the error code
45
51
message: a group number containing the error message. **required** at least one pattern must set the message
46
-
loop: loops until a match is not found, only valid on the last pattern of a multipattern matcher
52
+
loop: whether to loop until a match is not found, only valid on the last pattern of a multipattern matcher
47
53
}
48
54
]
49
55
}
50
56
```
51
57
52
-
53
58
## Multiline Matching
54
59
Consider the following output:
60
+
55
61
```
56
62
test.js
57
63
1:0 error Missing "use strict" statement strict
58
64
5:10 error 'addOne' is defined but never used no-unused-vars
59
65
✖ 2 problems (2 errors, 0 warnings)
60
66
```
67
+
61
68
The file name is printed once, yet multiple error lines are printed. The `loop` keyword provides a way to discover multiple errors in outputs.
62
69
63
70
The eslint-stylish problem matcher defined below catches that output, and creates two annotations from it.
@@ -94,12 +101,15 @@ The first pattern matches the `test.js` line and records the file information. T
94
101
The second pattern loops through the remaining lines with `loop: true` until it fails to find a match, and surfaces these lines prominently in the UI.
95
102
96
103
## Adding and Removing Problem Matchers
104
+
97
105
Problem Matchers are enabled and removed via the toolkit [commands](commands.md#problem-matchers).
98
106
99
107
## Duplicate Problem Matchers
108
+
100
109
Registering two problem-matchers with the same owner will result in only the problem matcher registered last running.
101
110
102
111
## Examples
112
+
103
113
Some of the starter actions are already using problem matchers, for example:
0 commit comments