Skip to content

Commit 17acd9c

Browse files
authored
update problem matchers doc for fromPath and default severity (#256)
1 parent d497551 commit 17acd9c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

docs/problem-matchers.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# Problem Matchers
2+
23
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.
34

45
## Single Line Matchers
56

67
Let's consider the ESLint compact output:
8+
79
```
810
badFile.js: line 50, col 11, Error - 'myVar' is defined but never used. (no-unused-vars)
911
```
12+
1013
We can define a problem matcher in json that detects input in that format:
14+
1115
```json
1216
{
1317
"problemMatcher": [
@@ -33,31 +37,34 @@ The following fields are available for problem matchers:
3337

3438
```
3539
{
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'
3742
pattern: [
3843
{
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**
4045
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)
4147
line: a group number containing the line number
4248
column: a group number containing the column information
4349
severity: a group number containing either 'warning' or 'error' case-insensitive. Defaults to `error`
4450
code: a group number containing the error code
4551
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
4753
}
4854
]
4955
}
5056
```
5157

52-
5358
## Multiline Matching
5459
Consider the following output:
60+
5561
```
5662
test.js
5763
1:0 error Missing "use strict" statement strict
5864
5:10 error 'addOne' is defined but never used no-unused-vars
5965
✖ 2 problems (2 errors, 0 warnings)
6066
```
67+
6168
The file name is printed once, yet multiple error lines are printed. The `loop` keyword provides a way to discover multiple errors in outputs.
6269

6370
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
94101
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.
95102

96103
## Adding and Removing Problem Matchers
104+
97105
Problem Matchers are enabled and removed via the toolkit [commands](commands.md#problem-matchers).
98106

99107
## Duplicate Problem Matchers
108+
100109
Registering two problem-matchers with the same owner will result in only the problem matcher registered last running.
101110

102111
## Examples
112+
103113
Some of the starter actions are already using problem matchers, for example:
104114
- [setup-node](https://github.com/actions/setup-node/tree/master/.github)
105115
- [setup-python](https://github.com/actions/setup-python/tree/master/.github)

0 commit comments

Comments
 (0)