Skip to content

Commit

Permalink
style: xo
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Mar 11, 2020
1 parent 2e56a35 commit e6726e1
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 20 deletions.
7 changes: 4 additions & 3 deletions lib/definitions/errors.js
Expand Up @@ -3,7 +3,8 @@ const {isString} = require('lodash');
const pkg = require('../../package.json');

const [homepage] = pkg.homepage.split('#');
const stringify = obj => (isString(obj) ? obj : inspect(obj, {breakLength: Infinity, depth: 2, maxArrayLength: 5}));
const stringify = object =>
isString(object) ? object : inspect(object, {breakLength: Infinity, depth: 2, maxArrayLength: 5});
const linkify = file => `${homepage}/blob/master/${file}`;

module.exports = {
Expand Down Expand Up @@ -72,7 +73,7 @@ By default the \`repositoryUrl\` option is retrieved from the \`repository\` pro
Your configuration for the \`proxy\` option is \`${stringify(proxy)}\`.`,
}),
EMISSINGREPO: ({owner, repo}) => ({
message: `The repository ${owner}/${repo} doesn't exist.`,
message: `The repository ${owner}/${repo} doesnt exist.`,
details: `The **semantic-release** \`repositoryUrl\` option must refer to your GitHub repository. The repository must be accessible with the [GitHub API](https://developer.github.com/v3).
By default the \`repositoryUrl\` option is retrieved from the \`repository\` property of your \`package.json\` or the [git origin url](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes) of the repository cloned by your CI environment.
Expand All @@ -82,7 +83,7 @@ If you are using [GitHub Enterprise](https://enterprise.github.com) please make
)}).`,
}),
EGHNOPERMISSION: ({owner, repo}) => ({
message: `The GitHub token doesn't allow to push on the repository ${owner}/${repo}.`,
message: `The GitHub token doesnt allow to push on the repository ${owner}/${repo}.`,
details: `The user associated with the [GitHub token](${linkify(
'README.md#github-authentication'
)}) configured in the \`GH_TOKEN\` or \`GITHUB_TOKEN\` environment variable must allows to push to the repository ${owner}/${repo}.
Expand Down
2 changes: 1 addition & 1 deletion lib/get-fail-comment.js
Expand Up @@ -7,7 +7,7 @@ const NEW_ISSUE_URL = `${HOME_URL}/issues/new`;
const formatError = error => `### ${error.message}
${error.details ||
`Unfortunately this error doesn't have any additional information.${
`Unfortunately this error doesnt have any additional information.${
error.pluginName
? ` Feel free to kindly ask the author of the \`${error.pluginName}\` plugin to add more helpful information.`
: ''
Expand Down
2 changes: 1 addition & 1 deletion lib/success.js
Expand Up @@ -100,7 +100,7 @@ module.exports = async (pluginConfig, context) => {
if (error.status === 403) {
logger.error('Not allowed to add a comment to the issue #%d.', issue.number);
} else if (error.status === 404) {
logger.error("Failed to add a comment to the issue #%d as it doesn't exist.", issue.number);
logger.error('Failed to add a comment to the issue #%d as it doesnt exist.', issue.number);
} else {
errors.push(error);
logger.error('Failed to add a comment to the issue #%d.', issue.number);
Expand Down
22 changes: 12 additions & 10 deletions test/get-client.test.js
Expand Up @@ -27,8 +27,8 @@ test.serial('Use a http proxy', async t => {
serverDestroy(proxy);

const proxyHandler = spy();
const serverHandler = spy((req, res) => {
res.end();
const serverHandler = spy((request, response) => {
response.end();
});
proxy.on('request', proxyHandler);
server.on('request', serverHandler);
Expand Down Expand Up @@ -65,8 +65,8 @@ test.serial('Use a https proxy', async t => {
serverDestroy(proxy);

const proxyHandler = spy();
const serverHandler = spy((req, res) => {
res.end();
const serverHandler = spy((request, response) => {
response.end();
});
proxy.on('connect', proxyHandler);
server.on('request', serverHandler);
Expand Down Expand Up @@ -102,8 +102,9 @@ test('Use the global throttler for all endpoints', async t => {
const b = await github.issues.createComment();
const c = await github.repos.createRelease();
const d = await github.issues.createComment();
const e = await github.search.issuesAndPullRequests();
// Skipping "e" so the XO linter won't complain
const f = await github.search.issuesAndPullRequests();
const g = await github.search.issuesAndPullRequests();

// `issues.createComment` should be called `rate` ms after `repos.createRelease`
t.true(inRange(b - a, rate - 50, rate + 50));
Expand All @@ -112,9 +113,9 @@ test('Use the global throttler for all endpoints', async t => {
// `issues.createComment` should be called `rate` ms after `repos.createRelease`
t.true(inRange(d - c, rate - 50, rate + 50));
// `search.issuesAndPullRequests` should be called `rate` ms after `issues.createComment`
t.true(inRange(e - d, rate - 50, rate + 50));
t.true(inRange(f - d, rate - 50, rate + 50));
// `search.issuesAndPullRequests` should be called `rate` ms after `search.issuesAndPullRequests`
t.true(inRange(f - e, rate - 50, rate + 50));
t.true(inRange(g - f, rate - 50, rate + 50));
});

test('Use the same throttler for endpoints in the same rate limit group', async t => {
Expand All @@ -132,8 +133,9 @@ test('Use the same throttler for endpoints in the same rate limit group', async
const b = await github.issues.createComment();
const c = await github.repos.createRelease();
const d = await github.issues.createComment();
const e = await github.search.issuesAndPullRequests();
// Skipping "e" so the XO linter won't complain
const f = await github.search.issuesAndPullRequests();
const g = await github.search.issuesAndPullRequests();

// `issues.createComment` should be called `coreRate` ms after `repos.createRelease`
t.true(inRange(b - a, coreRate - 50, coreRate + 50));
Expand All @@ -143,9 +145,9 @@ test('Use the same throttler for endpoints in the same rate limit group', async
t.true(inRange(d - c, coreRate - 50, coreRate + 50));

// The first search should be called immediatly as it uses a different throttler
t.true(inRange(e - d, -50, 50));
t.true(inRange(f - d, -50, 50));
// The second search should be called only after `searchRate` ms
t.true(inRange(f - e, searchRate - 50, searchRate + 50));
t.true(inRange(g - f, searchRate - 50, searchRate + 50));
});

test('Use different throttler for read and write endpoints', async t => {
Expand Down
4 changes: 2 additions & 2 deletions test/get-fail-comment.test.js
Expand Up @@ -34,7 +34,7 @@ test('Comment with missing error details and pluginName', t => {
t.regex(comment, /the `master` branch/);
t.regex(
comment,
/---\n\n### Error message 1\n\nUnfortunately this error doesn't have any additional information. Feel free to kindly ask the author of the `some-plugin` plugin to add more helpful information.\n\n---/
/---\n\n### Error message 1\n\nUnfortunately this error doesnt have any additional information. Feel free to kindly ask the author of the `some-plugin` plugin to add more helpful information.\n\n---/
);
});

Expand All @@ -46,6 +46,6 @@ test('Comment with missing error details and no pluginName', t => {
t.regex(comment, /the `master` branch/);
t.regex(
comment,
/---\n\n### Error message 1\n\nUnfortunately this error doesn't have any additional information.\n\n---/
/---\n\n### Error message 1\n\nUnfortunately this error doesnt have any additional information.\n\n---/
);
});
2 changes: 1 addition & 1 deletion test/success.test.js
Expand Up @@ -466,7 +466,7 @@ test.serial('Ignore missing and forbidden issues/PRs', async t => {
t.true(t.context.log.calledWith('Added labels %O to issue #%d', ['released'], 4));
t.true(t.context.log.calledWith('Added comment to issue #%d: %s', 5, 'https://github.com/successcomment-5'));
t.true(t.context.log.calledWith('Added labels %O to issue #%d', ['released'], 5));
t.true(t.context.error.calledWith("Failed to add a comment to the issue #%d as it doesn't exist.", 2));
t.true(t.context.error.calledWith('Failed to add a comment to the issue #%d as it doesnt exist.', 2));
t.true(t.context.error.calledWith('Not allowed to add a comment to the issue #%d.', 3));
t.true(github.isDone());
});
Expand Down
4 changes: 2 additions & 2 deletions test/verify.test.js
Expand Up @@ -403,7 +403,7 @@ test('Throw SemanticReleaseError for invalid repositoryUrl', async t => {
t.is(error.code, 'EINVALIDGITHUBURL');
});

test.serial("Throw SemanticReleaseError if token doesn't have the push permission on the repository", async t => {
test.serial('Throw SemanticReleaseError if token doesnt have the push permission on the repository', async t => {
const owner = 'test_user';
const repo = 'test_repo';
const env = {GH_TOKEN: 'github_token'};
Expand All @@ -421,7 +421,7 @@ test.serial("Throw SemanticReleaseError if token doesn't have the push permissio
t.true(github.isDone());
});

test.serial("Throw SemanticReleaseError if the repository doesn't exist", async t => {
test.serial('Throw SemanticReleaseError if the repository doesnt exist', async t => {
const owner = 'test_user';
const repo = 'test_repo';
const env = {GH_TOKEN: 'github_token'};
Expand Down

0 comments on commit e6726e1

Please sign in to comment.