Bug 1505758 - Fix/enable ESLint 'prefer-template'

https://eslint.org/docs/rules/prefer-template
This commit is contained in:
Ed Morley 2018-11-05 13:50:22 +00:00
Родитель 160a4d8007
Коммит 7af125f626
18 изменённых файлов: 27 добавлений и 15 удалений

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

@ -49,7 +49,6 @@ module.exports = {
'prefer-arrow-callback': 'off',
'prefer-destructuring': 'off',
'prefer-promise-reject-errors': 'off',
'prefer-template': 'off',
radix: 'off',
'react/button-has-type': 'off',
'react/default-props-match-prop-types': 'off',

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

@ -11,7 +11,7 @@ export const stringOverlap = function (str1, str2) {
// Replace paths like /foo/bar/baz.html with just the filename baz.html
return str.replace(/[^\s]+\/([^\s]+)\s/,
function (m, p1) {
return ' ' + p1 + ' ';
return ` ${p1} `;
});
})
.map(function (str) {

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

@ -26,7 +26,7 @@ export const getRevisionTitle = function getRevisionTitle(revisions) {
title = title.replace(/[;,\-\. ]+$/, '').trim();
if (title) {
if (title.length > thTitleSuffixLimit) {
title = title.substr(0, thTitleSuffixLimit - 3) + '...';
title = `${title.substr(0, thTitleSuffixLimit - 3)}...`;
}
break;
}

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

@ -207,7 +207,7 @@ export class PushesClass extends React.Component {
getLastModifiedJobTime() {
const { jobMap } = this.state;
const latest = max(Object.values(jobMap).map(job => new Date(job.last_modified + 'Z'))) || new Date();
const latest = max(Object.values(jobMap).map(job => new Date(`${job.last_modified}Z`))) || new Date();
latest.setSeconds(latest.getSeconds() - 3);
return latest;

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

@ -209,11 +209,11 @@ export class BugFilerClass extends React.Component {
const lowerJobGroupName = jobGroupName.toLowerCase();
// Try to fix up file paths for some job types.
if (lowerJobGroupName.includes('spidermonkey')) {
failurePath = 'js/src/tests/' + failurePath;
failurePath = `js/src/tests/${failurePath}`;
}
if (lowerJobGroupName.includes('videopuppeteer ')) {
failurePath = failurePath.replace('FAIL ', '');
failurePath = 'dom/media/test/external/external_media_tests/' + failurePath;
failurePath = `dom/media/test/external/external_media_tests/${failurePath}`;
}
if (lowerJobGroupName.includes('web platform')) {
failurePath = failurePath.startsWith('mozilla/tests') ?
@ -361,7 +361,7 @@ export class BugFilerClass extends React.Component {
let failureString = `${source} returned status ${status}(${statusText})`;
if (data && data.failure) {
failureString += '\n\n' + data.failure;
failureString += `\n\n${data.failure}`;
}
if (status === 403) {
failureString += '\n\nAuthentication failed. Has your Treeherder session expired?';

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

@ -237,7 +237,7 @@ class SimilarJobsTab extends React.Component {
<tr>
<th>Duration</th>
<td>
{selectedSimilarJob.duration >= 0 ? selectedSimilarJob.duration.toFixed(0) + ' minute(s)' : 'unknown'}
{selectedSimilarJob.duration >= 0 ? `${selectedSimilarJob.duration.toFixed(0)} minute(s)` : 'unknown'}
</td>
</tr>
<tr>

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

@ -239,7 +239,7 @@ class Push extends React.Component {
this.setState({ watched: 'none' });
} else if (watched === 'job' && lastCompleted < nextCompleted) {
const completeCount = nextCompleted - lastCompleted;
message = completeCount + ' jobs completed';
message = `${completeCount} jobs completed`;
}
if (message) {

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

@ -110,8 +110,8 @@ class PushJobs extends React.Component {
jobId,
).then((data) => {
if (data.logs.length > 0) {
window.open(location.origin + '/' +
getLogViewerUrl(jobId, repoName));
window.open(`${location.origin}/${
getLogViewerUrl(jobId, repoName)}`);
}
});
}

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

@ -1,3 +1,5 @@
// Remove the eslint-disable when rewriting this file during the React conversion.
/* eslint-disable prefer-template */
import logViewerApp from '../logviewer';
import { getInspectTaskUrl, getReftestUrl } from '../../helpers/url';
import { isReftest } from '../../helpers/job';

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

@ -1,3 +1,5 @@
// Remove the eslint-disable when rewriting this file during the React conversion.
/* eslint-disable prefer-template */
import merge from 'lodash/merge';
import defaults from 'lodash/defaults';
import set from 'lodash/set';

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

@ -1,3 +1,5 @@
// Remove the eslint-disable when rewriting this file during the React conversion.
/* eslint-disable prefer-template */
import isEqual from 'lodash/isEqual';
import difference from 'lodash/difference';
import metricsgraphics from 'metrics-graphics';

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

@ -1,4 +1,5 @@
/* eslint-disable no-use-before-define, no-var, vars-on-top */
// Remove the eslint-disable when rewriting this file during the React conversion.
/* eslint-disable no-use-before-define, no-var, prefer-template, vars-on-top */
// TODO: Vet/fix the use-before-defines to ensure switching var
// to let/const won't break anything.

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

@ -1,3 +1,5 @@
// Remove the eslint-disable when rewriting this file during the React conversion.
/* eslint-disable prefer-template */
import $ from 'jquery';
import treeherder from '../../treeherder';

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

@ -1,3 +1,5 @@
// Remove the eslint-disable when rewriting this file during the React conversion.
/* eslint-disable prefer-template */
import sortBy from 'lodash/sortBy';
import padStart from 'lodash/padStart';
import capitalize from 'lodash/capitalize';

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

@ -1,3 +1,5 @@
// Remove the eslint-disable when rewriting this file during the React conversion.
/* eslint-disable prefer-template */
import forIn from 'lodash/forIn';
import chunk from 'lodash/chunk';

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

@ -17,7 +17,7 @@ export default class JobModel {
// we want to do a search on something like `fxup-esr(`)
let symbolInfo = (this.job_group_symbol === '?') ? '' :
this.job_group_symbol;
symbolInfo += '(' + this.job_type_symbol + ')';
symbolInfo += `(${this.job_type_symbol})`;
return [
thPlatformMap[this.platform] || this.platform,

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

@ -19,7 +19,7 @@ export default class BugLinkify extends React.Component {
normalize: (match) => {
const bugNumber = match.text.replace('bug:', '');
match.url = 'https://bugzilla.mozilla.org/show_bug.cgi?id=' + bugNumber;
match.url = `https://bugzilla.mozilla.org/show_bug.cgi?id=${bugNumber}`;
match.text = `Bug ${bugNumber}`;
},
});

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

@ -243,7 +243,7 @@ function filterTests(store, { filter, groups, options, hideClassified }) {
} else {
params.delete('filter');
}
history.push(location.pathname + '?' + params.toString());
history.push(`${location.pathname}?${params.toString()}`);
store.dispatch({
type: groupsStore.types.RENDER_TESTS,
payload: { filter, rowData },