Skip to content

Commit 7c3f2ed

Browse files
authored
Merge pull request #120 from jamie29w/concat-strings-to-string-literals
Concat strings to string literals
2 parents 249da9f + 70e351b commit 7c3f2ed

File tree

5 files changed

+1305
-1267
lines changed

5 files changed

+1305
-1267
lines changed

app.js

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ function initializeExtension() {
2121
}
2222

2323
// the button
24-
const newBtn = $(Handlebars.templates.button().replace(/(\r\n|\n|\r)/gm,""))
24+
const newBtn = $(Handlebars.templates.button().replace(/(\r\n|\n|\r)/gm, ""))
2525

2626
// the modal
27-
const context = {confirmText: 'Are you sure you want to clone this issue to another repository? Choose whether to clone and close or clone and keep the original issue open.'}
28-
const popup = $(Handlebars.templates.modal(context).replace(/(\r\n|\n|\r)/gm,""))
27+
const context = { confirmText: 'Are you sure you want to clone this issue to another repository? Choose whether to clone and close or clone and keep the original issue open.' }
28+
const popup = $(Handlebars.templates.modal(context).replace(/(\r\n|\n|\r)/gm, ""))
2929

3030
// get url
3131
const urlObj = populateUrlMetadata()
3232

3333
// if the page is not a pull request page(view or create)
3434
// and the page is not a new issue page
3535
// and there is no Kamino button in the DOM, proceed
36-
if (urlObj.url.indexOf(urlObj.organization + '/' + urlObj.currentRepo + '/compare/') < 0 &&
37-
urlObj.url.indexOf(urlObj.organization + '/' + urlObj.currentRepo + '/pull/') < 0 &&
38-
urlObj.url.indexOf(urlObj.organization + '/' + urlObj.currentRepo + '/issues/new') < 0 &&
39-
$('.kaminoButton').length === 0) {
36+
if (urlObj.url.indexOf(`${urlObj.organization}/${urlObj.currentRepo}/compare/`) < 0 &&
37+
urlObj.url.indexOf(`${urlObj.organization}/${urlObj.currentRepo}/pull/`) < 0 &&
38+
urlObj.url.indexOf(`${urlObj.organization}/${urlObj.currentRepo}/issues/new`) < 0 &&
39+
$('.kaminoButton').length === 0) {
4040

4141
// look for any applied issue filters
4242
saveAppliedFilters(urlObj)
@@ -166,7 +166,7 @@ function getRepos(url) {
166166

167167
compileRepositoryList(repos.data)
168168

169-
if(nextLink) {
169+
if (nextLink) {
170170
return getRepos(nextLink)
171171
} else {
172172
return null
@@ -180,16 +180,16 @@ function getRepos(url) {
180180
function loadRepos() {
181181
// wire up search value change events
182182
var lastValue = '';
183-
$(".repoSearch").on('change keyup paste mouseup', function() {
184-
if ($(this).val() != lastValue) {
185-
lastValue = $(this).val()
186-
searchRepositories(lastValue)
187-
}
183+
$(".repoSearch").on('change keyup paste mouseup', function () {
184+
if ($(this).val() != lastValue) {
185+
lastValue = $(this).val()
186+
searchRepositories(lastValue)
187+
}
188188
})
189189

190190
// create a way to go to options without using the extension context menu
191191
$(".kamino-heading").click(() => {
192-
chrome.runtime.sendMessage({ action:'goToOptions' }, (response) => {
192+
chrome.runtime.sendMessage({ action: 'goToOptions' }, (response) => {
193193
})
194194
})
195195

@@ -221,23 +221,23 @@ function compileRepositoryList(list, searchTerm) {
221221
// check for a populated list
222222
if (item.mostUsed && item.mostUsed.length > 0) {
223223
$('.quickClone').attr('data-repo', item.mostUsed[0]);
224-
$('.quickClone').text('Clone to ' + item.mostUsed[0].substring(item.mostUsed[0].indexOf('/') + 1))
224+
$('.quickClone').text(`Clone to ${item.mostUsed[0].substring(item.mostUsed[0].indexOf('/') + 1)}`)
225225

226226
// show used separator header
227227
$('.dropdown-header-used').addClass('active')
228228

229229
var mostUsed = item.mostUsed
230230

231231
// filter out most used by search term
232-
if(searchTerm && searchTerm !== '') {
232+
if (searchTerm && searchTerm !== '') {
233233
console.log('filtering most used: ', searchTerm)
234234
mostUsed = item.mostUsed.filter((item, index) => {
235235
return item.indexOf(searchTerm) > -1
236236
})
237237
}
238238

239239
// hide header if there are no last used items
240-
if(!mostUsed || mostUsed.length === 0) {
240+
if (!mostUsed || mostUsed.length === 0) {
241241
$('.dropdown-header-used').removeClass('active')
242242
}
243243

@@ -259,7 +259,7 @@ function compileRepositoryList(list, searchTerm) {
259259
}
260260

261261
// show or hide rest header based on number of items
262-
if(!list || list.length === 0) {
262+
if (!list || list.length === 0) {
263263
$('.dropdown-header-rest').removeClass('active')
264264
} else {
265265
$('.dropdown-header-rest').addClass('active')
@@ -289,11 +289,11 @@ function searchRepositories(searchTerm) {
289289
function getGithubIssue(repo, closeOriginal) {
290290
const urlObj = populateUrlMetadata()
291291

292-
ajaxRequest('GET', '', 'https://api.github.com/repos/' + urlObj.organization + '/' + urlObj.currentRepo + '/issues/' + urlObj.issueNumber).then((issue) => {
292+
ajaxRequest('GET', '', `https://api.github.com/repos/${urlObj.organization}/${urlObj.currentRepo}/issues/${urlObj.issueNumber}`).then((issue) => {
293293
// build new issue
294294
const newIssue = {
295295
title: issue.data.title,
296-
body: 'From ' + urlObj.currentRepo + ' created by [' + issue.data.user.login + '](' + issue.data.user.html_url + ') : ' + urlObj.organization + '/' + urlObj.currentRepo + '#' + urlObj.issueNumber + " \n\n" + issue.data.body,
296+
body: `From ${urlObj.currentRepo} created by [${issue.data.user.login}](${issue.data.user.html_url}): ${urlObj.organization}/${urlObj.currentRepo}#${urlObj.issueNumber} \n\n${issue.data.body}`,
297297
labels: issue.data.labels
298298
}
299299

@@ -303,7 +303,7 @@ function getGithubIssue(repo, closeOriginal) {
303303

304304
// create the cloned GitHub issue
305305
function createGithubIssue(newIssue, repo, oldIssue, closeOriginal) {
306-
ajaxRequest('POST', newIssue, 'https://api.github.com/repos/' + repo + '/issues').then((response) => {
306+
ajaxRequest('POST', newIssue, `https://api.github.com/repos/${repo}/issues`).then((response) => {
307307
// add a comment to the closed issue
308308
commentOnIssue(repo, oldIssue, response.data, closeOriginal)
309309
})
@@ -316,18 +316,18 @@ function closeGithubIssue(oldIssue) {
316316

317317
const urlObj = populateUrlMetadata()
318318

319-
ajaxRequest('PATCH', issueToClose, 'https://api.github.com/repos/' + urlObj.organization + '/' + urlObj.currentRepo + '/issues/' + urlObj.issueNumber).then((done) => {
319+
ajaxRequest('PATCH', issueToClose, `https://api.github.com/repos/${urlObj.organization}/${urlObj.currentRepo}/issues/${urlObj.issueNumber}`).then((done) => {
320320
})
321321
}
322322

323323
function commentOnIssue(repo, oldIssue, newIssue, closeOriginal) {
324324
const urlObj = populateUrlMetadata()
325-
const newIssueLink = '[' + repo + ']' + '(' + newIssue.html_url + ')'
325+
const newIssueLink = `[${repo}](${newIssue.html_url})`
326326
const comment = {
327-
body: closeOriginal ? 'Kamino closed and cloned this issue to ' + newIssueLink: 'Kamino cloned this issue to ' + newIssueLink
327+
body: closeOriginal ? `Kamino closed and cloned this issue to ${newIssueLink}` : `Kamino cloned this issue to ${newIssueLink}`
328328
}
329329

330-
ajaxRequest('POST', comment, 'https://api.github.com/repos/' + urlObj.organization + '/' + urlObj.currentRepo + '/issues/' + urlObj.issueNumber + '/comments').then((response) => {
330+
ajaxRequest('POST', comment, `https://api.github.com/repos/${urlObj.organization}/${urlObj.currentRepo}/issues/${urlObj.issueNumber}/comments`).then((response) => {
331331

332332
if (closeOriginal) {
333333
// if success, close the existing issue and open new in a new tab
@@ -352,7 +352,7 @@ function ajaxRequest(type, data, url) {
352352
$.ajax({
353353
type: type,
354354
beforeSend: (request) => {
355-
request.setRequestHeader('Authorization', 'token ' + token)
355+
request.setRequestHeader('Authorization', `token ${token}`)
356356
request.setRequestHeader('Content-Type', 'application/json')
357357
},
358358
data: JSON.stringify(data),
@@ -373,15 +373,15 @@ function addRepoToList(repoFullName, repo, section) {
373373
const periodReplace = repo.replace(/\./g, '_')
374374

375375
// determine where the item needs to go
376-
if(section === 'used') {
377-
if($('#' + periodReplace).length === 0) {
378-
$('.dropdown-header-rest').before('<li data-toggle="modal" id="' + periodReplace + '" data-target="#kaminoModal"><a class="repoItem" href="#">' + repoFullName + '</a></li>')
376+
if (section === 'used') {
377+
if ($(`#${periodReplace}`).length === 0) {
378+
$('.dropdown-header-rest').before(`<li data-toggle="modal" id="${periodReplace}" data-target="#kaminoModal"><a class="repoItem" href="#">${repoFullName}</a></li>`)
379379
}
380380
} else {
381-
$('.repoDropdown').append('<li data-toggle="modal" id="' + periodReplace + '" data-target="#kaminoModal"><a class="repoItem" href="#">' + repoFullName + '</a></li>')
381+
$('.repoDropdown').append(`<li data-toggle="modal" id="${periodReplace}" data-target="#kaminoModal"><a class="repoItem" href="#">${repoFullName}</a></li>`)
382382
}
383383

384-
$('#' + periodReplace).bind('click', () => { itemClick(repoFullName) })
384+
$(`#${periodReplace}`).bind('click', () => { itemClick(repoFullName) })
385385
}
386386

387387
function populateUrlMetadata() {
@@ -456,7 +456,7 @@ function itemClick(repo) {
456456

457457
$('.cloneAndClose').attr('data-repo', repo)
458458
$('.cloneAndKeepOpen').attr('data-repo', repo)
459-
$('.confirmText').text('Are you sure you want to clone this issue to ' + repo + '? Choose whether to clone and close or clone and keep the original issue open.')
459+
$('.confirmText').text(`Are you sure you want to clone this issue to ${repo}? Choose whether to clone and close or clone and keep the original issue open.`)
460460
openModal()
461461
}
462462

background.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ chrome.runtime.onInstalled.addListener((details) => {
2222

2323
// listen for tab change requests
2424
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
25-
if(request.action && request.action === 'goToOptions') {
25+
if (request.action && request.action === 'goToOptions') {
2626
// open the options screen in a new tab
27-
chrome.tabs.create({ url: 'chrome-extension://' + chrome.runtime.id + '/options.html', selected: true })
27+
chrome.tabs.create({ url: `chrome-extension://${chrome.runtime.id}/options.html`, selected: true })
2828
} else {
2929
// get settings
3030
chrome.storage.sync.get({
@@ -48,17 +48,17 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
4848

4949
setTimeout(() => {
5050
if (item.createTab) {
51-
chrome.tabs.create({ url: 'https://github.com/' + request.repo + '/issues/' + request.issueNumber, selected: false })
51+
chrome.tabs.create({ url: `https://github.com/${request.repo}/issues/${request.issueNumber}`, selected: false })
5252
}
53-
chrome.tabs.update(tabs[0].id, { url: 'https://github.com/' + request.organization + '/' + request.oldRepo + filter.filter, selected: true })
53+
chrome.tabs.update(tabs[0].id, { url: `https://github.com/${request.organization}/${request.oldRepo}${filter.filter}`, selected: true })
5454
}, 1000)
5555
})
5656
}
5757
else {
5858
console.log('no navigation')
5959
if (item.createTab) {
6060
// if user setting is not set, open open cloned issue in new tab and set focus to that tab
61-
setTimeout(() => { chrome.tabs.create({ url: 'https://github.com/' + request.repo + '/issues/' + request.issueNumber, selected: true }) }, 1000)
61+
setTimeout(() => { chrome.tabs.create({ url: `https://github.com/${request.repo}/issues/${request.issueNumber}`, selected: true }) }, 1000)
6262
}
6363
}
6464
})

backgroundScriptsAPIBridge.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,19 @@ class EdgeBridgeDebugLog {
9696
result = action();
9797
this.AddToCalledDictionary(this.SuccededCalls, name);
9898
if (typeof deprecatedTo !== "undefined" && typeof deprecatedTo !== "null") {
99-
this.warn("API Call Deprecated - Name: " + name + ", Please use " + deprecatedTo + " instead!");
99+
this.warn(`API Call Deprecated - Name: ${name}, Please use ${deprecatedTo} instead!"`);
100100
this.AddToCalledDictionary(this.DeprecatedCalls, name);
101101
}
102102
if (typeof bridgedTo !== "undefined" && typeof bridgedTo !== "null") {
103-
this.info("API Call '" + name + "' has been bridged to another Edge API: " + bridgedTo);
103+
this.info(`API Call '${name}' has been bridged to another Edge API: ${bridgedTo}`);
104104
this.AddToCalledDictionary(this.BridgedCalls, name);
105105
}
106106
return result;
107107
}
108108
catch (ex) {
109109
this.AddToCalledDictionary(this.FailedCalls, name);
110110
if (this.CatchOnException)
111-
this.error("API Call Failed: " + name + " - " + ex);
111+
this.error(`API Call Failed: ${name} - ${ex}`);
112112
else
113113
throw ex;
114114
}
@@ -118,10 +118,10 @@ class EdgeBridgeDebugLog {
118118
this.AddToCalledDictionary(this.EdgeIssues, name);
119119
}
120120
LogUnavailbleApi(name, deprecatedTo) {
121-
this.warn("API Call '" + name + "' is not supported in Edge");
121+
this.warn(`API Call '${name}' is not supported in Edge"`);
122122
this.AddToCalledDictionary(this.UnavailableApis, name);
123123
if (typeof deprecatedTo !== "undefined" && typeof deprecatedTo !== "null") {
124-
this.warn("API Call Deprecated - Name: " + name + ", Please use " + deprecatedTo + " instead!");
124+
this.warn(`API Call Deprecated - Name: ${name}, Please use ${deprecatedTo} instead!`);
125125
this.AddToCalledDictionary(this.DeprecatedCalls, name);
126126
}
127127
}

contentScriptsAPIBridge.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,19 @@ class EdgeBridgeDebugLog {
9696
result = action();
9797
this.AddToCalledDictionary(this.SuccededCalls, name);
9898
if (typeof deprecatedTo !== "undefined" && typeof deprecatedTo !== "null") {
99-
this.warn("API Call Deprecated - Name: " + name + ", Please use " + deprecatedTo + " instead!");
99+
this.warn(`API Call Deprecated - Name: ${name}, Please use ${deprecatedTo} instead!"`);
100100
this.AddToCalledDictionary(this.DeprecatedCalls, name);
101101
}
102102
if (typeof bridgedTo !== "undefined" && typeof bridgedTo !== "null") {
103-
this.info("API Call '" + name + "' has been bridged to another Edge API: " + bridgedTo);
103+
this.info(`API Call '${name}' has been bridged to another Edge API: ${bridgedTo}`);
104104
this.AddToCalledDictionary(this.BridgedCalls, name);
105105
}
106106
return result;
107107
}
108108
catch (ex) {
109109
this.AddToCalledDictionary(this.FailedCalls, name);
110110
if (this.CatchOnException)
111-
this.error("API Call Failed: " + name + " - " + ex);
111+
this.error(`API Call Failed: ${name} - ${ex}`);
112112
else
113113
throw ex;
114114
}
@@ -118,10 +118,10 @@ class EdgeBridgeDebugLog {
118118
this.AddToCalledDictionary(this.EdgeIssues, name);
119119
}
120120
LogUnavailbleApi(name, deprecatedTo) {
121-
this.warn("API Call '" + name + "' is not supported in Edge");
121+
this.warn(`API Call '${name}' is not supported in Edge`);
122122
this.AddToCalledDictionary(this.UnavailableApis, name);
123123
if (typeof deprecatedTo !== "undefined" && typeof deprecatedTo !== "null") {
124-
this.warn("API Call Deprecated - Name: " + name + ", Please use " + deprecatedTo + " instead!");
124+
this.warn(`API Call Deprecated - Name: ${name}, Please use ${deprecatedTo} instead!`);
125125
this.AddToCalledDictionary(this.DeprecatedCalls, name);
126126
}
127127
}

0 commit comments

Comments
 (0)