Skip to content

Commit

Permalink
Merge pull request #151 from xt0rted/eslint-update
Browse files Browse the repository at this point in the history
Update eslint to v7
  • Loading branch information
xt0rted authored Feb 24, 2021
2 parents 6ffd6c0 + b99fc33 commit 6756652
Show file tree
Hide file tree
Showing 8 changed files with 495 additions and 409 deletions.
81 changes: 73 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,47 @@ module.exports = {
rules: {
"array-bracket-spacing": "error",
"comma-dangle": ["error", "always-multiline"],
eqeqeq: ["error", "smart"],
indent: ["error", 2],
"object-curly-newline": ["error", {
ExportDeclaration: {
multiline: true,
minProperties: 2,
},
ImportDeclaration: {
multiline: true,
minProperties: 2,
},
ObjectExpression: {
multiline: true,
minProperties: 2,
},
ObjectPattern: { consistent: true },
}],
"object-shorthand": "error",
quotes: ["error", "double"],
"quote-props": ["error", "as-needed"],
semi: "error",
// strings
"no-nonoctal-decimal-escape": "error",
// variables
"no-const-assign": "error",
"no-var": "error",
"prefer-const": "error",
// arrow functions
"arrow-body-style": ["error", "as-needed"],
"arrow-parens": ["error", "always"],
"arrow-spacing": ["error", {
before: true, after: true,
}],
"implicit-arrow-linebreak": ["error", "beside"],
"prefer-arrow-callback": "error",
// classes
"class-methods-use-this": "error",
"no-dupe-class-members": "error",
"no-useless-constructor": "error",
// modules
"no-duplicate-imports": ["error", { includeExports: true }],
},
overrides: [
{
Expand All @@ -35,15 +72,43 @@ module.exports = {
camelcase: "off",
indent: "off",
quotes: "off",
"@typescript-eslint/camelcase": ["error", {
properties: "always",
genericType: "always",
ignoreDestructuring: false,
allow: [
"pull_number",
],
}],
"@typescript-eslint/indent": ["error", 2],
"@typescript-eslint/naming-convention": [
"error",
// eslint defaults
{
selector: "default",
format: ["camelCase"],
},
{
selector: "variable",
format: ["camelCase", "UPPER_CASE"],
},
{
selector: "parameter",
format: ["camelCase"],
leadingUnderscore: "allow",
},
{
selector: "memberLike",
modifiers: ["private"],
format: ["camelCase"],
leadingUnderscore: "require",
},
{
selector: "typeLike",
format: ["PascalCase"],
},
// project specific settings
{
selector: "enumMember",
format: ["StrictPascalCase"],
},
{
selector: "property",
format: null,
},
],
"@typescript-eslint/quotes": ["error", "double"],
},
},
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
- Bumped `@actions/core` from 1.2.3 to 1.2.6
- Bumped `@actions/exec` from 1.0.3 to 1.0.4
- Bumped `@actions/github` from 2.1.1 to 4.0.0
- Bumped `@typescript-eslint/eslint-plugin` from 2.34.0 to 4.15.2
- Bumped `@typescript-eslint/parser` from 2.34.0 to 4.15.2
- Bumped `eslint` from 6.8.0 to 7.22.0
- Adjusted eslint rules and fixed any violations

## Version 1.0.1

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
},
"devDependencies": {
"@types/node": "^14.14.31",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"@typescript-eslint/eslint-plugin": "^4.15.2",
"@typescript-eslint/parser": "^4.15.2",
"@zeit/ncc": "^0.22.3",
"eslint": "^6.8.0",
"eslint": "^7.20.0",
"typescript": "^4.2.2"
}
}
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();
Loading

0 comments on commit 6756652

Please sign in to comment.