Skip to content

Commit caa3526

Browse files
committed
style: xo
1 parent ed5f26d commit caa3526

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+351
-351
lines changed

bin/semantic-release.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ execa('git', ['--version'])
2929
process.exit(1);
3030
}
3131
})
32-
.catch(error => {
32+
.catch((error) => {
3333
console.error(`[semantic-release]: Git version ${MIN_GIT_VERSION} is required. No git binary found.`);
3434
console.error(error);
3535
process.exit(1);
3636
});
3737

3838
// Node 10+ from this point on
3939
require('../cli')()
40-
.then(exitCode => {
40+
.then((exitCode) => {
4141
process.exitCode = exitCode;
4242
})
4343
.catch(() => {

cli.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ const hideSensitive = require('./lib/hide-sensitive');
55
const stringList = {
66
type: 'string',
77
array: true,
8-
coerce: values =>
8+
coerce: (values) =>
99
values.length === 1 && values[0].trim() === 'false'
1010
? []
11-
: values.reduce((values, value) => values.concat(value.split(',').map(value => value.trim())), []),
11+
: values.reduce((values, value) => values.concat(value.split(',').map((value) => value.trim())), []),
1212
};
1313

1414
module.exports = async () => {
1515
const cli = require('yargs')
16-
.command('$0', 'Run automated package publishing', yargs => {
16+
.command('$0', 'Run automated package publishing', (yargs) => {
1717
yargs.demandCommand(0, 0).usage(`Run automated package publishing
1818
1919
Usage:

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ async function run(context, plugins) {
214214
}
215215

216216
function logErrors({logger, stderr}, err) {
217-
const errors = extractErrors(err).sort(error => (error.semanticRelease ? -1 : 0));
217+
const errors = extractErrors(err).sort((error) => (error.semanticRelease ? -1 : 0));
218218
for (const error of errors) {
219219
if (error.semanticRelease) {
220220
logger.error(`${error.code} ${error.message}`);
@@ -228,7 +228,7 @@ function logErrors({logger, stderr}, err) {
228228
}
229229

230230
async function callFail(context, plugins, err) {
231-
const errors = extractErrors(err).filter(err => err.semanticRelease);
231+
const errors = extractErrors(err).filter((err) => err.semanticRelease);
232232
if (errors.length > 0) {
233233
try {
234234
await plugins.fail({...context, errors});

lib/branches/expand.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ module.exports = async (repositoryUrl, {cwd}, branches) => {
88
return branches.reduce(
99
(branches, branch) => [
1010
...branches,
11-
...remove(gitBranches, name => micromatch(gitBranches, branch.name).includes(name)).map(name => ({
11+
...remove(gitBranches, (name) => micromatch(gitBranches, branch.name).includes(name)).map((name) => ({
1212
name,
13-
...mapValues(omit(branch, 'name'), value => (isString(value) ? template(value)({name}) : value)),
13+
...mapValues(omit(branch, 'name'), (value) => (isString(value) ? template(value)({name}) : value)),
1414
})),
1515
],
1616
[]

lib/branches/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = async (repositoryUrl, ciBranch, context) => {
1414
const remoteBranches = await expand(
1515
repositoryUrl,
1616
context,
17-
context.options.branches.map(branch => (isString(branch) || isRegExp(branch) ? {name: branch} : branch))
17+
context.options.branches.map((branch) => (isString(branch) || isRegExp(branch) ? {name: branch} : branch))
1818
);
1919

2020
await pEachSeries(remoteBranches, async ({name}) => {
@@ -32,7 +32,7 @@ module.exports = async (repositoryUrl, ciBranch, context) => {
3232
);
3333

3434
const result = Object.entries(DEFINITIONS).reduce((result, [type, {branchesValidator, branchValidator}]) => {
35-
branchesByType[type].forEach(branch => {
35+
branchesByType[type].forEach((branch) => {
3636
if (branchValidator && !branchValidator(branch)) {
3737
errors.push(getError(`E${type.toUpperCase()}BRANCH`, {branch}));
3838
}
@@ -48,15 +48,15 @@ module.exports = async (repositoryUrl, ciBranch, context) => {
4848
}, {});
4949

5050
const duplicates = [...branches]
51-
.map(branch => branch.name)
51+
.map((branch) => branch.name)
5252
.sort()
5353
.filter((_, idx, array) => array[idx] === array[idx + 1] && array[idx] !== array[idx - 1]);
5454

5555
if (duplicates.length > 0) {
5656
errors.push(getError('EDUPLICATEBRANCHES', {duplicates}));
5757
}
5858

59-
await pEachSeries(branches, async branch => {
59+
await pEachSeries(branches, async (branch) => {
6060
if (!(await verifyBranchName(branch.name))) {
6161
errors.push(getError('EINVALIDBRANCHNAME', branch));
6262
}

lib/definitions/branches.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ const {isMaintenanceRange} = require('../utils');
55
const maintenance = {
66
filter: ({name, range}) => (!isNil(range) && range !== false) || isMaintenanceRange(name),
77
branchValidator: ({range}) => (isNil(range) ? true : isMaintenanceRange(range)),
8-
branchesValidator: branches => uniqBy(branches, ({range}) => semver.validRange(range)).length === branches.length,
8+
branchesValidator: (branches) => uniqBy(branches, ({range}) => semver.validRange(range)).length === branches.length,
99
};
1010

1111
const prerelease = {
1212
filter: ({prerelease}) => !isNil(prerelease) && prerelease !== false,
1313
branchValidator: ({name, prerelease}) =>
1414
Boolean(prerelease) && Boolean(semver.valid(`1.0.0-${prerelease === true ? name : prerelease}.1`)),
15-
branchesValidator: branches => uniqBy(branches, 'prerelease').length === branches.length,
15+
branchesValidator: (branches) => uniqBy(branches, 'prerelease').length === branches.length,
1616
};
1717

1818
const release = {
19-
filter: branch => !maintenance.filter(branch) && !prerelease.filter(branch),
20-
branchesValidator: branches => branches.length <= 3 && branches.length > 0,
19+
filter: (branch) => !maintenance.filter(branch) && !prerelease.filter(branch),
20+
branchesValidator: (branches) => branches.length <= 3 && branches.length > 0,
2121
};
2222

2323
module.exports = {maintenance, prerelease, release};

lib/definitions/errors.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ const pkg = require('../../package.json');
44
const {RELEASE_TYPE} = require('./constants');
55

66
const [homepage] = pkg.homepage.split('#');
7-
const stringify = object =>
7+
const stringify = (object) =>
88
isString(object) ? object : inspect(object, {breakLength: Infinity, depth: 2, maxArrayLength: 5});
9-
const linkify = file => `${homepage}/blob/master/${file}`;
10-
const wordsList = words =>
9+
const linkify = (file) => `${homepage}/blob/master/${file}`;
10+
const wordsList = (words) =>
1111
`${words.slice(0, -1).join(', ')}${words.length > 1 ? ` or ${words[words.length - 1]}` : trim(words[0])}`;
1212

1313
module.exports = {
@@ -85,7 +85,7 @@ Please refer to the \`${pluginName}\` and [semantic-release plugins configuratio
8585
EANALYZECOMMITSOUTPUT: ({result, pluginName}) => ({
8686
message: 'The `analyzeCommits` plugin returned an invalid value. It must return a valid semver release type.',
8787
details: `The \`analyzeCommits\` plugin must return a valid [semver](https://semver.org) release type. The valid values are: ${RELEASE_TYPE.map(
88-
type => `\`${type}\``
88+
(type) => `\`${type}\``
8989
).join(', ')}.
9090
9191
The \`analyzeCommits\` function of the \`${pluginName}\` returned \`${stringify(result)}\` instead.

lib/definitions/plugins.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ module.exports = {
1616
default: ['@semantic-release/commit-analyzer'],
1717
required: true,
1818
dryRun: true,
19-
outputValidator: output => !output || RELEASE_TYPE.includes(output),
19+
outputValidator: (output) => !output || RELEASE_TYPE.includes(output),
2020
preprocess: ({commits, ...inputs}) => ({
2121
...inputs,
22-
commits: commits.filter(commit => !/\[skip\s+release]|\[release\s+skip]/i.test(commit.message)),
22+
commits: commits.filter((commit) => !/\[skip\s+release]|\[release\s+skip]/i.test(commit.message)),
2323
}),
24-
postprocess: results =>
24+
postprocess: (results) =>
2525
RELEASE_TYPE[
2626
results.reduce((highest, result) => {
2727
const typeIndex = RELEASE_TYPE.indexOf(result);
@@ -37,7 +37,7 @@ module.exports = {
3737
generateNotes: {
3838
required: false,
3939
dryRun: true,
40-
outputValidator: output => !output || isString(output),
40+
outputValidator: (output) => !output || isString(output),
4141
pipelineConfig: () => ({
4242
getNextInput: ({nextRelease, ...context}, notes) => ({
4343
...context,
@@ -53,7 +53,7 @@ module.exports = {
5353
required: false,
5454
dryRun: false,
5555
pipelineConfig: ({generateNotes}) => ({
56-
getNextInput: async context => {
56+
getNextInput: async (context) => {
5757
const newGitHead = await getGitHead({cwd: context.cwd});
5858
// If previous prepare plugin has created a commit (gitHead changed)
5959
if (context.nextRelease.gitHead !== newGitHead) {
@@ -70,7 +70,7 @@ module.exports = {
7070
publish: {
7171
required: false,
7272
dryRun: false,
73-
outputValidator: output => !output || isPlainObject(output),
73+
outputValidator: (output) => !output || isPlainObject(output),
7474
pipelineConfig: () => ({
7575
// Add `nextRelease` and plugin properties to published release
7676
transform: (release, step, {nextRelease}) => ({
@@ -83,7 +83,7 @@ module.exports = {
8383
addChannel: {
8484
required: false,
8585
dryRun: false,
86-
outputValidator: output => !output || isPlainObject(output),
86+
outputValidator: (output) => !output || isPlainObject(output),
8787
pipelineConfig: () => ({
8888
// Add `nextRelease` and plugin properties to published release
8989
transform: (release, step, {nextRelease}) => ({

lib/get-config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module.exports = async (context, cliOptions) => {
4545
Object.entries(extendsOptions)
4646
.filter(([, value]) => Boolean(value))
4747
.reduce((pluginsPath, [option, value]) => {
48-
castArray(value).forEach(plugin => {
48+
castArray(value).forEach((plugin) => {
4949
if (option === 'plugins' && validatePlugin(plugin)) {
5050
pluginsPath[parseConfig(plugin)[0]] = extendPath;
5151
} else if (
@@ -83,7 +83,7 @@ module.exports = async (context, cliOptions) => {
8383
'@semantic-release/github',
8484
],
8585
// Remove `null` and `undefined` options so they can be replaced with default ones
86-
...pickBy(options, option => !isNil(option)),
86+
...pickBy(options, (option) => !isNil(option)),
8787
...(options.branches ? {branches: castArray(options.branches)} : {}),
8888
};
8989

lib/get-git-auth-url.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module.exports = async ({cwd, env, branch, options: {repositoryUrl}}) => {
4242
try {
4343
await verifyAuth(repositoryUrl, branch.name, {cwd, env});
4444
} catch (_) {
45-
const envVar = Object.keys(GIT_TOKENS).find(envVar => !isNil(env[envVar]));
45+
const envVar = Object.keys(GIT_TOKENS).find((envVar) => !isNil(env[envVar]));
4646
const gitCredentials = `${GIT_TOKENS[envVar] || ''}${env[envVar] || ''}`;
4747

4848
if (gitCredentials) {

lib/get-last-release.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ const {makeTag, isSameChannel} = require('./utils');
2929
module.exports = ({branch, options: {tagFormat}}, {before} = {}) => {
3030
const [{version, gitTag, channels} = {}] = branch.tags
3131
.filter(
32-
tag =>
33-
((branch.type === 'prerelease' && tag.channels.some(channel => isSameChannel(branch.channel, channel))) ||
32+
(tag) =>
33+
((branch.type === 'prerelease' && tag.channels.some((channel) => isSameChannel(branch.channel, channel))) ||
3434
!semver.prerelease(tag.version)) &&
3535
(isUndefined(before) || semver.lt(tag.version, before))
3636
)

lib/get-next-version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = ({branch, nextRelease: {type, channel}, lastRelease, logger}) =
1010
if (branch.type === 'prerelease') {
1111
if (
1212
semver.prerelease(lastRelease.version) &&
13-
lastRelease.channels.some(lastReleaseChannel => isSameChannel(lastReleaseChannel, channel))
13+
lastRelease.channels.some((lastReleaseChannel) => isSameChannel(lastReleaseChannel, channel))
1414
) {
1515
version = highest(
1616
semver.inc(lastRelease.version, 'prerelease'),

lib/get-release-to-add.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const {makeTag, getLowerBound} = require('./utils');
1111
*
1212
* @return {Array<Object>} Last release and next release to be added on the channel of the current branch.
1313
*/
14-
module.exports = context => {
14+
module.exports = (context) => {
1515
const {
1616
branch,
1717
branches,

lib/git.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async function getTagHead(tagName, execaOptions) {
3030
async function getTags(branch, execaOptions) {
3131
return (await execa('git', ['tag', '--merged', branch], execaOptions)).stdout
3232
.split('\n')
33-
.map(tag => tag.trim())
33+
.map((tag) => tag.trim())
3434
.filter(Boolean);
3535
}
3636

@@ -66,7 +66,7 @@ async function getBranches(repositoryUrl, execaOptions) {
6666
return (await execa('git', ['ls-remote', '--heads', repositoryUrl], execaOptions)).stdout
6767
.split('\n')
6868
.filter(Boolean)
69-
.map(branch => branch.match(/^.+refs\/heads\/(?<branch>.+)$/)[1]);
69+
.map((branch) => branch.match(/^.+refs\/heads\/(?<branch>.+)$/)[1]);
7070
}
7171

7272
/**

lib/hide-sensitive.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
const {escapeRegExp, size, isString} = require('lodash');
22
const {SECRET_REPLACEMENT, SECRET_MIN_SIZE} = require('./definitions/constants');
33

4-
module.exports = env => {
4+
module.exports = (env) => {
55
const toReplace = Object.keys(env).filter(
6-
envVar => /token|password|credential|secret|private/i.test(envVar) && size(env[envVar].trim()) >= SECRET_MIN_SIZE
6+
(envVar) => /token|password|credential|secret|private/i.test(envVar) && size(env[envVar].trim()) >= SECRET_MIN_SIZE
77
);
88

9-
const regexp = new RegExp(toReplace.map(envVar => escapeRegExp(env[envVar])).join('|'), 'g');
10-
return output =>
9+
const regexp = new RegExp(toReplace.map((envVar) => escapeRegExp(env[envVar])).join('|'), 'g');
10+
return (output) =>
1111
output && isString(output) && toReplace.length > 0 ? output.toString().replace(regexp, SECRET_REPLACEMENT) : output;
1212
};

lib/plugins/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ module.exports = (context, pluginsPath) => {
5353
} else {
5454
// If an object is passed and the path is missing, merge it with step options
5555
if (isPlainObject(options[type]) && !options[type].path) {
56-
options[type] = castArray(plugins[type]).map(plugin =>
56+
options[type] = castArray(plugins[type]).map((plugin) =>
5757
plugin ? [plugin[0], Object.assign(plugin[1], options[type])] : plugin
5858
);
5959
}
@@ -66,7 +66,7 @@ module.exports = (context, pluginsPath) => {
6666
pluginOptions = options[type];
6767
}
6868

69-
const steps = castArray(pluginOptions).map(pluginOpt =>
69+
const steps = castArray(pluginOptions).map((pluginOpt) =>
7070
normalize(
7171
{...context, options: omit(options, Object.keys(PLUGINS_DEFINITIONS), 'plugins')},
7272
type,
@@ -75,7 +75,7 @@ module.exports = (context, pluginsPath) => {
7575
)
7676
);
7777

78-
pluginsConf[type] = async input =>
78+
pluginsConf[type] = async (input) =>
7979
postprocess(
8080
await pipeline(steps, pipelineConfig && pipelineConfig(pluginsConf, logger))(await preprocess(input)),
8181
input

lib/plugins/normalize.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = (context, type, pluginOpt, pluginsPath) => {
2626
throw getError('EPLUGIN', {type, pluginName});
2727
}
2828

29-
const validator = async input => {
29+
const validator = async (input) => {
3030
const {dryRun, outputValidator} = PLUGINS_DEFINITIONS[type] || {};
3131
try {
3232
if (!input.options.dryRun || dryRun) {
@@ -48,7 +48,7 @@ module.exports = (context, type, pluginOpt, pluginsPath) => {
4848
logger.warn(`Skip step "${type}" of plugin "${pluginName}" in dry-run mode`);
4949
} catch (error) {
5050
logger.error(`Failed step "${type}" of plugin "${pluginName}"`);
51-
extractErrors(error).forEach(err => Object.assign(err, {pluginName}));
51+
extractErrors(error).forEach((err) => Object.assign(err, {pluginName}));
5252
throw error;
5353
}
5454
};

lib/plugins/pipeline.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const {extractErrors} = require('../utils');
2525
*
2626
* @return {Pipeline} A Function that execute the `steps` sequencially
2727
*/
28-
module.exports = (steps, {settleAll = false, getNextInput = identity, transform = identity} = {}) => async input => {
28+
module.exports = (steps, {settleAll = false, getNextInput = identity, transform = identity} = {}) => async (input) => {
2929
const results = [];
3030
const errors = [];
3131
await pReduce(

lib/plugins/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ const {dirname} = require('path');
22
const {isString, isFunction, castArray, isArray, isPlainObject, isNil} = require('lodash');
33
const resolveFrom = require('resolve-from');
44

5-
const validateSteps = conf => {
6-
return conf.every(conf => {
5+
const validateSteps = (conf) => {
6+
return conf.every((conf) => {
77
if (
88
isArray(conf) &&
99
(conf.length === 1 || conf.length === 2) &&

lib/utils.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ function extractErrors(err) {
88

99
function hideSensitiveValues(env, objs) {
1010
const hideFunction = hideSensitive(env);
11-
return objs.map(object => {
12-
Object.getOwnPropertyNames(object).forEach(prop => {
11+
return objs.map((object) => {
12+
Object.getOwnPropertyNames(object).forEach((prop) => {
1313
if (object[prop]) {
1414
object[prop] = hideFunction(object[prop]);
1515
}
@@ -49,17 +49,17 @@ function lowest(version1, version2) {
4949
}
5050

5151
function getLatestVersion(versions, {withPrerelease} = {}) {
52-
return versions.filter(version => withPrerelease || !semver.prerelease(version)).sort(semver.rcompare)[0];
52+
return versions.filter((version) => withPrerelease || !semver.prerelease(version)).sort(semver.rcompare)[0];
5353
}
5454

5555
function getEarliestVersion(versions, {withPrerelease} = {}) {
56-
return versions.filter(version => withPrerelease || !semver.prerelease(version)).sort(semver.compare)[0];
56+
return versions.filter((version) => withPrerelease || !semver.prerelease(version)).sort(semver.compare)[0];
5757
}
5858

5959
function getFirstVersion(versions, lowerBranches) {
6060
const lowerVersion = union(...lowerBranches.map(({tags}) => tagsToVersions(tags))).sort(semver.rcompare);
6161
if (lowerVersion[0]) {
62-
return versions.sort(semver.compare).find(version => semver.gt(version, lowerVersion[0]));
62+
return versions.sort(semver.compare).find((version) => semver.gt(version, lowerVersion[0]));
6363
}
6464

6565
return getEarliestVersion(versions);

0 commit comments

Comments
 (0)