Skip to content

Commit c686932

Browse files
committed
Merge branch 'master' into releases/v1
2 parents e08fd32 + 4ee2d12 commit c686932

12 files changed

+59
-52
lines changed

.editorconfig

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,13 @@ indent_size = 4
77
indent_style = space
88
trim_trailing_whitespace = true
99

10-
[*.js]
10+
[*.{js,ts}]
1111
end_of_line = lf
1212
indent_size = 2
1313

1414
[*.json]
1515
indent_size = 2
1616

17-
[*.ts]
18-
end_of_line = lf
19-
indent_size = 2
20-
2117
[*.yml]
2218
indent_size = 2
2319

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
__tests__/runner/*
22

3-
# comment out in distribution branches
43
dist/
54

65
node_modules/

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"cSpell.words": [
3+
"dependabot",
4+
"promisify"
5+
]
6+
}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# dotnet-format Problem Matcher
1+
# Problem Matcher for dotnet-format
22

33
[![CI Workflow Status](https://github.com/xt0rted/dotnet-format-problem-matcher/workflows/CI/badge.svg)](https://github.com/xt0rted/dotnet-format-problem-matcher/actions?query=workflow%3ACI)
4+
[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=xt0rted/dotnet-format-problem-matcher)](https://dependabot.com)
45

56
Adds a problem matcher that will detect errors from [dotnet-format](https://github.com/dotnet/format) and create annotations for them.
67

__data__/dotnetFormatMatcher.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

__tests__/problemMatcher.test.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
import { matchResults } from "../__helpers__/utils";
2-
import { dotnetFormatMatcher, ProblemMatcherPattern } from "../__data__/dotnetFormatMatcher";
2+
import { problemMatcher as problemMatcherJson } from "../.github/problem-matcher.json";
3+
import { ProblemMatcher, ProblemPattern } from "github-actions-problem-matcher-typings";
4+
5+
const problemMatcher: ProblemMatcher = problemMatcherJson[0];
36

47
describe("problemMatcher", () => {
8+
it("has the correct owner", () => {
9+
expect(problemMatcher.owner).toEqual("dotnet-format");
10+
});
11+
512
it("has one pattern", () => {
6-
expect(dotnetFormatMatcher.pattern.length).toEqual(1);
13+
expect(problemMatcher.pattern.length).toEqual(1);
714
});
815

916
describe("pattern", () => {
@@ -15,25 +22,22 @@ describe("problemMatcher", () => {
1522
" Format complete in 4451ms.",
1623
];
1724

18-
let pattern: ProblemMatcherPattern;
19-
let regexp: RegExp;
25+
let pattern: ProblemPattern;
26+
let results: RegExpExecArray[];
2027

2128
beforeEach(() => {
22-
pattern = dotnetFormatMatcher.pattern[0];
23-
regexp = new RegExp(pattern.regexp);
29+
pattern = problemMatcher.pattern[0];
30+
31+
const regexp = new RegExp(pattern.regexp);
32+
33+
results = matchResults(reportOutput, regexp);
2434
});
2535

2636
it("matches violations", () => {
27-
const results = matchResults(reportOutput, regexp);
28-
2937
expect(results.length).toEqual(2);
3038
});
3139

3240
it("matches violation details", () => {
33-
const results = matchResults(reportOutput, regexp);
34-
35-
expect(results.length).toEqual(2);
36-
3741
expect(results[0][pattern.file]).toEqual("src\\ConsoleApp\\Program.cs");
3842
expect(results[0][pattern.line]).toEqual("5");
3943
expect(results[0][pattern.column]).toEqual("18");

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "dotnet-format Problem Matcher"
1+
name: "Problem Matcher for dotnet-format"
22

33
description: "Sets up a problem matcher for dotnet-format that's used to create annotations for violations"
44

package-lock.json

Lines changed: 12 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
"url": "git+https://github.com/xt0rted/dotnet-format-problem-matcher.git"
1717
},
1818
"keywords": [
19-
"actions"
19+
"actions",
20+
"github",
21+
"problem-matcher",
22+
"annotations"
2023
],
2124
"author": "xt0rted",
2225
"license": "MIT",
@@ -25,8 +28,9 @@
2528
},
2629
"devDependencies": {
2730
"@types/jest": "^25.1.2",
28-
"@types/node": "^13.7.0",
29-
"@zeit/ncc": "^0.21.0",
31+
"@types/node": "^13.7.1",
32+
"@zeit/ncc": "^0.21.1",
33+
"github-actions-problem-matcher-typings": "^1.0.0",
3034
"jest": "^25.1.0",
3135
"jest-circus": "^25.1.0",
3236
"ts-jest": "^25.2.0",

src/main.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
1+
import { readFile } from "fs";
12
import { join } from "path";
3+
import { promisify } from "util";
24

35
import { getInput, setFailed } from "@actions/core";
46
import { issueCommand } from "@actions/core/lib/command"
57

6-
export function run() {
8+
import { ProblemMatcher } from "github-actions-problem-matcher-typings";
9+
10+
const readFileAsync = promisify(readFile);
11+
12+
export async function run(): Promise<void> {
713
try {
814
const action = getInput("action");
915

16+
const matcherFile = join(__dirname, "..", ".github", "problem-matcher.json");
17+
1018
switch (action) {
1119
case "add":
1220
issueCommand(
1321
"add-matcher",
1422
{},
15-
join(__dirname, "..", ".github", "dotnet-format-problem-matcher.json"),
23+
matcherFile,
1624
);
1725
break;
1826

1927
case "remove":
28+
const fileContents = await readFileAsync(matcherFile, { encoding: "utf8" });
29+
const problemMatcher: ProblemMatcher = JSON.parse(fileContents);
30+
2031
issueCommand(
2132
"remove-matcher",
2233
{
23-
owner: "dotnet-format",
34+
owner: problemMatcher.owner,
2435
},
2536
"",
2637
);

tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
},
6363
"exclude": [
6464
"node_modules",
65-
"__data__",
6665
"__helpers__",
6766
"__tests__"
6867
]

0 commit comments

Comments
 (0)