Skip to content

Commit

Permalink
Merge pull request #114 from PaulGiletich/master
Browse files Browse the repository at this point in the history
annotate files relative to git root, instead of cwd, so that it works in nested packages in monorepos (+fix lint)
  • Loading branch information
hipstersmoothie committed Mar 2, 2023
2 parents a1a27e1 + 516d432 commit a60ce85
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"rules": {
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/camelcase": 0,
"camelcase": 0,
"complexity": 0,
"import/extensions": 0
}
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@
},
"dependencies": {
"create-check": "^0.6.0",
"eslint-formatter-pretty": "^3.0.0"
"eslint-formatter-pretty": "^3.0.0",
"execa": "^1.0.0"
},
"devDependencies": {
"@types/execa": "^0.9.0",
"@types/env-ci": "3.1.0",
"@types/eslint": "6.8.0",
"@types/lru-cache": "5.1.0",
"@typescript-eslint/eslint-plugin": "2.32.0",
"@typescript-eslint/parser": "2.32.0",
"@typescript-eslint/eslint-plugin": "^5.54.0",
"@typescript-eslint/parser": "^5.54.0",
"auto": "^10.43.0",
"auto-config-hipstersmoothie": "^4.0.0",
"eslint": "7.0.0",
"eslint": "^7.1.0",
"eslint-config-airbnb": "18.1.0",
"eslint-config-airbnb-base": "14.1.0",
"eslint-config-prettier": "6.11.0",
Expand Down
9 changes: 6 additions & 3 deletions src/create-check.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import createCheck, { Annotation } from 'create-check';
import path from 'path';
import eslint from 'eslint';
import execa from 'execa';

const APP_ID = 38817;
/**
Expand Down Expand Up @@ -45,7 +46,9 @@ rxXIyGcdFUjpY/U2tobjXousbYyz8/DqgDoLWXOMt2dNkbbNAN8L3OMVTGb6TzS2
gd8URXIGc6Nk7ueWMKEZaropIg6q1J7e9qJdlzA6j1fu6vVY3qX3tA==
-----END RSA PRIVATE KEY-----`;

export function createAnnotations(results: eslint.CLIEngine.LintResult[]) {
export async function createAnnotations(results: eslint.CLIEngine.LintResult[]) {
const repoRoot = (await execa('git', ['rev-parse', '--show-toplevel'])).stdout;

const annotations: Annotation[] = [];
const levels: Annotation['annotation_level'][] = [
'notice',
Expand All @@ -61,7 +64,7 @@ export function createAnnotations(results: eslint.CLIEngine.LintResult[]) {
const annotationLevel = levels[severity];

annotations.push({
path: path.relative(process.cwd(), filePath),
path: path.relative(repoRoot, filePath),
start_line: line,
end_line: line,
annotation_level: annotationLevel,
Expand Down Expand Up @@ -91,7 +94,7 @@ export default async (results: eslint.CLIEngine.LintResult[]) => {
return createCheck({
tool: 'ESLint',
name: process.env.GH_CHECK_NAME || 'Check Code for Errors',
annotations: createAnnotations(results),
annotations: await createAnnotations(results),
errorCount,
warningCount,
appId: process.env.ESLINT_APP_ID
Expand Down

0 comments on commit a60ce85

Please sign in to comment.