Skip to content

Commit

Permalink
Merge pull request #23 from flo-sch/greenkeeper/xo-0.29.0
Browse files Browse the repository at this point in the history
Update xo to the latest version 🚀
  • Loading branch information
flo-sch authored Apr 11, 2020
2 parents e97a473 + 2043ab7 commit 754db1c
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions lib/get-contributors-from-commits.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const {chain} = require('lodash');

module.exports = function(commits = []) {
module.exports = function (commits = []) {
return chain(commits)
.map(commit => commit.author)
.map((commit) => commit.author)
.sortBy('date')
.map(({email, name}) => ({email, name}))
.uniqBy('email')
Expand Down
4 changes: 2 additions & 2 deletions lib/merge-contributors.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const {chain, concat} = require('lodash');
const parseAuthor = require('parse-author');

const parseContributor = function(contributor) {
const parseContributor = function (contributor) {
return typeof contributor === 'string' ? parseAuthor(contributor) : contributor;
};

module.exports = function(packageContributors = [], commitsContributors = []) {
module.exports = function (packageContributors = [], commitsContributors = []) {
return chain(concat(packageContributors.map(parseContributor), commitsContributors.map(parseContributor)))
.uniqBy('email')
.value();
Expand Down
2 changes: 1 addition & 1 deletion lib/save-contributors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fs = require('fs-extra');
const stringifyAuthor = require('stringify-author');
const mergeContributors = require('./merge-contributors');

module.exports = async function(packageFilePath, contributors = [], format = 'string', logger = undefined) {
module.exports = async function (packageFilePath, contributors = [], format = 'string', logger = undefined) {
const pkg = await fs.readJson(packageFilePath);

let allContributors = mergeContributors(pkg.contributors, contributors);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@
"husky": "^4.2.3",
"lint-staged": "^10.0.3",
"nyc": "^14.1.1",
"prettier": "^1.18.2",
"prettier": "^2.0.4",
"semantic-release": "^17.0.4",
"sinon": "^7.4.1",
"tempy": "^0.3.0",
"xo": "^0.28.3"
"xo": "^0.29.0"
},
"peerDependencies": {
"semantic-release": ">=17.0.4 <18.0.0"
Expand Down
10 changes: 5 additions & 5 deletions test/get-contributors-from-commits.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from 'ava';
import {stub} from 'sinon';
import getContributors from '../lib/get-contributors-from-commits';

test.beforeEach(t => {
test.beforeEach((t) => {
// Stub the logger functions
const log = stub();
t.context.log = log;
Expand All @@ -16,13 +16,13 @@ test.beforeEach(t => {
};
});

test('Extract an empty list if the commit list is empty', t => {
test('Extract an empty list if the commit list is empty', (t) => {
const contributors = getContributors();

t.is(contributors.length, 0);
});

test('Extract a list of contributors from a commits list', t => {
test('Extract a list of contributors from a commits list', (t) => {
const firstCommiterName = 'John Doe';
const secondCommiterEmail = 'john.smith@domain.tld';

Expand All @@ -48,7 +48,7 @@ test('Extract a list of contributors from a commits list', t => {
t.is(contributors[1].email, secondCommiterEmail);
});

test('Removes duplicates email from the commiters list', t => {
test('Removes duplicates email from the commiters list', (t) => {
const name = 'John Doe';
const email = 'john.doe@domain.tld';

Expand Down Expand Up @@ -77,5 +77,5 @@ test('Removes duplicates email from the commiters list', t => {
]);

t.is(contributors.length, 2);
t.is(contributors.filter(contributor => contributor.email === email).length, 1);
t.is(contributors.filter((contributor) => contributor.email === email).length, 1);
});
10 changes: 5 additions & 5 deletions test/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {outputJson, readJson} from 'fs-extra';
import {spy} from 'sinon';
import tempy from 'tempy';

test.beforeEach(t => {
test.beforeEach((t) => {
t.context.m = require('..');

const log = spy();
Expand All @@ -19,7 +19,7 @@ test.beforeEach(t => {
};
});

test('Throws an error if package.json is not provided', async t => {
test('Throws an error if package.json is not provided', async (t) => {
await t.throwsAsync(
t.context.m.prepare(
{
Expand All @@ -33,7 +33,7 @@ test('Throws an error if package.json is not provided', async t => {
);
});

test('Do not change the list if there is no new commit', async t => {
test('Do not change the list if there is no new commit', async (t) => {
const cwd = tempy.directory();
const filepath = path.resolve(cwd, 'package.json');
const email = 'john.doe@domain.tld';
Expand Down Expand Up @@ -68,7 +68,7 @@ test('Do not change the list if there is no new commit', async t => {
t.is(pkg.contributors[0].email, email);
});

test('Update the list of contributors', async t => {
test('Update the list of contributors', async (t) => {
const cwd = tempy.directory();
const filepath = path.resolve(cwd, 'package.json');
const email = 'john.doe@domain.tld';
Expand Down Expand Up @@ -109,7 +109,7 @@ test('Update the list of contributors', async t => {
t.is(typeof pkg.contributors[1], 'string');
});

test('Works in a sub-directory', async t => {
test('Works in a sub-directory', async (t) => {
const cwd = tempy.directory();
const filepath = path.resolve(cwd, 'dist/package.json');
const email = 'john.doe@domain.tld';
Expand Down
14 changes: 7 additions & 7 deletions test/merge-contributors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from 'ava';
import {stub} from 'sinon';
import mergeContributors from '../lib/merge-contributors';

test.beforeEach(t => {
test.beforeEach((t) => {
// Stub the logger functions
const log = stub();
t.context.log = log;
Expand All @@ -16,13 +16,13 @@ test.beforeEach(t => {
};
});

test('Merge empty arrays into one', t => {
test('Merge empty arrays into one', (t) => {
const mergedContributors = mergeContributors();

t.is(mergedContributors.length, 0);
});

test('Merge arrays of contributors', t => {
test('Merge arrays of contributors', (t) => {
const name = 'John Doe';
const email = 'john.smith@domain.tld';
const mergedContributors = mergeContributors(
Expand All @@ -45,7 +45,7 @@ test('Merge arrays of contributors', t => {
t.is(mergedContributors[1].email, email);
});

test('Removes duplicated emails', t => {
test('Removes duplicated emails', (t) => {
const email = 'john.smith@domain.tld';
const mergedContributors = mergeContributors(
[
Expand All @@ -71,10 +71,10 @@ test('Removes duplicated emails', t => {
);

t.is(mergedContributors.length, 2);
t.is(mergedContributors.filter(contributor => contributor.email === email).length, 1);
t.is(mergedContributors.filter((contributor) => contributor.email === email).length, 1);
});

test('Works with strings and objects', t => {
test('Works with strings and objects', (t) => {
const email = 'john.smith@domain.tld';
const mergedContributors = mergeContributors(
[
Expand All @@ -94,5 +94,5 @@ test('Works with strings and objects', t => {
);

t.is(mergedContributors.length, 3);
t.is(mergedContributors.filter(contributor => contributor.email === email).length, 1);
t.is(mergedContributors.filter((contributor) => contributor.email === email).length, 1);
});
10 changes: 5 additions & 5 deletions test/save-contributors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import tempy from 'tempy';
import {outputJson, readJson} from 'fs-extra';
import saveContributors from '../lib/save-contributors';

test.beforeEach(t => {
test.beforeEach((t) => {
// Stub the logger functions
const log = stub();
t.context.log = log;
Expand All @@ -19,21 +19,21 @@ test.beforeEach(t => {
};
});

test('Throw an error if the package file path is undefined', async t => {
test('Throw an error if the package file path is undefined', async (t) => {
await t.throwsAsync(async () => {
await saveContributors(undefined);
});
});

test('Throw an error if the package file does not exists', async t => {
test('Throw an error if the package file does not exists', async (t) => {
const error = await t.throwsAsync(async () => {
await saveContributors('not-existing-file.json');
});
t.is(error.code, 'ENOENT');
t.regex(error.message, /no such file or directory/i);
});

test('Save an updated list of contributors in "string" format', async t => {
test('Save an updated list of contributors in "string" format', async (t) => {
const cwd = tempy.directory();
const filepath = path.resolve(cwd, 'package.json');
const email = 'john.smith@domain.tld';
Expand Down Expand Up @@ -69,7 +69,7 @@ test('Save an updated list of contributors in "string" format', async t => {
t.is(typeof pkg.contributors[1], 'string');
});

test('Save an updated list of contributors in "object" format', async t => {
test('Save an updated list of contributors in "object" format', async (t) => {
const cwd = tempy.directory();
const filepath = path.resolve(cwd, 'package.json');
const email = 'john.doe@domain.tld';
Expand Down

0 comments on commit 754db1c

Please sign in to comment.