Skip to content

Commit

Permalink
Configure prettier and eslint-config-standard (#1123)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmelnikow authored Oct 9, 2017
1 parent c3636e7 commit 2809ff6
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 12 deletions.
27 changes: 18 additions & 9 deletions .eslintrc-preferred.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
# plugins:
# - "prettier"

extends:
- "standard"
- "prettier"

parserOptions:
# Override eslint-config-standard, which incorrectly sets this to "module",
# though that setting is only for ES6 modules, not CommonJS modules.
sourceType: "script"

rules:
# From eslint-config-standard.
arrow-spacing: ["error", { "before": true, "after": true }]
brace-style: ["error", "1tbs", { "allowSingleLine": true }]
camelcase: ["error", { "properties": "never" }]
func-style: ["error", "declaration", { "allowArrowFunctions": true }]
indent: ["error", 2, { "SwitchCase": 1 }]
key-spacing: ["error", { "beforeColon": false, "afterColon": true }]
no-trailing-spaces: "error"
quotes: ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }]
# prettier/prettier: "error"

# These are not disabled by eslint-config-prettier
spaced-comment: "off"
standard/object-curly-even-spacing: "off"
one-var: "off"

# Shields additions.
no-var: "error"
Expand Down
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
server.js
server.spec.js
gh-badge.js
gh-badge.spec.js
3 changes: 3 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
singleQuote: true
trailingComma: es5
bracketSpacing: true
1 change: 1 addition & 0 deletions lib/badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ function makeImage(data, cb) {
try {
result = template(data);
} catch(e) {
// eslint-disable-next-line standard/no-callback-literal
cb('', e);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/github-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function mapGithubCommitsSince(camp, githubApiUrl, githubAuth) {

//Github Release & Pre-Release Date Integration release-date-pre (?:\/(all))?
function mapGithubReleaseDate(camp, githubApiUrl, githubAuth) {
camp.route(/^\/github\/(release-date|release-date-pre)\/([^\/]+)\/([^\/]+)\.(svg|png|gif|jpg|json)$/,
camp.route(/^\/github\/(release-date|release-date-pre)\/([^/]+)\/([^/]+)\.(svg|png|gif|jpg|json)$/,
cache(function (data, match, sendBadge, request) {
const releaseType = match[1]; // eg, release-date-pre / release-date
const user = match[2]; // eg, microsoft
Expand Down
1 change: 1 addition & 0 deletions lib/request-handler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

// eslint-disable-next-line node/no-deprecated-api
const domain = require('domain');
const request = require('request');
const badge = require('./badge');
Expand Down
2 changes: 2 additions & 0 deletions lib/suggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ function findSuggestions (url, cb) {
}
promises.push(twitterPage(url));
Promise.all(promises).then(function(badges) {
// eslint-disable-next-line standard/no-callback-literal
cb({badges: badges.filter(function(b) { return b != null; })});
}).catch(function(err) {
// eslint-disable-next-line standard/no-callback-literal
cb({badges: [], err: err});
});
}
Expand Down
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@
"child-process-promise": "^2.2.1",
"dejavu-fonts-ttf": "^2.37.3",
"eslint": "^3.18.0",
"eslint-config-prettier": "^2.6.0",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-prettier": "^2.3.1",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1",
"glob": "^7.1.1",
"icedfrisby": "^1.2.0",
"icedfrisby-nock": "^1.0.0",
Expand All @@ -81,6 +88,7 @@
"nock": "^9.0.13",
"node-fetch": "^1.6.3",
"opn-cli": "^3.1.0",
"prettier": "1.7.3",
"read-all-stdin-sync": "^1.0.5",
"sinon": "^2.1.0"
},
Expand Down
2 changes: 1 addition & 1 deletion service-tests/bower.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Joi = require('joi');
const ServiceTester = require('./runner/service-tester');
const { isVPlusDottedVersionAtLeastOne } = require('./helpers/validators');

const isBowerPrereleaseVersion = Joi.string().regex(/^v\d+(\.\d+)?(\.\d+)?(\-?\w)+?$/);
const isBowerPrereleaseVersion = Joi.string().regex(/^v\d+(\.\d+)?(\.\d+)?(-?\w)+?$/);

const t = new ServiceTester({ id: 'bower', title: 'Bower' });
module.exports = t;
Expand Down
2 changes: 1 addition & 1 deletion service-tests/helpers/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const isStarRating = withRegex(/^[\u2605\u2606]{5}$/);

const isMetric = withRegex(/^[0-9]+[kMGTPEZY]?$/);

const isPercentage = withRegex(/^[0-9]+\%$/);
const isPercentage = withRegex(/^[0-9]+%$/);

const isFileSize = withRegex(/^[0-9]*[.]?[0-9]+\s(B|kB|MB|GB|TB|PB|EB|ZB|YB)$/);

Expand Down

0 comments on commit 2809ff6

Please sign in to comment.