Skip to content

Commit 8cb068a

Browse files
committed
style: xo
1 parent a946687 commit 8cb068a

37 files changed

+1092
-1734
lines changed

index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
import {defaultTo, castArray} from 'lodash';
44

5-
import verifyGitHub from './lib/verify';
6-
import addChannelGitHub from './lib/add-channel';
7-
import publishGitHub from './lib/publish';
8-
import successGitHub from './lib/success';
9-
import failGitHub from './lib/fail';
5+
import verifyGitHub from './lib/verify.js';
6+
import addChannelGitHub from './lib/add-channel.js';
7+
import publishGitHub from './lib/publish.js';
8+
import successGitHub from './lib/success.js';
9+
import failGitHub from './lib/fail.js';
1010

1111
let verified;
1212

@@ -65,4 +65,6 @@ async function fail(pluginConfig, context) {
6565
await failGitHub(pluginConfig, context);
6666
}
6767

68-
export default {verifyConditions, addChannel, publish, success, fail};
68+
const plugin = {verifyConditions, addChannel, publish, success, fail};
69+
70+
export default plugin;

lib/add-channel.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import debugFactory from 'debug';
2-
import {RELEASE_NAME} from './definitions/constants';
3-
import parseGithubUrl from './parse-github-url';
4-
import resolveConfig from './resolve-config';
5-
import getClient from './get-client';
6-
import isPrerelease from './is-prerelease';
2+
3+
import {RELEASE_NAME} from './definitions/constants.js';
4+
import parseGithubUrl from './parse-github-url.js';
5+
import resolveConfig from './resolve-config.js';
6+
import getClient from './get-client.js';
7+
import isPrerelease from './is-prerelease.js';
78

89
const debug = debugFactory('semantic-release:github');
910

10-
export default async (pluginConfig, context) => {
11+
export default async function addChannel(pluginConfig, context) {
1112
const {
1213
options: {repositoryUrl},
1314
branch,
@@ -51,4 +52,4 @@ export default async (pluginConfig, context) => {
5152
logger.log('Updated GitHub release: %s', url);
5253

5354
return {url, name: RELEASE_NAME};
54-
};
55+
}

lib/definitions/constants.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ const ISSUE_ID = '<!-- semantic-release:github -->';
22

33
const RELEASE_NAME = 'GitHub release';
44

5-
export default {ISSUE_ID, RELEASE_NAME};
5+
const CONSTANTS = {ISSUE_ID, RELEASE_NAME};
6+
7+
export default CONSTANTS;

lib/definitions/errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {isString} from 'lodash';
55
const HOMEPAGE = 'https://github.com/semantic-release/github#readme';
66

77
const stringify = (object) =>
8-
isString(object) ? object : inspect(object, {breakLength: Infinity, depth: 2, maxArrayLength: 5});
8+
isString(object) ? object : inspect(object, {breakLength: Number.POSITIVE_INFINITY, depth: 2, maxArrayLength: 5});
99
const linkify = (file) => `${HOMEPAGE}/blob/master/${file}`;
1010

1111
export function EINVALIDASSETS({assets}) {

lib/definitions/rate-limit.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ const RATE_LIMITS = {
2424
*/
2525
const GLOBAL_RATE_LIMIT = 1000;
2626

27-
export default {RETRY_CONF, RATE_LIMITS, GLOBAL_RATE_LIMIT};
27+
const RATE_LIMIT = {RETRY_CONF, RATE_LIMITS, GLOBAL_RATE_LIMIT};
28+
29+
export default RATE_LIMIT;

lib/fail.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import {template} from 'lodash';
22
import debugFactory from 'debug';
3-
import parseGithubUrl from './parse-github-url';
4-
import {ISSUE_ID} from './definitions/constants';
5-
import resolveConfig from './resolve-config';
6-
import getClient from './get-client';
7-
import findSRIssues from './find-sr-issues';
8-
import getFailComment from './get-fail-comment';
3+
4+
import parseGithubUrl from './parse-github-url.js';
5+
import {ISSUE_ID} from './definitions/constants.js';
6+
import resolveConfig from './resolve-config.js';
7+
import getClient from './get-client.js';
8+
import findSRIssues from './find-sr-issues.js';
9+
import getFailComment from './get-fail-comment.js';
910

1011
const debug = debugFactory('semantic-release:github');
1112

12-
export default async (pluginConfig, context) => {
13+
export default async function fail(pluginConfig, context) {
1314
const {
1415
options: {repositoryUrl},
1516
branch,
@@ -39,12 +40,19 @@ export default async (pluginConfig, context) => {
3940
} = await github.issues.createComment(comment);
4041
logger.log('Added comment to issue #%d: %s.', srIssue.number, url);
4142
} else {
42-
const newIssue = {owner, repo, title: failTitle, body: `${body}\n\n${ISSUE_ID}`, labels: labels || [], assignees};
43+
const newIssue = {
44+
owner,
45+
repo,
46+
title: failTitle,
47+
body: `${body}\n\n${ISSUE_ID}`,
48+
labels: labels || [],
49+
assignees,
50+
};
4351
debug('create issue: %O', newIssue);
4452
const {
4553
data: {html_url: url, number},
4654
} = await github.issues.create(newIssue);
4755
logger.log('Created issue #%d: %s.', number, url);
4856
}
4957
}
50-
};
58+
}

lib/find-sr-issues.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {ISSUE_ID} from './definitions/constants';
1+
import {ISSUE_ID} from './definitions/constants.js';
22

3-
export default async (github, title, owner, repo) => {
3+
export default async function findIssues(github, title, owner, repo) {
44
const {
55
data: {items: issues},
66
} = await github.search.issuesAndPullRequests({
77
q: `in:title+repo:${owner}/${repo}+type:issue+state:open+${title}`,
88
});
99

1010
return issues.filter((issue) => issue.body && issue.body.includes(ISSUE_ID));
11-
};
11+
}

lib/get-client.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import urljoin from 'url-join';
66
import HttpProxyAgent from 'http-proxy-agent';
77
import HttpsProxyAgent from 'https-proxy-agent';
88

9-
import {RETRY_CONF, RATE_LIMITS, GLOBAL_RATE_LIMIT} from './definitions/rate-limit';
9+
import {RETRY_CONF, RATE_LIMITS, GLOBAL_RATE_LIMIT} from './definitions/rate-limit.js';
1010

1111
/**
1212
* Http error status for which to not retry.
@@ -26,7 +26,7 @@ const getThrottler = memoize((rate, globalThrottler) =>
2626
new Bottleneck({minTime: get(RATE_LIMITS, rate)}).chain(globalThrottler)
2727
);
2828

29-
export default ({githubToken, githubUrl, githubApiPathPrefix, proxy}) => {
29+
export default function getClient({githubToken, githubUrl, githubApiPathPrefix, proxy}) {
3030
const baseUrl = githubUrl && urljoin(githubUrl, githubApiPathPrefix);
3131
const globalThrottler = new Bottleneck({minTime: GLOBAL_RATE_LIMIT});
3232
const github = new Octokit({
@@ -60,4 +60,4 @@ export default ({githubToken, githubUrl, githubApiPathPrefix, proxy}) => {
6060
});
6161

6262
return github;
63-
};
63+
}

lib/get-error.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import SemanticReleaseError from '@semantic-release/error';
22

3-
import * as ERROR_DEFINITIONS from './definitions/errors';
3+
import * as ERROR_DEFINITIONS from './definitions/errors.js';
44

5-
export default (code, ctx = {}) => {
5+
export default function getError(code, ctx = {}) {
66
const {message, details} = ERROR_DEFINITIONS[code](ctx);
77
return new SemanticReleaseError(message, code, details);
8-
};
8+
}

lib/get-fail-comment.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ ${
1515
}`
1616
}`;
1717

18-
export default (branch, errors) => `## :rotating_light: The automated release from the \`${
19-
branch.name
20-
}\` branch failed. :rotating_light:
18+
export default function getFailComment(branch, errors) {
19+
return `## :rotating_light: The automated release from the \`${branch.name}\` branch failed. :rotating_light:
2120
2221
I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.
2322
@@ -26,8 +25,8 @@ You can find below the list of errors reported by **semantic-release**. Each one
2625
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
2726
2827
Once all the errors are resolved, **semantic-release** will release your package the next time you push a commit to the \`${
29-
branch.name
30-
}\` branch. You can also manually restart the failed CI job that runs **semantic-release**.
28+
branch.name
29+
}\` branch. You can also manually restart the failed CI job that runs **semantic-release**.
3130
3231
If you are not sure how to resolve this, here are some links that can help you:
3332
- [Usage documentation](${USAGE_DOC_URL})
@@ -45,3 +44,4 @@ ${errors.map((error) => formatError(error)).join('\n\n---\n\n')}
4544
Good luck with your project ✨
4645
4746
Your **[semantic-release](${HOME_URL})** bot :package::rocket:`;
47+
}

0 commit comments

Comments
 (0)