Skip to content

Commit f41d284

Browse files
Fix eslint lints
1 parent 872ddf2 commit f41d284

File tree

4 files changed

+34
-34
lines changed

4 files changed

+34
-34
lines changed

src/librustdoc/html/static/main.js

+23-31
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// Local js definitions:
55
/* global addClass, getCurrentValue, hasClass */
6-
/* global onEach, removeClass, updateLocalStorage */
6+
/* global onEachLazy, hasOwnProperty, removeClass, updateLocalStorage */
77

88
if (!String.prototype.startsWith) {
99
String.prototype.startsWith = function(searchString, position) {
@@ -192,6 +192,7 @@ function defocusSearchBar() {
192192
var savedHash = "";
193193

194194
function handleHashes(ev) {
195+
var elem;
195196
var search = getSearchElement();
196197
if (ev !== null && search && !hasClass(search, "hidden") && ev.newURL) {
197198
// This block occurs when clicking on an element in the navbar while
@@ -201,7 +202,7 @@ function defocusSearchBar() {
201202
if (browserSupportsHistoryApi()) {
202203
history.replaceState(hash, "", "?search=#" + hash);
203204
}
204-
var elem = document.getElementById(hash);
205+
elem = document.getElementById(hash);
205206
if (elem) {
206207
elem.scrollIntoView();
207208
}
@@ -212,7 +213,7 @@ function defocusSearchBar() {
212213
if (savedHash.length === 0) {
213214
return;
214215
}
215-
var elem = document.getElementById(savedHash.slice(1)); // we remove the '#'
216+
elem = document.getElementById(savedHash.slice(1)); // we remove the '#'
216217
if (!elem || !isHidden(elem)) {
217218
return;
218219
}
@@ -335,7 +336,7 @@ function defocusSearchBar() {
335336
}
336337

337338
function displayHelp(display, ev, help) {
338-
var help = help ? help : getHelpElement();
339+
help = help ? help : getHelpElement();
339340
if (display === true) {
340341
if (hasClass(help, "hidden")) {
341342
ev.preventDefault();
@@ -449,7 +450,7 @@ function defocusSearchBar() {
449450

450451
set_fragment(cur_line_id);
451452
}
452-
}
453+
};
453454
}());
454455

455456
document.addEventListener("click", function(ev) {
@@ -615,7 +616,7 @@ function defocusSearchBar() {
615616
function sortResults(results, isType) {
616617
var ar = [];
617618
for (var entry in results) {
618-
if (results.hasOwnProperty(entry)) {
619+
if (hasOwnProperty(results, entry)) {
619620
ar.push(results[entry]);
620621
}
621622
}
@@ -1113,8 +1114,6 @@ function defocusSearchBar() {
11131114
}
11141115
fullId = generateId(ty);
11151116

1116-
// allow searching for void (no output) functions as well
1117-
var typeOutput = type.length > OUTPUT_DATA ? type[OUTPUT_DATA].name : "";
11181117
returned = checkReturned(ty, output, true, NO_TYPE_FILTER);
11191118
if (output.name === "*" || returned === true) {
11201119
in_args = false;
@@ -1177,7 +1176,6 @@ function defocusSearchBar() {
11771176
var contains = paths.slice(0, paths.length > 1 ? paths.length - 1 : 1);
11781177

11791178
var lev;
1180-
var lev_distance;
11811179
for (j = 0; j < nSearchWords; ++j) {
11821180
ty = searchIndex[j];
11831181
if (!ty || (filterCrates !== undefined && ty.crate !== filterCrates)) {
@@ -1674,7 +1672,7 @@ function defocusSearchBar() {
16741672
function getFilterCrates() {
16751673
var elem = document.getElementById("crate-search");
16761674

1677-
if (elem && elem.value !== "All crates" && rawSearchIndex.hasOwnProperty(elem.value)) {
1675+
if (elem && elem.value !== "All crates" && hasOwnProperty(rawSearchIndex, elem.value)) {
16781676
return elem.value;
16791677
}
16801678
return undefined;
@@ -1722,7 +1720,7 @@ function defocusSearchBar() {
17221720
var currentIndex = 0;
17231721

17241722
for (var crate in rawSearchIndex) {
1725-
if (!rawSearchIndex.hasOwnProperty(crate)) { continue; }
1723+
if (!hasOwnProperty(rawSearchIndex, crate)) { continue; }
17261724

17271725
var crateSize = 0;
17281726

@@ -1906,7 +1904,7 @@ function defocusSearchBar() {
19061904

19071905
var crates = [];
19081906
for (var crate in rawSearchIndex) {
1909-
if (!rawSearchIndex.hasOwnProperty(crate)) {
1907+
if (!hasOwnProperty(rawSearchIndex, crate)) {
19101908
continue;
19111909
}
19121910
crates.push(crate);
@@ -2173,19 +2171,13 @@ function defocusSearchBar() {
21732171
}
21742172
}
21752173
var ns = n.nextElementSibling;
2176-
while (true) {
2177-
if (ns && (
2178-
hasClass(ns, "docblock") ||
2179-
hasClass(ns, "stability"))) {
2180-
if (addOrRemove) {
2181-
addClass(ns, "hidden-by-impl-hider");
2182-
} else {
2183-
removeClass(ns, "hidden-by-impl-hider");
2184-
}
2185-
ns = ns.nextElementSibling;
2186-
continue;
2174+
while (ns && (hasClass(ns, "docblock") || hasClass(ns, "stability"))) {
2175+
if (addOrRemove) {
2176+
addClass(ns, "hidden-by-impl-hider");
2177+
} else {
2178+
removeClass(ns, "hidden-by-impl-hider");
21872179
}
2188-
break;
2180+
ns = ns.nextElementSibling;
21892181
}
21902182
}
21912183
};
@@ -2482,7 +2474,7 @@ function defocusSearchBar() {
24822474
onEachLazy(inner_toggle.getElementsByClassName("toggle-label"), function(e) {
24832475
e.style.display = "inline-block";
24842476
if (extra === true) {
2485-
i_e.innerHTML = " Show " + e.childNodes[0].innerHTML;
2477+
e.innerHTML = " Show " + e.childNodes[0].innerHTML;
24862478
}
24872479
});
24882480
}
@@ -2587,17 +2579,17 @@ function defocusSearchBar() {
25872579
}
25882580
onEachLazy(document.getElementsByClassName("rust-example-rendered"), function(e) {
25892581
if (hasClass(e, "compile_fail")) {
2590-
e.addEventListener("mouseover", function(event) {
2582+
e.addEventListener("mouseover", function() {
25912583
this.parentElement.previousElementSibling.childNodes[0].style.color = "#f00";
25922584
});
2593-
e.addEventListener("mouseout", function(event) {
2585+
e.addEventListener("mouseout", function() {
25942586
this.parentElement.previousElementSibling.childNodes[0].style.color = "";
25952587
});
25962588
} else if (hasClass(e, "ignore")) {
2597-
e.addEventListener("mouseover", function(event) {
2589+
e.addEventListener("mouseover", function() {
25982590
this.parentElement.previousElementSibling.childNodes[0].style.color = "#ff9200";
25992591
});
2600-
e.addEventListener("mouseout", function(event) {
2592+
e.addEventListener("mouseout", function() {
26012593
this.parentElement.previousElementSibling.childNodes[0].style.color = "";
26022594
});
26032595
}
@@ -2705,7 +2697,7 @@ function defocusSearchBar() {
27052697
var crates_text = [];
27062698
if (Object.keys(crates).length > 1) {
27072699
for (var crate in crates) {
2708-
if (crates.hasOwnProperty(crate)) {
2700+
if (hasOwnProperty(crates, crate)) {
27092701
crates_text.push(crate);
27102702
}
27112703
}
@@ -2740,7 +2732,7 @@ function defocusSearchBar() {
27402732

27412733
if (search_input) {
27422734
search_input.removeAttribute('disabled');
2743-
};
2735+
}
27442736
};
27452737

27462738
function buildHelperPopup() {

src/librustdoc/html/static/settings.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Local js definitions:
2+
/* global getCurrentValue, updateLocalStorage */
3+
14
(function () {
25
function changeSetting(settingName, isEnabled) {
36
updateLocalStorage('rustdoc-' + settingName, isEnabled);

src/librustdoc/html/static/source-script.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// From rust:
2-
/* global sourcesIndex */
2+
/* global search, sourcesIndex */
33

44
// Local js definitions:
55
/* global addClass, getCurrentValue, hasClass, removeClass, updateLocalStorage */

src/librustdoc/html/static/storage.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ function removeClass(elem, className) {
2727
function onEach(arr, func, reversed) {
2828
if (arr && arr.length > 0 && func) {
2929
var length = arr.length;
30+
var i;
3031
if (reversed !== true) {
31-
for (var i = 0; i < length; ++i) {
32+
for (i = 0; i < length; ++i) {
3233
if (func(arr[i]) === true) {
3334
return true;
3435
}
3536
}
3637
} else {
37-
for (var i = length - 1; i >= 0; --i) {
38+
for (i = length - 1; i >= 0; --i) {
3839
if (func(arr[i]) === true) {
3940
return true;
4041
}
@@ -51,6 +52,10 @@ function onEachLazy(lazyArray, func, reversed) {
5152
reversed);
5253
}
5354

55+
function hasOwnProperty(obj, property) {
56+
return Object.prototype.hasOwnProperty.call(obj, property);
57+
}
58+
5459
function usableLocalStorage() {
5560
// Check if the browser supports localStorage at all:
5661
if (typeof Storage === "undefined") {

0 commit comments

Comments
 (0)