Skip to content

Commit

Permalink
Fix eslint violations
Browse files Browse the repository at this point in the history
  • Loading branch information
xt0rted committed Feb 24, 2021
1 parent 99f779d commit b1468db
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
5 changes: 4 additions & 1 deletion src/actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { getInput, setOutput } from "@actions/core";
import {
getInput,
setOutput,
} from "@actions/core";

import { format } from "./dotnet";

Expand Down
10 changes: 6 additions & 4 deletions src/dotnet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { debug, info, warning } from "@actions/core";
import {
debug,
info,
warning,
} from "@actions/core";
import { exec } from "@actions/exec";
import { context } from "@actions/github";
import { which } from "@actions/io";
Expand Down Expand Up @@ -27,9 +31,7 @@ function formatOnlyChangedFiles(onlyChangedFiles: boolean): boolean {
}

export async function format(options: FormatOptions): Promise<boolean> {
const execOptions: ExecOptions = {
ignoreReturnCode: true,
};
const execOptions: ExecOptions = { ignoreReturnCode: true };

const dotnetFormatOptions = ["format", "--check"];

Expand Down
23 changes: 13 additions & 10 deletions src/files.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
import { extname } from "path";

import { getInput } from "@actions/core";
import { context, getOctokit } from "@actions/github";
import {
context,
getOctokit,
} from "@actions/github";

enum fileStatus {
enum FileStatus {
/**
* The file was added.
*/
added = "added",
Added = "added",

/**
* The mode of the file was changed or there are unknown changes because the diff was truncated.
*/
changed = "changed",
Changed = "changed",

/**
* The content of the file was modified.
*/
modified = "modified",
Modified = "modified",

/**
* The file was removed.
*/
removed = "removed",
Removed = "removed",

/**
* The file was renamed.
*/
renamed = "renamed",
Renamed = "renamed",
}

const fileTypes = [
Expand All @@ -49,7 +52,7 @@ export async function getPullRequestFiles(): Promise<string[]> {
});

return files
.filter(file => file.status !== fileStatus.removed)
.filter(file => fileTypes.includes(extname(file.filename)))
.map(file => file.filename);
.filter((file) => file.status !== FileStatus.Removed)
.filter((file) => fileTypes.includes(extname(file.filename)))
.map((file) => file.filename);
}
19 changes: 14 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { getInput, setFailed } from "@actions/core";
import {
getInput,
setFailed,
} from "@actions/core";

import { check, fix } from "./actions";
import {
check,
fix,
} from "./actions";

export async function run(): Promise<void> {
try {
Expand All @@ -19,9 +25,12 @@ export async function run(): Promise<void> {
throw Error(`Unsupported action "${action}"`);
}
} catch (error) {
setFailed(error.message);
throw error;
if (error instanceof Error) {
setFailed(error.message);
} else {
throw error;
}
}
}

run();
void run();

0 comments on commit b1468db

Please sign in to comment.