Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A Disgusting PR #3

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
@@ -0,0 +1,3 @@
{
"eslint.enable": false
}
3 changes: 3 additions & 0 deletions src/api.ts
@@ -1,3 +1,4 @@
import * as github from '@actions/github';
import * as core from '@actions/core';

import { PrResponse, Octokit, ActionData, ExpectedUpdateParams } from './types';
Expand Down Expand Up @@ -126,6 +127,8 @@ export async function fetchFilesBatchCommit(
}
}

const client = 1;

export async function createCheck(
client: Octokit,
data: ActionData,
Expand Down
5 changes: 4 additions & 1 deletion src/constants.ts
Expand Up @@ -12,7 +12,10 @@ declare global {

export const NAME = 'Eslint Changed';




export const OWNER = github.context.repo.owner;

export const REPO = github.context.repo.repo;
export const { GITHUB_WORKSPACE } = process.env;
export const { GITHUB_WORKSPACE } = process.env;
30 changes: 16 additions & 14 deletions src/eslint.ts
Expand Up @@ -53,12 +53,14 @@ export async function lintChangedFiles(
},
});
}
console.log('Final Check')
const summary = `
| Type | Occurrences | Fixable |
| ------------ | ----------------------- | ---------------------------- |
| **Errors** | ${state.errorCount} | ${state.fixableErrorCount} |
| **Warnings** | ${state.warningCount} | ${state.fixableWarningCount} |
`;
console.log('Summary Length: ', summary.length)
const checkResult = await updateCheck({
conclusion: state.errorCount > 0 ? 'failure' : 'success',
status: 'completed',
Expand All @@ -67,21 +69,21 @@ export async function lintChangedFiles(
title: 'Checks Complete',
summary,
},
// actions:
// state.fixableErrorCount > 0 || state.fixableWarningCount > 0
// ? [
// {
// label: `Fix ${
// state.fixableErrorCount + state.fixableWarningCount
// } Issues`,
// description:
// '[UNFINISHED] Run eslint --fix',
// identifier: 'fix',
// },
// ]
// : undefined,
actions:
state.fixableErrorCount > 0 || state.fixableWarningCount > 0
? [
{
label: `Fix ${
state.fixableErrorCount + state.fixableWarningCount
} Issues`,
description: '[UNFINISHED] Run eslint --fix',
identifier: 'fix',
},
]
: undefined,
});
if (data.prID && data.issueSummary) {
console.log('Handle Issues')
// const annotations = await client.checks.listAnnotations({
// check_run_id: checkResult.data.id,
// owner: OWNER,
Expand Down Expand Up @@ -138,7 +140,7 @@ ${[...state.rulesSummaries]
${summary.annotations
.map(
(annotation) =>
`- [${annotation.path}](${data.repoHtmlUrl}/blob/${data.sha}/${annotation.path}#L${annotation.start_line}-L${annotation.end_line}) Line ${annotation.start_line} - ${annotation.message}`,
`- [${annotation.path}](${data.repoHtmlUrl}/blob/${data.sha}/${annotation.path}#L${annotation.start_line}-L${annotation.end_line}) Line ${annotation.start_line} - ${annotation.message.replace(`[${summary.ruleId}] `, '')}`,
)
.join('\n')}`,
)
Expand Down
1 change: 1 addition & 0 deletions src/fs.ts
Expand Up @@ -9,6 +9,7 @@ import { Octokit, PrResponse, ActionData, ActionDataWithPR } from './types';
export async function filterFiles(
files: string[],
data: ActionData,
unused?: any
): Promise<string[]> {
const { extensions } = data.eslint;
// const result: string[] = [];
Expand Down
1 change: 0 additions & 1 deletion src/test.md

This file was deleted.

1 change: 1 addition & 0 deletions src/types.ts
Expand Up @@ -13,6 +13,7 @@ export type ActionData = {
sha: string;
prID: number | undefined;
prHtmlUrl: string | undefined;
cam_case?: any;
repoHtmlUrl: string | undefined;

includeGlob: string[];
Expand Down
5 changes: 2 additions & 3 deletions src/utils.ts
Expand Up @@ -23,7 +23,7 @@ export const processArrayInput = <D>(
}
return defaultValue;
}
return result.split(',').map((e) => e.trim());
return result.split(',' ).map((e) => e.trim());
};

export const processBooleanInput = <D>(
Expand Down Expand Up @@ -105,8 +105,7 @@ export function processLintResults(
start_line: line,
end_line: line,
annotation_level: level,
title: ruleId,
message: `${message}${
message: `[${ruleId}] ${message}${
suggestions && suggestions.length > 0
? `

Expand Down