Skip to content

Commit a60ce85

Browse files
Merge pull request #114 from PaulGiletich/master
annotate files relative to git root, instead of cwd, so that it works in nested packages in monorepos (+fix lint)
2 parents a1a27e1 + 516d432 commit a60ce85

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

.eslintrc

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"rules": {
2323
"@typescript-eslint/explicit-function-return-type": 0,
2424
"@typescript-eslint/camelcase": 0,
25+
"camelcase": 0,
2526
"complexity": 0,
2627
"import/extensions": 0
2728
}

package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,19 @@
3434
},
3535
"dependencies": {
3636
"create-check": "^0.6.0",
37-
"eslint-formatter-pretty": "^3.0.0"
37+
"eslint-formatter-pretty": "^3.0.0",
38+
"execa": "^1.0.0"
3839
},
3940
"devDependencies": {
41+
"@types/execa": "^0.9.0",
4042
"@types/env-ci": "3.1.0",
4143
"@types/eslint": "6.8.0",
4244
"@types/lru-cache": "5.1.0",
43-
"@typescript-eslint/eslint-plugin": "2.32.0",
44-
"@typescript-eslint/parser": "2.32.0",
45+
"@typescript-eslint/eslint-plugin": "^5.54.0",
46+
"@typescript-eslint/parser": "^5.54.0",
4547
"auto": "^10.43.0",
4648
"auto-config-hipstersmoothie": "^4.0.0",
47-
"eslint": "7.0.0",
49+
"eslint": "^7.1.0",
4850
"eslint-config-airbnb": "18.1.0",
4951
"eslint-config-airbnb-base": "14.1.0",
5052
"eslint-config-prettier": "6.11.0",

src/create-check.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import createCheck, { Annotation } from 'create-check';
22
import path from 'path';
33
import eslint from 'eslint';
4+
import execa from 'execa';
45

56
const APP_ID = 38817;
67
/**
@@ -45,7 +46,9 @@ rxXIyGcdFUjpY/U2tobjXousbYyz8/DqgDoLWXOMt2dNkbbNAN8L3OMVTGb6TzS2
4546
gd8URXIGc6Nk7ueWMKEZaropIg6q1J7e9qJdlzA6j1fu6vVY3qX3tA==
4647
-----END RSA PRIVATE KEY-----`;
4748

48-
export function createAnnotations(results: eslint.CLIEngine.LintResult[]) {
49+
export async function createAnnotations(results: eslint.CLIEngine.LintResult[]) {
50+
const repoRoot = (await execa('git', ['rev-parse', '--show-toplevel'])).stdout;
51+
4952
const annotations: Annotation[] = [];
5053
const levels: Annotation['annotation_level'][] = [
5154
'notice',
@@ -61,7 +64,7 @@ export function createAnnotations(results: eslint.CLIEngine.LintResult[]) {
6164
const annotationLevel = levels[severity];
6265

6366
annotations.push({
64-
path: path.relative(process.cwd(), filePath),
67+
path: path.relative(repoRoot, filePath),
6568
start_line: line,
6669
end_line: line,
6770
annotation_level: annotationLevel,
@@ -91,7 +94,7 @@ export default async (results: eslint.CLIEngine.LintResult[]) => {
9194
return createCheck({
9295
tool: 'ESLint',
9396
name: process.env.GH_CHECK_NAME || 'Check Code for Errors',
94-
annotations: createAnnotations(results),
97+
annotations: await createAnnotations(results),
9598
errorCount,
9699
warningCount,
97100
appId: process.env.ESLINT_APP_ID

0 commit comments

Comments
 (0)