Bug 1383114 - Enforce airbnb recommendations around es6 functions and block spacing (#2648)

This commit is contained in:
William Lachance 2017-07-21 13:59:52 -04:00 коммит произвёл GitHub
Родитель 91c7727d17
Коммит e968c8d966
23 изменённых файлов: 76 добавлений и 77 удалений

Просмотреть файл

@ -26,8 +26,16 @@ module.exports = neutrino => {
}
},
extends: 'eslint:recommended',
rules: {
rules: {
'arrow-body-style': ['error', 'as-needed', {
requireReturnForObjectLiteral: false,
}],
'arrow-parens': ['error', 'as-needed', {
requireForBlockBody: true,
}],
'arrow-spacing': ['error', { before: true, after: true }],
'accessor-pairs': 'error',
'block-spacing': ['error', 'always'],
'comma-spacing': 'error',
'comma-style': 'error',
'eol-last': 'error',

Просмотреть файл

@ -5,7 +5,7 @@
// actually need to request a partial file at any point.
module.exports = ['$templateCache', ($templateCache) => {
const partialsReq = require.context('../partials', true, /\.(tmpl|html)$/);
partialsReq.keys().forEach(template => {
partialsReq.keys().forEach((template) => {
const keyPath = `partials${template.substring(1)}`;
$templateCache.put(
keyPath,
@ -13,7 +13,7 @@ module.exports = ['$templateCache', ($templateCache) => {
);
});
const pluginsReq = require.context('../plugins', true, /\.(tmpl|html)$/);
pluginsReq.keys().forEach(template => {
pluginsReq.keys().forEach((template) => {
const keyPath = `plugins${template.substring(1)}`;
$templateCache.put(
keyPath,

Просмотреть файл

@ -133,7 +133,7 @@ treeherder.component('distributionGraph', {
ctrl.minValue = Math.floor(ctrl.minValue/1.001);
}
ctx.globalAlpha = 0.3;
ctrl.replicates.forEach((value) =>{
ctrl.replicates.forEach((value) => {
ctx.beginPath();
ctx.arc(180/(ctrl.maxValue - ctrl.minValue)*(value - ctrl.minValue) + 5, 18, 5, 0, 360);
ctx.fillStyle = 'white';

Просмотреть файл

@ -223,7 +223,7 @@ treeherder.controller('BugFilerCtrl', [
// Bug 1358328 - We need to override headers here until DXR returns JSON with the default Accept header
$http.get(dxrlink, {"headers": {
"Accept": "application/json"
}}).then(secondRequest => {
}}).then((secondRequest) => {
const results = secondRequest.data.results;
var resultsCount = results.length;
// If the search returns too many results, this probably isn't a good search term, so bail
@ -231,10 +231,10 @@ treeherder.controller('BugFilerCtrl', [
$scope.searching = false;
injectProducts(failurePath);
}
results.forEach(result => {
results.forEach((result) => {
$scope.searching = "DXR & Mercurial";
$http.get(`${hgBaseUrl}mozilla-central/json-mozbuildinfo?p=${result.path}`)
.then(thirdRequest => {
.then((thirdRequest) => {
if (thirdRequest.data.aggregate && thirdRequest.data.aggregate.recommended_bug_component) {
const suggested = thirdRequest.data.aggregate.recommended_bug_component;
addProduct(suggested[0] + " :: " + suggested[1]);

Просмотреть файл

@ -76,9 +76,7 @@ logViewerApp.controller('LogviewerCtrl', [
};
// Get the css class for the result, step buttons and other general use
$scope.getShadingClass = (result) => {
return "result-status-shading-" + result;
};
$scope.getShadingClass = result => "result-status-shading-" + result;
// @@@ it may be possible to do this with the angular date filter?
$scope.formatTime = (startedStr, finishedStr) => {
@ -115,7 +113,7 @@ logViewerApp.controller('LogviewerCtrl', [
if (jobList.length > 0) {
$scope.job_id = jobList[0]['id'];
}
ThJobModel.get($scope.repoName, $scope.job_id).then(job => {
ThJobModel.get($scope.repoName, $scope.job_id).then((job) => {
// set the title of the browser window/tab
$scope.logViewerTitle = job.get_title();
@ -149,13 +147,13 @@ logViewerApp.controller('LogviewerCtrl', [
};
// get the revision and linkify it
ThResultSetModel.getResultSet($scope.repoName, job.result_set_id).then(data => {
ThResultSetModel.getResultSet($scope.repoName, job.result_set_id).then((data) => {
const revision = data.data.revision;
$scope.logProperties.push({label: 'Revision', value: revision});
});
ThJobDetailModel.getJobDetails({job_guid: job.job_guid}).then(jobDetails => {
ThJobDetailModel.getJobDetails({job_guid: job.job_guid}).then((jobDetails) => {
$scope.job_details = jobDetails;
});
}, () => {
@ -173,14 +171,14 @@ logViewerApp.controller('LogviewerCtrl', [
ThTextLogStepModel.query({
project: $rootScope.repoName,
jobId: $scope.job_id
}, textLogSteps => {
}, (textLogSteps) => {
let shouldPost = true;
const allErrors = _.flatten(textLogSteps.map(s => s.errors));
const q = $location.search();
$scope.steps = textLogSteps;
// add an ordering to each step
textLogSteps.forEach((step, i) => {step.order = i;});
textLogSteps.forEach((step, i) => { step.order = i; });
// load the first failure step line else load the head
if (allErrors.length) {

Просмотреть файл

@ -894,17 +894,12 @@ perf.controller('CompareSubtestDistributionCtrl', ['$scope', '$stateParams', '$q
}
const numRuns = perfDatumList[subtestSignature].length;
let replicatePromises = perfDatumList[subtestSignature].map(
(value) => {return PhSeries.getReplicateData({job_id: value.job_id});
});
value => PhSeries.getReplicateData({job_id: value.job_id}));
return $q.all(replicatePromises).then((replicateData) => {
let replicateValues = replicateData.concat.apply([],
replicateData.map((data) => {
let testSuite = data.suites.find((suite) => {
return suite.name === $scope.testSuite;
});
let subtest = testSuite.subtests.find((subtest) =>{
return subtest.name === $scope.subtest;
});
let testSuite = data.suites.find(suite => suite.name === $scope.testSuite);
let subtest = testSuite.subtests.find(subtest => subtest.name === $scope.subtest);
return subtest.replicates;
})
);
@ -924,10 +919,10 @@ perf.controller('CompareSubtestDistributionCtrl', ['$scope', '$stateParams', '$q
target: `#${target}`
});
},
() =>{
() => {
replicateData.replicateDataError = true;
});
}).then(() =>{
}).then(() => {
if (replicateData.replicateDataError) {
metricsgraphics.data_graphic({
title: `${target} Replicates`,

Просмотреть файл

@ -150,7 +150,7 @@ perf.controller('dashCtrl', [
$scope.compareResults[testName].push(cmap);
}
}
}});
} });
});
});
});

Просмотреть файл

@ -1,6 +1,6 @@
'use strict';
treeherder.directive('lvLogSteps', ['$timeout', $timeout => {
treeherder.directive('lvLogSteps', ['$timeout', ($timeout) => {
function getOffsetOfStep(order) {
const el = $('.lv-step[order="' + order + '"]');
const parentOffset = el.parent().offset();
@ -19,9 +19,7 @@ treeherder.directive('lvLogSteps', ['$timeout', $timeout => {
scope.toggleSuccessfulSteps = () => {
scope.showSuccessful = !scope.showSuccessful;
const firstError = scope.steps.filter(step => {
return step.result && step.result !== 'success';
})[0];
const firstError = scope.steps.filter(step => step.result && step.result !== 'success')[0];
if (!firstError) {
return;

Просмотреть файл

@ -125,7 +125,7 @@ treeherder.filter('highlightLogLine', function () {
treeherder.filter('highlightCommonTerms', function () {
return function (input) {
var compareStr = Array.prototype.slice.call(arguments, 1).filter(
function (x) {return x;}).join(" ");
function (x) { return x; }).join(" ");
var tokens = compareStr.split(/[^a-zA-Z0-9_-]+/);
tokens.sort(function (a, b) {
return b.length - a.length;

Просмотреть файл

@ -9,7 +9,7 @@ treeherder.factory('ThBugJobMapModel', [
angular.extend(this, data);
};
ThBugJobMapModel.get_uri = function () {return thUrl.getProjectUrl("/bug-job-map/");};
ThBugJobMapModel.get_uri = function () { return thUrl.getProjectUrl("/bug-job-map/"); };
// a static method to retrieve a list of ThBugJobMap
// the options parameter is used to filter/limit the list of objects

Просмотреть файл

@ -12,7 +12,7 @@ treeherder.factory('ThJobClassificationModel', [
angular.extend(this, data);
};
ThJobClassificationModel.get_uri = function () {return thUrl.getProjectUrl("/note/");};
ThJobClassificationModel.get_uri = function () { return thUrl.getProjectUrl("/note/"); };
ThJobClassificationModel.get_list = function (options) {
// a static method to retrieve a list of ThJobClassificationModel

Просмотреть файл

@ -48,7 +48,7 @@ treeherder.factory('ThJobModel', [
]).join(' ');
};
ThJobModel.get_uri = function (repoName) {return thUrl.getProjectUrl("/jobs/", repoName);};
ThJobModel.get_uri = function (repoName) { return thUrl.getProjectUrl("/jobs/", repoName); };
ThJobModel.get_list = function (repoName, options, config) {
// a static method to retrieve a list of ThJobModel

Просмотреть файл

@ -22,13 +22,13 @@ treeherder.factory('ThMatcherModel', [
};
ThMatcherModel.by_id = function () {
return matchers.then((data) =>
return matchers.then(data =>
data.reduce((matchersById, matcher) =>
matchersById.set(matcher.id, matcher), new Map()));
};
ThMatcherModel.get = function (pk) {
ThMatcherModel.by_id.then((map) => map[pk]);
ThMatcherModel.by_id.then(map => map[pk]);
};
var matchers = $http

Просмотреть файл

@ -75,10 +75,10 @@ treeherder.factory('PhAlerts', [
AlertSummary.prototype.getTextualSummary = function (copySummary) {
var resultStr = "";
var improved = _.sortBy(_.filter(this.alerts, function (alert) {
return !alert.is_regression && alert.visible;}),
return !alert.is_regression && alert.visible; }),
'amount_pct').reverse();
var regressed = _.sortBy(_.filter(this.alerts, function (alert) {
return alert.is_regression && alert.visible && !alert.isInvalid();}),
return alert.is_regression && alert.visible && !alert.isInvalid(); }),
'amount_pct').reverse();
var formatAlert = function (alert, alertList) {

Просмотреть файл

@ -34,7 +34,7 @@ treeherder.factory('ThRepositoryModel', [
var getOrderedRepoGroups = function () {
if (!_.size(orderedRepoGroups)) {
var groups = _.groupBy($rootScope.repos, function (r) {return r.repository_group.name;});
var groups = _.groupBy($rootScope.repos, function (r) { return r.repository_group.name; });
_.each(groups, function (reposAr, gName) {
orderedRepoGroups[thRepoGroupOrder[gName] || gName] = {name: gName, repos: reposAr};
});

Просмотреть файл

@ -154,7 +154,7 @@ treeherder.factory('ThResultSetStore', [
_.groupBy(jobList, 'result_set_id')
);
jobListByResultSet
.forEach((singleResultSetJobList) =>
.forEach(singleResultSetJobList =>
mapResultSetJobs($rootScope.repoName,
singleResultSetJobList));
} else if (lastJobUpdate) {
@ -835,7 +835,7 @@ treeherder.factory('ThResultSetStore', [
if (data.results.length > 0) {
$log.debug("appendResultSets", data.results);
var rsIds = repositories[repoName].resultSets.map((rs) => rs.id);
var rsIds = repositories[repoName].resultSets.map(rs => rs.id);
// ensure we only append resultsets we don't already have.
// There could be overlap with fetching "next 10" because we use
@ -1019,7 +1019,7 @@ treeherder.factory('ThResultSetStore', [
count,
true,
keepFilters)
.then((data) => {resultsets = data.data;});
.then((data) => { resultsets = data.data; });
return $q.all([loadRepositories, loadResultsets])
.then(() => appendResultSets(repoName, resultsets),
@ -1043,7 +1043,7 @@ treeherder.factory('ThResultSetStore', [
$q.all(jobsPromiseList)
.then((resultSetJobList) => {
var lastModifiedTimes = resultSetJobList
.map((jobList) => getLastModifiedJobTime(jobList))
.map(jobList => getLastModifiedJobTime(jobList))
.filter(x => x);
if (lastModifiedTimes.length) {
var lastModifiedTime = _.max(lastModifiedTimes);
@ -1065,8 +1065,8 @@ treeherder.factory('ThResultSetStore', [
* ie when we can register the job poller
*/
var mapResultSetJobsPromiseList = jobsPromiseList
.map((jobsPromise) => jobsPromise
.then((jobs) => mapResultSetJobs(repoName, jobs)));
.map(jobsPromise => jobsPromise
.then(jobs => mapResultSetJobs(repoName, jobs)));
$q.all(mapResultSetJobsPromiseList)
.then(() => {
setSelectedJobFromQueryString(repoName);
@ -1177,7 +1177,7 @@ treeherder.factory('ThResultSetStore', [
job_counts: getJobCount(jobList)
};
if (jobList.length === 0) {return groupedJobs;}
if (jobList.length === 0) { return groupedJobs; }
groupedJobs.id = jobList[0].result_set_id;
var lastModified = "";
for (var i=0; i<jobList.length; i++) {

Просмотреть файл

@ -12,7 +12,7 @@ treeherder.factory('ThUserModel', [
angular.extend(this, data);
};
ThUserModel.get_uri = function () {return thUrl.getRootUrl("/user/");};
ThUserModel.get_uri = function () { return thUrl.getRootUrl("/user/"); };
ThUserModel.get = function () {
// a static method to retrieve a single instance of ThUserModel

Просмотреть файл

@ -1,6 +1,6 @@
'use strict';
const MoreRevisionsLink = (props) => (
const MoreRevisionsLink = props => (
<li>
<a href={props.href}
data-ignore-job-clear-on-click={true}

Просмотреть файл

@ -164,7 +164,7 @@ treeherder.factory('thJobFilters', [
fieldFilters[_withoutPrefix(field)] = decodeURIComponent(values).replace(/ +(?= )/g, ' ').toLowerCase().split(' ');
} else {
var lowerVals = _.map(_toArray(values),
function (v) {return String(v).toLowerCase();});
function (v) { return String(v).toLowerCase(); });
fieldFilters[_withoutPrefix(field)] = lowerVals;
}
}

Просмотреть файл

@ -20,11 +20,11 @@ treeherder.factory('ThLog', [
return this.name;
};
ThLog.prototype.debug = function () {logIt(this, $log.debug, arguments);};
ThLog.prototype.log = function () {logIt(this, $log.log, arguments);};
ThLog.prototype.warn = function () {logIt(this, $log.warn, arguments);};
ThLog.prototype.info = function () {logIt(this, $log.info, arguments);};
ThLog.prototype.error = function () {logIt(this, $log.error, arguments);};
ThLog.prototype.debug = function () { logIt(this, $log.debug, arguments); };
ThLog.prototype.log = function () { logIt(this, $log.log, arguments); };
ThLog.prototype.warn = function () { logIt(this, $log.warn, arguments); };
ThLog.prototype.info = function () { logIt(this, $log.info, arguments); };
ThLog.prototype.error = function () { logIt(this, $log.error, arguments); };
var logIt = function (self, func, args) {
if ((whitelist.length && _.includes(whitelist, self.getClassName())) ||

Просмотреть файл

@ -36,7 +36,7 @@ treeherder.controller('AnnotationsPluginCtrl', [
// this $evalAsync will be sure that the * is added or removed in
// the job in the jobs table when this change takes place.
$scope.$evalAsync(function () {job.failure_classification_id = 1;});
$scope.$evalAsync(function () { job.failure_classification_id = 1; });
ThResultSetStore.updateUnclassifiedFailureMap($rootScope.repoName, job);
classification.delete()

Просмотреть файл

@ -16,7 +16,7 @@ treeherder.factory('thStringOverlap', function () {
})
.map(function (str) {
// Split into tokens on whitespace / , and |
return str.split(/[\s\/\,|]+/).filter(function (x) {return x !== "";});
return str.split(/[\s\/\,|]+/).filter(function (x) { return x !== ""; });
});
if (tokens[0].length === 0 || tokens[1].length === 0) {
@ -24,7 +24,7 @@ treeherder.factory('thStringOverlap', function () {
}
var tokenCounts = tokens.map(function (tokens) {
return _.countBy(tokens, function (x) {return x;});
return _.countBy(tokens, function (x) { return x; });
});
var overlap = Object.keys(tokenCounts[0])
@ -53,7 +53,7 @@ treeherder.factory('ThErrorLineData', [
this.verified = !!line.metadata.best_is_verified;
this.bestClassification = line.metadata.best_classification ?
line.classified_failures
.find((cf) => cf.id === line.metadata.best_classification) : null;
.find(cf => cf.id === line.metadata.best_classification) : null;
this.bugNumber = this.bestClassification ?
this.bestClassification.bug_number : null;
this.verifiedIgnore = this.verified && (this.bugNumber === 0 ||
@ -302,7 +302,7 @@ treeherder.controller('ThErrorLineController', [
* @param {Object[]} options - List of options
*/
$scope.hasHidden = function (options) {
return options.some((option) => option.hidden);
return options.some(option => option.hidden);
};
/**
@ -353,8 +353,8 @@ treeherder.controller('ThErrorLineController', [
var classificationMatches = getClassifiedFailureMatcher();
var autoclassifyOptions = line.data.classified_failures
.filter((cf) => cf.bug_number !== 0)
.map((cf) => new ThClassificationOption("classifiedFailure",
.filter(cf => cf.bug_number !== 0)
.map(cf => new ThClassificationOption("classifiedFailure",
line.id + "-" + cf.id,
cf.id,
cf.bug_number,
@ -367,8 +367,8 @@ treeherder.controller('ThErrorLineController', [
new Set());
var bugSuggestionOptions = bugSuggestions
.filter((bug) => !autoclassifiedBugs.has(bug.id))
.map((bugSuggestion) => new ThClassificationOption("unstructuredBug",
.filter(bug => !autoclassifiedBugs.has(bug.id))
.map(bugSuggestion => new ThClassificationOption("unstructuredBug",
line.id + "-" + "ub-" + bugSuggestion.id,
null,
bugSuggestion.id,
@ -383,7 +383,7 @@ treeherder.controller('ThErrorLineController', [
if (!bestIsIgnore()) {
var bestIndex = line.bestClassification ?
autoclassifyOptions
.findIndex((option) => option.classifiedFailureId === line.bestClassification.id) : -1;
.findIndex(option => option.classifiedFailureId === line.bestClassification.id) : -1;
if (bestIndex > -1) {
bestOption = autoclassifyOptions[bestIndex];
@ -440,7 +440,7 @@ treeherder.controller('ThErrorLineController', [
if (option.type === "classifiedFailure") {
score = parseFloat(
data.matches.find(
(x) => x.classified_failure === option.classifiedFailureId).score);
x => x.classified_failure === option.classifiedFailureId).score);
} else {
score = thStringOverlap(data.bug_suggestions.search,
option.bugSummary.replace(/^\s*Intermittent\s+/, ""));
@ -642,7 +642,7 @@ treeherder.controller('ThErrorLineController', [
id = line.id + "-manual";
} else {
var idx = parseInt(option);
var selectableOptions = $scope.options.filter((option) => option.selectable);
var selectableOptions = $scope.options.filter(option => option.selectable);
if (selectableOptions[idx]) {
id = selectableOptions[idx].id;
}
@ -907,7 +907,7 @@ treeherder.controller('ThAutoclassifyPanelController', [
$scope.errorMatchers = data.matchers;
loadData(data.error_lines);
$scope.errorLines
.forEach((line) => stateByLine.set(
.forEach(line => stateByLine.set(
line.id, {
classifiedFailureId: null,
bugNumber: null,
@ -933,7 +933,7 @@ treeherder.controller('ThAutoclassifyPanelController', [
}
});
}
$scope.$evalAsync(() => {ctrl.loadStatus = "ready";});
$scope.$evalAsync(() => { ctrl.loadStatus = "ready"; });
}
/**
@ -963,7 +963,7 @@ treeherder.controller('ThAutoclassifyPanelController', [
linesById = lines
.reduce((byId, line) => {
byId.set(line.id, new ThErrorLineData(line));
return byId;}, linesById);
return byId; }, linesById);
$scope.errorLines = Array.from(linesById.values());
// Resort the lines to allow for in-place updates
$scope.errorLines.sort((a, b) => a.data.id - b.data.id);
@ -1056,7 +1056,7 @@ treeherder.controller('ThAutoclassifyPanelController', [
ctrl.onToggleEditable = function () {
var selectedIds = Array.from(ctrl.selectedLineIds);
var editable = selectedIds.some((id) => !ctrl.editableLineIds.has(id));
var editable = selectedIds.some(id => !ctrl.editableLineIds.has(id));
setEditable(selectedIds, editable);
};
@ -1073,8 +1073,8 @@ treeherder.controller('ThAutoclassifyPanelController', [
};
function setEditable(lineIds, editable) {
var f = editable ? (lineId) => ctrl.editableLineIds.add(lineId):
(lineId) => ctrl.editableLineIds.delete(lineId);
var f = editable ? lineId => ctrl.editableLineIds.add(lineId):
lineId => ctrl.editableLineIds.delete(lineId);
lineIds.forEach(f);
}
@ -1142,7 +1142,7 @@ treeherder.controller('ThAutoclassifyPanelController', [
} else if (indexes.some(x => x === "prevJob" || x === "nextJob")) {
return;
}
var lineIds = indexes.map((idx) => selectable[idx].id);
var lineIds = indexes.map(idx => selectable[idx].id);
ctrl.onToggleSelect(lineIds, clear);
$scope.$evalAsync(
() => $("th-autoclassify-errors th-error-line")[indexes[0]]
@ -1220,17 +1220,17 @@ treeherder.controller('ThAutoclassifyPanelController', [
/**
* Lines that haven't yet been saved.
*/
$scope.pendingLines = lineFilterFunc((line) => line.verified === false);
$scope.pendingLines = lineFilterFunc(line => line.verified === false);
/**
* Lines that are selected
*/
$scope.selectedLines = lineFilterFunc((line) => ctrl.selectedLineIds.has(line.id));
$scope.selectedLines = lineFilterFunc(line => ctrl.selectedLineIds.has(line.id));
/**
* Lines that can be selected
*/
var selectableLines = lineFilterFunc((line) => !line.verified);
var selectableLines = lineFilterFunc(line => !line.verified);
function lineFilterFunc(filterFunc) {
return () => {

Просмотреть файл

@ -325,7 +325,7 @@ treeherder.controller('PluginCtrl', [
var getRevisionTips = function (projectName, list) {
list.splice(0, list.length);
var rsArr = ThResultSetStore.getResultSetsArray(projectName);
_.forEach(rsArr, rs => {
_.forEach(rsArr, (rs) => {
list.push({
revision: rs.revision,
author: rs.author,