diff --git a/cli.js b/cli.js
index 16172e1..afa4eb4 100755
--- a/cli.js
+++ b/cli.js
@@ -1,4 +1,5 @@
#!/usr/bin/env node
+/* eslint-disable no-console */
'use strict';
var fs = require('fs');
@@ -23,7 +24,7 @@ var argv = require('yargs')
.default('contributorsPerLine', 7)
.default('contributors', [])
.default('config', defaultRCFile)
- .config('config', function(configPath) {
+ .config('config', function (configPath) {
try {
return JSON.parse(fs.readFileSync(configPath, 'utf-8'));
} catch (error) {
@@ -37,11 +38,11 @@ var argv = require('yargs')
function startGeneration(argv, cb) {
argv.files
- .map(function(file) {
+ .map(function (file) {
return path.join(cwd, file);
})
- .forEach(function(file) {
- markdown.read(file, function(error, fileContent) {
+ .forEach(function (file) {
+ markdown.read(file, function (error, fileContent) {
if (error) {
return cb(error);
}
@@ -65,7 +66,7 @@ if (command === 'generate') {
var username = argv._[1];
var contributions = argv._[2];
// Add or update contributor in the config file
- updateContributors(argv, username, contributions, function(error, contributors) {
+ updateContributors(argv, username, contributions, function (error, contributors) {
if (error) {
return onError(error);
}
diff --git a/lib/configFile.js b/lib/configFile.js
index b7fd978..67da1fc 100644
--- a/lib/configFile.js
+++ b/lib/configFile.js
@@ -7,10 +7,10 @@ function formatCommaFirst(o) {
return JSON.stringify(o, null, 2)
.split(/(,\n\s+)/)
.map(function (e, i) {
- return i % 2 ? '\n' + e.substring(4) + ', ' : e
+ return i % 2 ? '\n' + e.substring(4) + ', ' : e;
})
- .join('')
- + '\n';
+ .join('') +
+ '\n';
}
function readConfig(configPath) {
@@ -19,11 +19,11 @@ function readConfig(configPath) {
function writeContributors(configPath, contributors, cb) {
var config = readConfig(configPath);
- var content = _.assign(config, { contributors: contributors });
+ var content = _.assign(config, {contributors: contributors});
return fs.writeFile(configPath, formatCommaFirst(content), cb);
}
module.exports = {
readConfig: readConfig,
writeContributors: writeContributors
-}
+};
diff --git a/lib/contributors/add.js b/lib/contributors/add.js
index e86f5f0..a5ddc53 100644
--- a/lib/contributors/add.js
+++ b/lib/contributors/add.js
@@ -2,12 +2,6 @@
var _ = require('lodash/fp');
-function matchContribution(type) {
- return function(existing) {
- return type === existing || type === existing.type;
- };
-}
-
function uniqueTypes(contribution) {
return contribution.type || contribution;
}
@@ -15,11 +9,11 @@ function uniqueTypes(contribution) {
function formatContributions(options, existing, newTypes) {
var types = newTypes.split(',');
if (options.url) {
- return (existing ||Β []).concat(types.map(function(type) {
- return { type: type, url: options.url };
+ return (existing || []).concat(types.map(function (type) {
+ return {type: type, url: options.url};
}));
}
- return _.uniqBy(uniqueTypes, (existing ||Β []).concat(types));
+ return _.uniqBy(uniqueTypes, (existing || []).concat(types));
}
function updateContributor(options, contributor, contributions) {
@@ -29,7 +23,7 @@ function updateContributor(options, contributor, contributions) {
}
function updateExistingContributor(options, username, contributions) {
- return options.contributors.map(function(contributor, index) {
+ return options.contributors.map(function (contributor) {
if (username !== contributor.login) {
return contributor;
}
@@ -38,7 +32,7 @@ function updateExistingContributor(options, username, contributions) {
}
function addNewContributor(options, username, contributions, infoFetcher, cb) {
- infoFetcher(username, function(error, userData) {
+ infoFetcher(username, function (error, userData) {
if (error) {
return cb(error);
}
@@ -54,4 +48,4 @@ module.exports = function addContributor(options, username, contributions, infoF
return cb(null, updateExistingContributor(options, username, contributions));
}
return addNewContributor(options, username, contributions, infoFetcher, cb);
-}
+};
diff --git a/lib/contributors/add.test.js b/lib/contributors/add.test.js
index a8b2b85..d44d05d 100644
--- a/lib/contributors/add.test.js
+++ b/lib/contributors/add.test.js
@@ -26,7 +26,7 @@ function fixtures() {
avatar_url: 'www.avatar.url',
profile: 'www.profile.url',
contributions: [
- { type: 'blog', url: 'www.blog.url/path' },
+ {type: 'blog', url: 'www.blog.url/path'},
'code'
]
}]
@@ -42,7 +42,7 @@ test.cb('should callback with error if infoFetcher fails', t => {
return cb(new Error('infoFetcher error'));
}
- return addContributor(options, username, contributions, infoFetcher, function(error) {
+ return addContributor(options, username, contributions, infoFetcher, function (error) {
t.is(error.message, 'infoFetcher error');
t.end();
});
@@ -53,7 +53,7 @@ test.cb('should add new contributor at the end of the list of contributors', t =
const username = 'login3';
const contributions = 'doc';
- return addContributor(options, username, contributions, mockInfoFetcher, function(error, contributors) {
+ return addContributor(options, username, contributions, mockInfoFetcher, function (error, contributors) {
t.notOk(error);
t.is(contributors.length, 3);
t.same(contributors[2], {
@@ -75,7 +75,7 @@ test.cb('should add new contributor at the end of the list of contributors with
const contributions = 'doc';
options.url = 'www.foo.bar';
- return addContributor(options, username, contributions, mockInfoFetcher, function(error, contributors) {
+ return addContributor(options, username, contributions, mockInfoFetcher, function (error, contributors) {
t.notOk(error);
t.is(contributors.length, 3);
t.same(contributors[2], {
@@ -84,7 +84,7 @@ test.cb('should add new contributor at the end of the list of contributors with
avatar_url: 'www.avatar.url',
profile: 'www.profile.url',
contributions: [
- { type: 'doc', url: 'www.foo.bar' }
+ {type: 'doc', url: 'www.foo.bar'}
]
});
t.end();
@@ -96,7 +96,7 @@ test.cb(`should not update an existing contributor's contributions where nothing
const username = 'login2';
const contributions = 'blog,code';
- return addContributor(options, username, contributions, mockInfoFetcher, function(error, contributors) {
+ return addContributor(options, username, contributions, mockInfoFetcher, function (error, contributors) {
t.notOk(error);
t.same(contributors, options.contributors);
t.end();
@@ -108,7 +108,7 @@ test.cb(`should update an existing contributor's contributions if a new type is
const username = 'login1';
const contributions = 'bug';
- return addContributor(options, username, contributions, mockInfoFetcher, function(error, contributors) {
+ return addContributor(options, username, contributions, mockInfoFetcher, function (error, contributors) {
t.notOk(error);
t.is(contributors.length, 2);
t.same(contributors[0], {
@@ -131,7 +131,7 @@ test.cb(`should update an existing contributor's contributions if a new type is
const contributions = 'bug';
options.url = 'www.foo.bar';
- return addContributor(options, username, contributions, mockInfoFetcher, function(error, contributors) {
+ return addContributor(options, username, contributions, mockInfoFetcher, function (error, contributors) {
t.notOk(error);
t.is(contributors.length, 2);
t.same(contributors[0], {
@@ -141,7 +141,7 @@ test.cb(`should update an existing contributor's contributions if a new type is
profile: 'www.profile.url',
contributions: [
'code',
- { type: 'bug', url: 'www.foo.bar' },
+ {type: 'bug', url: 'www.foo.bar'}
]
});
t.end();
diff --git a/lib/contributors/github.js b/lib/contributors/github.js
index 69a2bf2..06471bc 100644
--- a/lib/contributors/github.js
+++ b/lib/contributors/github.js
@@ -1,6 +1,5 @@
'use strict';
-var _ = require('lodash/fp');
var request = require('request');
module.exports = function getUserInfo(username, cb) {
@@ -9,7 +8,7 @@ module.exports = function getUserInfo(username, cb) {
headers: {
'User-Agent': 'request'
}
- }, function(error, res) {
+ }, function (error, res) {
if (error) {
return cb(error);
}
@@ -22,4 +21,4 @@ module.exports = function getUserInfo(username, cb) {
};
return cb(null, user);
});
-}
+};
diff --git a/lib/contributors/index.js b/lib/contributors/index.js
index 3dd5430..1dc6acd 100644
--- a/lib/contributors/index.js
+++ b/lib/contributors/index.js
@@ -5,11 +5,11 @@ var github = require('./github');
var configFile = require('../configFile');
module.exports = function addContributor(options, username, contributions, cb) {
- add(options, username, contributions, github, function(error, contributors) {
+ add(options, username, contributions, github, function (error, contributors) {
if (error) {
return cb(error);
}
- configFile.writeContributors(options.config, contributors, function(error) {
+ configFile.writeContributors(options.config, contributors, function (error) {
return cb(error, contributors);
});
});
diff --git a/lib/generate/formatBadge.js b/lib/generate/formatBadge.js
index 0a3cd4a..4f38df5 100644
--- a/lib/generate/formatBadge.js
+++ b/lib/generate/formatBadge.js
@@ -5,7 +5,7 @@ var _ = require('lodash/fp');
var defaultTemplate = '[![All Contributors](https://img.shields.io/badge/all_contributors-<%= contributors.length %>-orange.svg?style=flat-square)](#contributors)';
module.exports = function formatBadge(options, contributors) {
- return _.template(options.badgeTemplate ||Β defaultTemplate)({
+ return _.template(options.badgeTemplate || defaultTemplate)({
contributors: contributors
});
};
diff --git a/lib/generate/formatBadge.test.js b/lib/generate/formatBadge.test.js
index 9cf913e..17ccd24 100644
--- a/lib/generate/formatBadge.test.js
+++ b/lib/generate/formatBadge.test.js
@@ -2,15 +2,6 @@ import test from 'ava';
import _ from 'lodash/fp';
import formatBadge from './formatBadge';
-const fixtures = () => {
- const options = {
- projectOwner: 'jfmengels',
- projectName: 'all-contributors-cli',
- imageSize: 100
- };
- return {options};
-}
-
test('should return badge with the number of contributors', t => {
const options = {};
const expected8 =
diff --git a/lib/generate/formatContributionType.js b/lib/generate/formatContributionType.js
index 322c997..1f3c8a1 100644
--- a/lib/generate/formatContributionType.js
+++ b/lib/generate/formatContributionType.js
@@ -2,12 +2,12 @@
var _ = require('lodash/fp');
-var linkToCommits = 'https://github.com/<%= options.projectOwner %>/<%= options.projectName %>/commits?author=<%= contributor.login %>'
+var linkToCommits = 'https://github.com/<%= options.projectOwner %>/<%= options.projectName %>/commits?author=<%= contributor.login %>';
var linkToIssues = 'https://github.com/<%= options.projectOwner %>/<%= options.projectName %>/issues?q=author%3A<%= contributor.login %>';
var linkTemplate = _.template('[<%= symbol %>](<%= url %>)');
var defaultTypes = {
- blog: { symbol: 'π' },
+ blog: {symbol: 'π'},
bug: {
symbol: 'π',
link: linkToIssues
@@ -16,24 +16,24 @@ var defaultTypes = {
symbol: 'π»',
link: linkToCommits
},
- design: { symbol: 'π¨' },
+ design: {symbol: 'π¨'},
doc: {
symbol: 'π',
link: linkToCommits
},
- example: { symbol: 'π‘' },
- plugin: { symbol: 'π' },
- question: { symbol: 'β' },
- review: { symbol: 'π' },
- talk: { symbol: 'π’' },
+ example: {symbol: 'π‘'},
+ plugin: {symbol: 'π'},
+ question: {symbol: 'β'},
+ review: {symbol: 'π'},
+ talk: {symbol: 'π’'},
test: {
symbol: 'β οΈ',
link: linkToCommits
},
- translation: { symbol: 'π' },
- tool: { symbol: 'π§' },
- tutorial: { symbol: 'β
' },
- video: { symbol: 'πΉ' }
+ translation: {symbol: 'π'},
+ tool: {symbol: 'π§'},
+ tutorial: {symbol: 'β
'},
+ video: {symbol: 'πΉ'}
};
function getType(options, contribution) {
diff --git a/lib/generate/formatContributionType.test.js b/lib/generate/formatContributionType.test.js
index 1afa401..8e31d2f 100644
--- a/lib/generate/formatContributionType.test.js
+++ b/lib/generate/formatContributionType.test.js
@@ -9,7 +9,7 @@ const fixtures = () => {
imageSize: 100
};
return {options};
-}
+};
test('should return corresponding symbol', t => {
const contributor = contributors.kentcdodds;
@@ -63,7 +63,7 @@ test('should be able to add types to the symbol list', t => {
const contributor = contributors.kentcdodds;
const {options} = fixtures();
options.types = {
- cheerful: { symbol: ':smiley:' }
+ cheerful: {symbol: ':smiley:'}
};
t.is(formatContributionType(options, contributor, 'cheerful'), ':smiley:');
@@ -90,7 +90,7 @@ test('should be able to override existing types', t => {
const contributor = contributors.kentcdodds;
const {options} = fixtures();
options.types = {
- code: { symbol: ':smiley:' }
+ code: {symbol: ':smiley:'}
};
t.is(formatContributionType(options, contributor, 'code'), ':smiley:');
diff --git a/lib/generate/formatContributor.js b/lib/generate/formatContributor.js
index 4da0de8..469c549 100644
--- a/lib/generate/formatContributor.js
+++ b/lib/generate/formatContributor.js
@@ -10,8 +10,8 @@ var contributorTemplate = _.template('<%= avatarBlock %>
<%= contributions
function defaultTemplate(templateData) {
var avatar = avatarTemplate(templateData);
- var avatarBlock = avatarBlockTemplate(_.assign({ avatar: avatar }, templateData));
- return contributorTemplate(_.assign({ avatarBlock: avatarBlock }, templateData));
+ var avatarBlock = avatarBlockTemplate(_.assign({avatar: avatar}, templateData));
+ return contributorTemplate(_.assign({avatarBlock: avatarBlock}, templateData));
}
function updateAvatarUrl(options, contributor) {
@@ -20,7 +20,6 @@ function updateAvatarUrl(options, contributor) {
return _.assign(contributor, {
avatar_url: avatarUrl + paramJoiner + 's=' + options.imageSize
});
- '<%= contributor.avatar_url %>?s=<%= options.imageSize %>'
}
module.exports = function formatContributor(options, contributor) {
diff --git a/lib/generate/formatContributor.test.js b/lib/generate/formatContributor.test.js
index 025df8b..04c61b0 100644
--- a/lib/generate/formatContributor.test.js
+++ b/lib/generate/formatContributor.test.js
@@ -13,7 +13,7 @@ function fixtures() {
}
test('should format a simple contributor', t => {
- const contributor = _.assign(contributors.kentcdodds, { contributions: ['review'] });
+ const contributor = _.assign(contributors.kentcdodds, {contributions: ['review']});
const {options} = fixtures();
const expected = '[![Kent C. Dodds](https://avatars1.githubusercontent.com/u/1500684?s=100)
Kent C. Dodds](http://kentcdodds.com)
π';
@@ -33,7 +33,7 @@ test('should format contributor with complex contribution types', t => {
test('should format contributor using custom template', t => {
const contributor = contributors.kentcdodds;
const {options} = fixtures();
- options.contributorTemplate = '<%= contributor.name %> is awesome!'
+ options.contributorTemplate = '<%= contributor.name %> is awesome!';
const expected = 'Kent C. Dodds is awesome!';
@@ -43,7 +43,7 @@ test('should format contributor using custom template', t => {
test('should add image size to url', t => {
const {options} = fixtures();
const contributor = contributors.kentcdodds;
- options.contributorTemplate = '<%= contributor.name %> at <%= contributor.avatar_url %>'
+ options.contributorTemplate = '<%= contributor.name %> at <%= contributor.avatar_url %>';
var contributionWithoutQuestionMarkUrl = _.assign(contributor, {
avatar_url: 'www.some-url-without-question-mark.com'
diff --git a/lib/generate/index.js b/lib/generate/index.js
index 80c20b0..9a0bf8a 100644
--- a/lib/generate/index.js
+++ b/lib/generate/index.js
@@ -12,7 +12,7 @@ function injectContentBetween(lines, content, startIndex, endIndex) {
);
}
-var injectBetweenTags = _.curry(function(tag, newContent, previousContent) {
+var injectBetweenTags = _.curry(function (tag, newContent, previousContent) {
var lines = previousContent.split('\n');
var openingTagIndex = _.findIndex(_.startsWith('