diff --git a/.eslintrc-frontend.yml b/.eslintrc-frontend.yml
index 9cec4789c3513..7fcc1ead4807a 100644
--- a/.eslintrc-frontend.yml
+++ b/.eslintrc-frontend.yml
@@ -9,7 +9,7 @@ parserOptions:
extends:
- "standard-jsx"
- "standard-react"
- - "./.eslintrc-preferred.yml"
+ - "./.eslintrc.yml"
settings:
react:
diff --git a/.eslintrc-preferred.yml b/.eslintrc-preferred.yml
deleted file mode 100644
index f08d82881046f..0000000000000
--- a/.eslintrc-preferred.yml
+++ /dev/null
@@ -1,29 +0,0 @@
-plugins:
- - "chai-friendly"
-
-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:
- # 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"
- prefer-const: "error"
- strict: "error"
- arrow-body-style: ["error", "as-needed"]
-
- # Chai friendly.
- no-unused-expressions: "off"
- chai-friendly/no-unused-expressions: "error"
-
- mocha/prefer-arrow-callback: "error"
diff --git a/.eslintrc.yml b/.eslintrc.yml
index 6a09b28ea259f..240cf97eaf3ce 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -1,19 +1,19 @@
-parserOptions:
- ecmaVersion: 8
+extends:
+ - standard
+ - prettier
env:
node: true
- # We use Promise, Map, and occasional ES6 syntax.
- es6: true
mocha: true
+parserOptions:
+ # Override eslint-config-standard, which incorrectly sets this to "module",
+ # though that setting is only for ES6 modules, not CommonJS modules.
+ sourceType: "script"
+
plugins:
- mocha
-
-extends:
- # Enable a set of unopinionated, style-agnostic rules which cover many
- # likely errors.
- - "eslint:recommended"
+ - "chai-friendly"
rules:
# Disable some rules from eslint:recommended.
@@ -23,14 +23,22 @@ rules:
# what the functions are doing.
no-unused-vars: ["error", {"args": "none"}]
- # We use semicolons.
- semi: ["error", "always"]
+ # These should be disabled by eslint-config-prettier, but are not.
+ spaced-comment: "off"
+ standard/object-curly-even-spacing: "off"
+ one-var: "off"
- # We keep whitespace cleaned up.
- no-trailing-spaces: "error"
- eol-last: "error"
- object-curly-spacing: ["error", "always"]
- comma-dangle: ["error", "always-multiline"]
+ # Shields additions.
+ no-var: "error"
+ prefer-const: "error"
+ strict: "error"
+ arrow-body-style: ["error", "as-needed"]
+ # Mocha-related.
mocha/no-exclusive-tests: "error"
mocha/no-mocha-arrows: "error"
+ mocha/prefer-arrow-callback: "error"
+
+ # Chai friendly.
+ no-unused-expressions: "off"
+ chai-friendly/no-unused-expressions: "error"
diff --git a/dangerfile.js b/dangerfile.js
index d2f8f934727fe..4722810c502e3 100644
--- a/dangerfile.js
+++ b/dangerfile.js
@@ -1,3 +1,5 @@
+'use strict'
+
// Have you identified a contributing guideline that should be included here?
// Please open a pull request!
//
@@ -43,7 +45,7 @@ message([
`@${danger.github.pr.user.login}!`,
].join(''));
-if (targetBranch != 'master') {
+if (targetBranch !== 'master') {
const message = `This PR targets \`${targetBranch}\``;
const idea = 'It is likely that the target branch should be `master`';
warn(`${message} - ${idea}`);
@@ -99,10 +101,10 @@ if (capitals.created || underscores.created) {
].join(''));
}
-const all_files = danger.git.created_files.concat(danger.git.modified_files);
+const allFiles = danger.git.created_files.concat(danger.git.modified_files);
-all_files.forEach(function(file) {
- danger.git.diffForFile(file).then(function(diff) {
+allFiles.forEach(file => {
+ danger.git.diffForFile(file).then(diff => {
if (/\+.*assert[(.]/.test(diff.diff)) {
warn([
`Found 'assert' statement added in \`${file}\`.
`,
@@ -117,23 +119,23 @@ function onlyUnique(value, index, self) {
return self.indexOf(value) === index;
}
-const affectedServices = all_files
- .map(function(file) {
+const affectedServices = allFiles
+ .map(file => {
const match = file.match(/^services\/(.+)\/.+\.service.js$/);
return match ? match[1] : undefined;
})
.filter(Boolean)
.filter(onlyUnique);
-const testedServices = all_files
- .map(function(file) {
+const testedServices = allFiles
+ .map(file => {
const match = file.match(/^services\/(.+)\/.+\.tester.js$/);
return match ? match[1] : undefined;
})
.filter(Boolean)
.filter(onlyUnique);
-affectedServices.forEach(function(service) {
+affectedServices.forEach(service => {
if (testedServices.indexOf(service) === -1) {
warn(
[
diff --git a/lib/.eslintrc.yml b/lib/.eslintrc.yml
deleted file mode 100644
index 22fe798e18073..0000000000000
--- a/lib/.eslintrc.yml
+++ /dev/null
@@ -1 +0,0 @@
-extends: '../.eslintrc-preferred.yml'
diff --git a/next.config.js b/next.config.js
index 8164bee263f78..0254924c5eddb 100644
--- a/next.config.js
+++ b/next.config.js
@@ -1,3 +1,5 @@
+'use strict'
+
const envFlag = require('node-env-flag');
const webpack = require('webpack');
const shouldAnalyze = envFlag(process.env.ANALYZE);
diff --git a/server.js b/server.js
index a55c4e339aa1c..5fc2c48d3b431 100644
--- a/server.js
+++ b/server.js
@@ -1,6 +1,6 @@
'use strict';
-const dom = require('xmldom').DOMParser;
+const { DOMParser } = require('xmldom');
const jp = require('jsonpath');
const path = require('path');
const xpath = require('xpath');
@@ -95,9 +95,9 @@ githubConstellation.initialize(camp);
suggest.setRoutes(config.cors.allowedOrigin, githubApiProvider, camp);
-camp.notfound(/\.(svg|png|gif|jpg|json)/, function(query, match, end, request) {
- var format = match[1];
- var badgeData = getBadgeData("404", query);
+camp.notfound(/\.(svg|png|gif|jpg|json)/, (query, match, end, request) => {
+ const format = match[1];
+ const badgeData = getBadgeData("404", query);
badgeData.text[1] = 'badge not found';
badgeData.colorscheme = 'red';
// Add format to badge data.
@@ -106,7 +106,7 @@ camp.notfound(/\.(svg|png|gif|jpg|json)/, function(query, match, end, request) {
makeSend(format, request.res, end)(svg);
});
-camp.notfound(/.*/, function(query, match, end, request) {
+camp.notfound(/.*/, (query, match, end, request) => {
end(null, { template: '404.html' });
});
@@ -122,14 +122,14 @@ camp.route(/^\/badge\/dynamic\/(json|xml|yaml)\.(svg|png|gif|jpg|json)$/,
cache({
queryParams: ['uri', 'url', 'query', 'prefix', 'suffix'],
handler: function(query, match, sendBadge, request) {
- var type = match[1];
- var format = match[2];
- var prefix = query.prefix || '';
- var suffix = query.suffix || '';
- var pathExpression = query.query;
- var requestOptions = {};
+ const type = match[1];
+ const format = match[2];
+ const prefix = query.prefix || '';
+ const suffix = query.suffix || '';
+ const pathExpression = query.query;
+ let requestOptions = {};
- var badgeData = getBadgeData('custom badge', query);
+ const badgeData = getBadgeData('custom badge', query);
if (!query.uri && !query.url || !query.query){
setBadgeColor(badgeData, 'red');
@@ -138,8 +138,9 @@ cache({
return;
}
+ let url
try {
- var url = encodeURI(decodeURIComponent(query.url || query.uri));
+ url = encodeURI(decodeURIComponent(query.url || query.uri));
} catch(e){
setBadgeColor(badgeData, 'red');
badgeData.text[1] = 'malformed url';
@@ -183,18 +184,18 @@ cache({
let innerText = [];
switch (type){
case 'json':
- data = (typeof data == 'object' ? data : JSON.parse(data));
+ data = (typeof data === 'object' ? data : JSON.parse(data));
data = jp.query(data, pathExpression);
if (!data.length) {
- throw 'no result';
+ throw Error('no result');
}
innerText = data;
break;
case 'xml':
- data = new dom().parseFromString(data);
+ data = new DOMParser().parseFromString(data);
data = xpath.select(pathExpression, data);
if (!data.length) {
- throw 'no result';
+ throw Error('no result');
}
data.forEach((i,v)=>{
innerText.push(pathExpression.indexOf('@') + 1 ? i.value : i.firstChild.data);
@@ -204,7 +205,7 @@ cache({
data = yaml.safeLoad(data);
data = jp.query(data, pathExpression);
if (!data.length) {
- throw 'no result';
+ throw Error('no result');
}
innerText = data;
break;
@@ -212,7 +213,7 @@ cache({
badgeData.text[1] = (prefix || '') + innerText.join(', ') + (suffix || '');
} catch (e) {
setBadgeColor(badgeData, 'lightgrey');
- badgeData.text[1] = e;
+ badgeData.text[1] = e.message;
} finally {
sendBadge(format, badgeData);
}
@@ -222,16 +223,16 @@ cache({
// Any badge.
camp.route(/^\/(:|badge\/)(([^-]|--)*?)-?(([^-]|--)*)-(([^-]|--)+)\.(svg|png|gif|jpg)$/,
-function(data, match, end, ask) {
- var subject = escapeFormat(match[2]);
- var status = escapeFormat(match[4]);
- var color = escapeFormat(match[6]);
- var format = match[8];
+(data, match, end, ask) => {
+ const subject = escapeFormat(match[2]);
+ const status = escapeFormat(match[4]);
+ const color = escapeFormat(match[6]);
+ const format = match[8];
analytics.noteRequest(data, match);
// Cache management - the badge is constant.
- var cacheDuration = (3600*24*1)|0; // 1 day.
+ const cacheDuration = (3600*24*1)|0; // 1 day.
ask.res.setHeader('Cache-Control', 'max-age=' + cacheDuration);
if (+(new Date(ask.req.headers['if-modified-since'])) >= +serverStartTime) {
ask.res.statusCode = 304;
@@ -242,7 +243,7 @@ function(data, match, end, ask) {
// Badge creation.
try {
- var badgeData = getBadgeData(subject, data);
+ const badgeData = getBadgeData(subject, data);
badgeData.text[0] = getLabel(subject, data);
badgeData.text[1] = status;
badgeData.colorB = makeColorB(color, data);
@@ -264,13 +265,13 @@ function(data, match, end, ask) {
// Production cache debugging.
let bitFlip = false;
-camp.route(/^\/flip\.svg$/, function(data, match, end, ask) {
- var cacheSecs = 60;
+camp.route(/^\/flip\.svg$/, (data, match, end, ask) => {
+ const cacheSecs = 60;
ask.res.setHeader('Cache-Control', 'max-age=' + cacheSecs);
- var reqTime = new Date();
- var date = (new Date(+reqTime + cacheSecs * 1000)).toGMTString();
+ const reqTime = new Date();
+ const date = (new Date(+reqTime + cacheSecs * 1000)).toGMTString();
ask.res.setHeader('Expires', date);
- var badgeData = getBadgeData('flip', data);
+ const badgeData = getBadgeData('flip', data);
bitFlip = !bitFlip;
badgeData.text[1] = bitFlip? 'on': 'off';
badgeData.colorscheme = bitFlip? 'brightgreen': 'red';
@@ -280,13 +281,13 @@ camp.route(/^\/flip\.svg$/, function(data, match, end, ask) {
// Any badge, old version.
camp.route(/^\/([^/]+)\/(.+).png$/,
-function(data, match, end, ask) {
- var subject = match[1];
- var status = match[2];
- var color = data.color;
+(data, match, end, ask) => {
+ const subject = match[1];
+ const status = match[2];
+ const color = data.color;
// Cache management - the badge is constant.
- var cacheDuration = (3600*24*1)|0; // 1 day.
+ const cacheDuration = (3600*24*1)|0; // 1 day.
ask.res.setHeader('Cache-Control', 'max-age=' + cacheDuration);
if (+(new Date(ask.req.headers['if-modified-since'])) >= +serverStartTime) {
ask.res.statusCode = 304;
@@ -297,7 +298,7 @@ function(data, match, end, ask) {
// Badge creation.
try {
- var badgeData = { text: [subject, status] };
+ const badgeData = { text: [subject, status] };
badgeData.colorscheme = color;
const svg = makeBadge(badgeData);
makeSend('png', ask.res, end)(svg);
diff --git a/services/.eslintrc.yml b/services/.eslintrc.yml
deleted file mode 100644
index 22fe798e18073..0000000000000
--- a/services/.eslintrc.yml
+++ /dev/null
@@ -1 +0,0 @@
-extends: '../.eslintrc-preferred.yml'