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

Prefering arrow functions #1059

Merged
merged 4 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"plugins": [
"deprecation",
"jest",
"prefer-arrow-functions",
"simple-import-sort",
"@typescript-eslint"
],
Expand All @@ -19,11 +20,19 @@
"plugin:prettier/recommended"
],
"rules": {
"deprecation/deprecation": "warn",
"arrow-body-style": ["error", "as-needed"],
"camelcase": ["error", {"allow": ["issue_number"]}],
"no-warning-comments": "warn",
"strict": ["error", "never"],
"deprecation/deprecation": "warn",
"prefer-arrow-functions/prefer-arrow-functions": [
"error",
{
"allowNamedFunctions": true
}
],
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"strict": ["error", "never"],
"@typescript-eslint/array-type": ["error", { "default": "generic" }],
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/consistent-type-imports": "error",
Expand Down
24 changes: 12 additions & 12 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10189,7 +10189,7 @@ function getIssue() {
return __awaiter(this, void 0, void 0, function* () {
const issues = yield (0, octokit_1.octokit)()
.rest.issues.listForRepo(Object.assign(Object.assign({}, (0, repo_1.repo)()), { creator: "github-actions[bot]", labels: "wpvc" }))
.catch(function (e) {
.catch((e) => {
throw new IssueListError_1.IssueListError(String(e));
});
return issues.data.length > 0 ? issues.data[0].number : null;
Expand All @@ -10200,7 +10200,7 @@ function commentOnIssue(issue, comment) {
return __awaiter(this, void 0, void 0, function* () {
yield (0, octokit_1.octokit)()
.rest.issues.createComment(Object.assign(Object.assign({}, (0, repo_1.repo)()), { issue_number: issue, body: comment }))
.catch(function (e) {
.catch((e) => {
throw new IssueCommentError_1.IssueCommentError(issue, String(e));
});
});
Expand All @@ -10210,7 +10210,7 @@ function closeIssue(issue) {
return __awaiter(this, void 0, void 0, function* () {
yield (0, octokit_1.octokit)()
.rest.issues.update(Object.assign(Object.assign({}, (0, repo_1.repo)()), { issue_number: issue, state: "closed" }))
.catch(function (e) {
.catch((e) => {
throw new IssueUpdateError_1.IssueUpdateError(issue, String(e));
});
});
Expand All @@ -10221,7 +10221,7 @@ function createIssue(title, body, assignees) {
yield (0, octokit_1.octokit)()
.rest.issues.create(Object.assign(Object.assign({}, (0, repo_1.repo)()), { title,
body, labels: ["wpvc"], assignees }))
.catch(function (e) {
.catch((e) => {
throw new IssueCreationError_1.IssueCreationError(String(e));
});
});
Expand All @@ -10231,7 +10231,7 @@ function updateIssue(issueNumber, title, body) {
return __awaiter(this, void 0, void 0, function* () {
const issue = yield (0, octokit_1.octokit)()
.rest.issues.get(Object.assign(Object.assign({}, (0, repo_1.repo)()), { issue_number: issueNumber }))
.catch(function (e) {
.catch((e) => {
throw new GetIssueError_1.GetIssueError(issueNumber, String(e));
});
if (issue.data.title === title && issue.data.body === body) {
Expand All @@ -10240,7 +10240,7 @@ function updateIssue(issueNumber, title, body) {
yield (0, octokit_1.octokit)()
.rest.issues.update(Object.assign(Object.assign({}, (0, repo_1.repo)()), { issue_number: issueNumber, title,
body }))
.catch(function (e) {
.catch((e) => {
throw new IssueUpdateError_1.IssueUpdateError(issueNumber, String(e));
});
});
Expand Down Expand Up @@ -10585,7 +10585,7 @@ function readme(config) {
for (const readmeLocation of config.readme) {
const result = yield (0, octokit_1.octokit)()
.rest.repos.getContent(Object.assign(Object.assign({}, (0, repo_1.repo)()), { path: readmeLocation }))
.catch(function (e) {
.catch((e) => {
if ((0, has_status_1.hasStatus)(e) && e.status === 404) {
return null;
}
Expand Down Expand Up @@ -10698,15 +10698,15 @@ const https = __importStar(__nccwpck_require__(5687));
const LatestVersionError_1 = __nccwpck_require__(4241);
function httpsRequest(options) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise(function (resolve, reject) {
return new Promise((resolve, reject) => {
https
.get(options, function (response) {
.get(options, (response) => {
let data = "";
response.setEncoding("utf8");
response.on("data", (chunk) => {
data += chunk;
});
response.on("end", function () {
response.on("end", () => {
if (response.statusCode === 200) {
resolve(data);
}
Expand Down Expand Up @@ -10737,7 +10737,7 @@ function wordpressVersions() {
const rawData = yield httpsRequest({
host: "api.wordpress.org",
path: "/core/version-check/1.7/?channel=beta",
}).catch(function (e) {
}).catch((e) => {
throw new LatestVersionError_1.LatestVersionError(e);
});
let response = {};
Expand Down Expand Up @@ -10834,7 +10834,7 @@ function WPVCConfig() {
return __awaiter(this, void 0, void 0, function* () {
const file = yield (0, octokit_1.octokit)()
.rest.repos.getContent(Object.assign(Object.assign({}, (0, repo_1.repo)()), { path: ".wordpress-version-checker.json" }))
.catch(function (e) {
.catch((e) => {
if ((0, has_status_1.hasStatus)(e) && e.status === 404) {
return null;
}
Expand Down
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-deprecation": "^2.0.0",
"eslint-plugin-jest": "^27.4.2",
"eslint-plugin-prefer-arrow-functions": "^3.2.4",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"jest": "^29.7.0",
Expand Down
12 changes: 6 additions & 6 deletions src/issue-management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function getIssue(): Promise<number | null> {
creator: "github-actions[bot]",
labels: "wpvc",
})
.catch(function (e): never {
.catch((e): never => {
throw new IssueListError(String(e));
});
return issues.data.length > 0 ? issues.data[0].number : null;
Expand All @@ -29,7 +29,7 @@ export async function commentOnIssue(
issue_number: issue,
body: comment,
})
.catch(function (e): never {
.catch((e): never => {
throw new IssueCommentError(issue, String(e));
});
}
Expand All @@ -41,7 +41,7 @@ export async function closeIssue(issue: number): Promise<void> {
issue_number: issue,
state: "closed",
})
.catch(function (e): never {
.catch((e): never => {
throw new IssueUpdateError(issue, String(e));
});
}
Expand All @@ -59,7 +59,7 @@ export async function createIssue(
labels: ["wpvc"],
assignees,
})
.catch(function (e): never {
.catch((e): never => {
throw new IssueCreationError(String(e));
});
}
Expand All @@ -71,7 +71,7 @@ export async function updateIssue(
): Promise<void> {
const issue = await octokit()
.rest.issues.get({ ...repo(), issue_number: issueNumber })
.catch(function (e): never {
.catch((e): never => {
throw new GetIssueError(issueNumber, String(e));
});
if (issue.data.title === title && issue.data.body === body) {
Expand All @@ -84,7 +84,7 @@ export async function updateIssue(
title,
body,
})
.catch(function (e): never {
.catch((e): never => {
throw new IssueUpdateError(issueNumber, String(e));
});
}
2 changes: 1 addition & 1 deletion src/tested-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ async function readme(config: Config): Promise<string> {
for (const readmeLocation of config.readme) {
const result = await octokit()
.rest.repos.getContent({ ...repo(), path: readmeLocation })
.catch(function (e: unknown): never | null {
.catch((e: unknown): never | null => {
if (hasStatus(e) && e.status === 404) {
return null;
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/wordpress-versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import type { VersionCheckResponse } from "./interfaces/VersionCheckResponse";
import type { WordpressVersions } from "./interfaces/WordpressVersions";

async function httpsRequest(options: https.RequestOptions): Promise<string> {
return new Promise(function (resolve, reject) {
return new Promise((resolve, reject) => {
https
.get(options, function (response) {
.get(options, (response) => {
let data = "";
response.setEncoding("utf8");
response.on("data", (chunk): void => {
data += chunk;
});
response.on("end", function (): void {
response.on("end", (): void => {
if (response.statusCode === 200) {
resolve(data);
} else {
Expand Down Expand Up @@ -45,7 +45,7 @@ export async function wordpressVersions(): Promise<WordpressVersions> {
const rawData = await httpsRequest({
host: "api.wordpress.org",
path: "/core/version-check/1.7/?channel=beta",
}).catch(function (e: string): never {
}).catch((e: string): never => {
throw new LatestVersionError(e);
});
let response: VersionCheckResponse = {};
Expand Down
2 changes: 1 addition & 1 deletion src/wpvc-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function WPVCConfig(): Promise<Config> {
...repo(),
path: ".wordpress-version-checker.json",
})
.catch(function (e: unknown): never | null {
.catch((e: unknown): never | null => {
if (hasStatus(e) && e.status === 404) {
return null;
} else {
Expand Down