Skip to content

Commit 1489718

Browse files
Enforce quote rule for JS source code
1 parent f9b2e3c commit 1489718

File tree

6 files changed

+56
-52
lines changed

6 files changed

+56
-52
lines changed

src/librustdoc/html/static/.eslintrc.js

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ module.exports = {
1717
"error",
1818
"always"
1919
],
20+
"quotes": [
21+
"error",
22+
"double"
23+
],
2024
"no-var": ["error"],
2125
"prefer-const": ["error"],
2226
"prefer-arrow-callback": ["error"],

src/librustdoc/html/static/js/main.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ function loadCss(cssFileName) {
291291

292292
(function() {
293293
function loadScript(url) {
294-
const script = document.createElement('script');
294+
const script = document.createElement("script");
295295
script.src = url;
296296
document.head.append(script);
297297
}
@@ -344,7 +344,7 @@ function loadCss(cssFileName) {
344344
searchState.input.blur();
345345
},
346346
showResults: search => {
347-
if (search === null || typeof search === 'undefined') {
347+
if (search === null || typeof search === "undefined") {
348348
search = searchState.outputElement();
349349
}
350350
switchDisplayedElement(search);
@@ -390,7 +390,7 @@ function loadCss(cssFileName) {
390390
loadSearch();
391391
});
392392

393-
if (search_input.value !== '') {
393+
if (search_input.value !== "") {
394394
loadSearch();
395395
}
396396

@@ -968,7 +968,7 @@ function loadCss(cssFileName) {
968968

969969
onEachLazy(document.getElementsByClassName("notable-traits"), e => {
970970
e.onclick = function() {
971-
this.getElementsByClassName('notable-traits-tooltiptext')[0]
971+
this.getElementsByClassName("notable-traits-tooltiptext")[0]
972972
.classList.toggle("force-tooltip");
973973
};
974974
});
@@ -1070,29 +1070,29 @@ function loadCss(cssFileName) {
10701070
const path = [];
10711071

10721072
onEach(parent.childNodes, child => {
1073-
if (child.tagName === 'A') {
1073+
if (child.tagName === "A") {
10741074
path.push(child.textContent);
10751075
}
10761076
});
10771077

1078-
const el = document.createElement('textarea');
1079-
el.value = path.join('::');
1080-
el.setAttribute('readonly', '');
1078+
const el = document.createElement("textarea");
1079+
el.value = path.join("::");
1080+
el.setAttribute("readonly", "");
10811081
// To not make it appear on the screen.
1082-
el.style.position = 'absolute';
1083-
el.style.left = '-9999px';
1082+
el.style.position = "absolute";
1083+
el.style.left = "-9999px";
10841084

10851085
document.body.appendChild(el);
10861086
el.select();
1087-
document.execCommand('copy');
1087+
document.execCommand("copy");
10881088
document.body.removeChild(el);
10891089

10901090
// There is always one children, but multiple childNodes.
1091-
but.children[0].style.display = 'none';
1091+
but.children[0].style.display = "none";
10921092

10931093
let tmp;
10941094
if (but.childNodes.length < 2) {
1095-
tmp = document.createTextNode('✓');
1095+
tmp = document.createTextNode("✓");
10961096
but.appendChild(tmp);
10971097
} else {
10981098
onEachLazy(but.childNodes, e => {
@@ -1101,15 +1101,15 @@ function loadCss(cssFileName) {
11011101
return true;
11021102
}
11031103
});
1104-
tmp.textContent = '✓';
1104+
tmp.textContent = "✓";
11051105
}
11061106

11071107
if (reset_button_timeout !== null) {
11081108
window.clearTimeout(reset_button_timeout);
11091109
}
11101110

11111111
function reset_button() {
1112-
tmp.textContent = '';
1112+
tmp.textContent = "";
11131113
reset_button_timeout = null;
11141114
but.children[0].style.display = "";
11151115
}

src/librustdoc/html/static/js/scrape-examples.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// Scroll code block to the given code location
1010
function scrollToLoc(elt, loc) {
11-
const lines = elt.querySelector('.line-numbers');
11+
const lines = elt.querySelector(".line-numbers");
1212
let scrollOffset;
1313

1414
// If the block is greater than the size of the viewer,
@@ -32,16 +32,16 @@
3232
function updateScrapedExample(example) {
3333
const locs = JSON.parse(example.attributes.getNamedItem("data-locs").textContent);
3434
let locIndex = 0;
35-
const highlights = Array.prototype.slice.call(example.querySelectorAll('.highlight'));
36-
const link = example.querySelector('.scraped-example-title a');
35+
const highlights = Array.prototype.slice.call(example.querySelectorAll(".highlight"));
36+
const link = example.querySelector(".scraped-example-title a");
3737

3838
if (locs.length > 1) {
3939
// Toggle through list of examples in a given file
4040
const onChangeLoc = changeIndex => {
41-
removeClass(highlights[locIndex], 'focus');
41+
removeClass(highlights[locIndex], "focus");
4242
changeIndex();
4343
scrollToLoc(example, locs[locIndex][0]);
44-
addClass(highlights[locIndex], 'focus');
44+
addClass(highlights[locIndex], "focus");
4545

4646
const url = locs[locIndex][1];
4747
const title = locs[locIndex][2];
@@ -50,24 +50,24 @@
5050
link.innerHTML = title;
5151
};
5252

53-
example.querySelector('.prev')
54-
.addEventListener('click', () => {
53+
example.querySelector(".prev")
54+
.addEventListener("click", () => {
5555
onChangeLoc(() => {
5656
locIndex = (locIndex - 1 + locs.length) % locs.length;
5757
});
5858
});
5959

60-
example.querySelector('.next')
61-
.addEventListener('click', () => {
60+
example.querySelector("next")
61+
.addEventListener("click", () => {
6262
onChangeLoc(() => {
6363
locIndex = (locIndex + 1) % locs.length;
6464
});
6565
});
6666
}
6767

68-
const expandButton = example.querySelector('.expand');
68+
const expandButton = example.querySelector(".expand");
6969
if (expandButton) {
70-
expandButton.addEventListener('click', () => {
70+
expandButton.addEventListener("click", () => {
7171
if (hasClass(example, "expanded")) {
7272
removeClass(example, "expanded");
7373
scrollToLoc(example, locs[0][0]);
@@ -81,19 +81,19 @@
8181
scrollToLoc(example, locs[0][0]);
8282
}
8383

84-
const firstExamples = document.querySelectorAll('.scraped-example-list > .scraped-example');
84+
const firstExamples = document.querySelectorAll(".scraped-example-list > .scraped-example");
8585
onEachLazy(firstExamples, updateScrapedExample);
86-
onEachLazy(document.querySelectorAll('.more-examples-toggle'), toggle => {
86+
onEachLazy(document.querySelectorAll(".more-examples-toggle"), toggle => {
8787
// Allow users to click the left border of the <details> section to close it,
8888
// since the section can be large and finding the [+] button is annoying.
89-
onEachLazy(toggle.querySelectorAll('.toggle-line, .hide-more'), button => {
90-
button.addEventListener('click', () => {
89+
onEachLazy(toggle.querySelectorAll(".toggle-line, .hide-more"), button => {
90+
button.addEventListener("click", () => {
9191
toggle.open = false;
9292
});
9393
});
9494

95-
const moreExamples = toggle.querySelectorAll('.scraped-example');
96-
toggle.querySelector('summary').addEventListener('click', () => {
95+
const moreExamples = toggle.querySelectorAll(".scraped-example");
96+
toggle.querySelector("summary").addEventListener("click", () => {
9797
// Wrapping in setTimeout ensures the update happens after the elements are actually
9898
// visible. This is necessary since updateScrapedExample calls scrollToLoc which
9999
// depends on offsetHeight, a property that requires an element to be visible to

src/librustdoc/html/static/js/search.js

+14-13
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ window.initSearch = rawSearchIndex => {
204204
* @return {boolean}
205205
*/
206206
function isPathStart(parserState) {
207-
return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) == '::';
207+
return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) == "::";
208208
}
209209

210210
/**
@@ -215,7 +215,7 @@ window.initSearch = rawSearchIndex => {
215215
* @return {boolean}
216216
*/
217217
function isReturnArrow(parserState) {
218-
return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) == '->';
218+
return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) == "->";
219219
}
220220

221221
/**
@@ -227,10 +227,10 @@ window.initSearch = rawSearchIndex => {
227227
*/
228228
function isIdentCharacter(c) {
229229
return (
230-
c === '_' ||
231-
(c >= '0' && c <= '9') ||
232-
(c >= 'a' && c <= 'z') ||
233-
(c >= 'A' && c <= 'Z'));
230+
c === "_" ||
231+
(c >= "0" && c <= "9") ||
232+
(c >= "a" && c <= "z") ||
233+
(c >= "A" && c <= "Z"));
234234
}
235235

236236
/**
@@ -264,7 +264,7 @@ window.initSearch = rawSearchIndex => {
264264
* @return {QueryElement} - The newly created `QueryElement`.
265265
*/
266266
function createQueryElement(query, parserState, name, generics, isInGenerics) {
267-
if (name === '*' || (name.length === 0 && generics.length === 0)) {
267+
if (name === "*" || (name.length === 0 && generics.length === 0)) {
268268
return;
269269
}
270270
if (query.literalSearch && parserState.totalElems - parserState.genericsElems > 0) {
@@ -1708,29 +1708,30 @@ window.initSearch = rawSearchIndex => {
17081708

17091709
let crates = "";
17101710
if (window.ALL_CRATES.length > 1) {
1711-
crates = ` in <select id="crate-search"><option value="All crates">All crates</option>`;
1711+
crates = " in <select id=\"crate-search\"><option value=\"All crates\">" +
1712+
"All crates</option>";
17121713
for (const c of window.ALL_CRATES) {
17131714
crates += `<option value="${c}" ${c == filterCrates && "selected"}>${c}</option>`;
17141715
}
1715-
crates += `</select>`;
1716+
crates += "</select>";
17161717
}
17171718

17181719
let typeFilter = "";
17191720
if (results.query.typeFilter !== NO_TYPE_FILTER) {
17201721
typeFilter = " (type: " + escape(itemTypes[results.query.typeFilter]) + ")";
17211722
}
17221723

1723-
let output = `<div id="search-settings">` +
1724+
let output = "<div id=\"search-settings\">" +
17241725
`<h1 class="search-results-title">Results for ${escape(results.query.userQuery)}` +
17251726
`${typeFilter}</h1> in ${crates} </div>`;
17261727
if (results.query.error !== null) {
17271728
output += `<h3>Query parser error: "${results.query.error}".</h3>`;
1728-
output += '<div id="titles">' +
1729+
output += "<div id=\"titles\">" +
17291730
makeTabHeader(0, "In Names", ret_others[1]) +
17301731
"</div>";
17311732
currentTab = 0;
17321733
} else if (results.query.foundElems <= 1 && results.query.returned.length === 0) {
1733-
output += `<div id="titles">` +
1734+
output += "<div id=\"titles\">" +
17341735
makeTabHeader(0, "In Names", ret_others[1]) +
17351736
makeTabHeader(1, "In Parameters", ret_in_args[1]) +
17361737
makeTabHeader(2, "In Return Types", ret_returned[1]) +
@@ -1740,7 +1741,7 @@ window.initSearch = rawSearchIndex => {
17401741
results.query.elems.length === 0 ? "In Function Return Types" :
17411742
results.query.returned.length === 0 ? "In Function Parameters" :
17421743
"In Function Signatures";
1743-
output += '<div id="titles">' +
1744+
output += "<div id=\"titles\">" +
17441745
makeTabHeader(0, signatureTabTitle, ret_others[1]) +
17451746
"</div>";
17461747
currentTab = 0;

src/librustdoc/html/static/js/settings.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
let output = "";
109109

110110
for (const setting of settings) {
111-
output += `<div class="setting-line">`;
111+
output += "<div class=\"setting-line\">";
112112
const js_data_name = setting["js_name"];
113113
const setting_name = setting["name"];
114114

@@ -217,11 +217,10 @@
217217

218218
if (isSettingsPage) {
219219
innerHTML +=
220-
`<a id="back" href="javascript:void(0)" onclick="history.back();">Back</a>`;
220+
"<a id=\"back\" href=\"javascript:void(0)\" onclick=\"history.back();\">Back</a>";
221221
} else {
222-
innerHTML +=
223-
`<a id="back" href="javascript:void(0)" onclick="switchDisplayedElement(null);">\
224-
Back</a>`;
222+
innerHTML += "<a id=\"back\" href=\"javascript:void(0)\" " +
223+
"onclick=\"switchDisplayedElement(null);\">Back</a>";
225224
}
226225
innerHTML += `</span>
227226
</div>

src/librustdoc/html/static/js/storage.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function getSettingValue(settingName) {
2424
if (settingsDataset !== null) {
2525
// See the comment for `default_settings.into_iter()` etc. in
2626
// `Options::from_matches` in `librustdoc/config.rs`.
27-
const def = settingsDataset[settingName.replace(/-/g,'_')];
27+
const def = settingsDataset[settingName.replace(/-/g,"_")];
2828
if (def !== undefined) {
2929
return def;
3030
}
@@ -173,7 +173,7 @@ const updateSystemTheme = (function () {
173173
// fallback to the CSS computed value
174174
return () => {
175175
const cssTheme = getComputedStyle(document.documentElement)
176-
.getPropertyValue('content');
176+
.getPropertyValue("content");
177177

178178
switchTheme(
179179
window.currentTheme,

0 commit comments

Comments
 (0)