1
1
import createCheck , { Annotation } from 'create-check' ;
2
2
import path from 'path' ;
3
3
import eslint from 'eslint' ;
4
+ import execa from 'execa' ;
4
5
5
6
const APP_ID = 38817 ;
6
7
/**
@@ -45,7 +46,9 @@ rxXIyGcdFUjpY/U2tobjXousbYyz8/DqgDoLWXOMt2dNkbbNAN8L3OMVTGb6TzS2
45
46
gd8URXIGc6Nk7ueWMKEZaropIg6q1J7e9qJdlzA6j1fu6vVY3qX3tA==
46
47
-----END RSA PRIVATE KEY-----` ;
47
48
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
+
49
52
const annotations : Annotation [ ] = [ ] ;
50
53
const levels : Annotation [ 'annotation_level' ] [ ] = [
51
54
'notice' ,
@@ -61,7 +64,7 @@ export function createAnnotations(results: eslint.CLIEngine.LintResult[]) {
61
64
const annotationLevel = levels [ severity ] ;
62
65
63
66
annotations . push ( {
64
- path : path . relative ( process . cwd ( ) , filePath ) ,
67
+ path : path . relative ( repoRoot , filePath ) ,
65
68
start_line : line ,
66
69
end_line : line ,
67
70
annotation_level : annotationLevel ,
@@ -91,7 +94,7 @@ export default async (results: eslint.CLIEngine.LintResult[]) => {
91
94
return createCheck ( {
92
95
tool : 'ESLint' ,
93
96
name : process . env . GH_CHECK_NAME || 'Check Code for Errors' ,
94
- annotations : createAnnotations ( results ) ,
97
+ annotations : await createAnnotations ( results ) ,
95
98
errorCount,
96
99
warningCount,
97
100
appId : process . env . ESLINT_APP_ID
0 commit comments