Rollup merge of #85323 - GuillaumeGomez:fix-eslint-errors, r=jsha
Fix eslint errors I cherry-picked the two non-CI commits from #85285. r? ```@jsha```
This commit is contained in:
commit
46bc5526db
@ -1,6 +1,6 @@
|
||||
// Local js definitions:
|
||||
/* global addClass, getSettingValue, hasClass */
|
||||
/* global onEach, onEachLazy, hasOwnProperty, removeClass, updateLocalStorage */
|
||||
/* global addClass, getSettingValue, hasClass, searchState */
|
||||
/* global onEach, onEachLazy, removeClass */
|
||||
/* global switchTheme, useSystemTheme */
|
||||
|
||||
if (!String.prototype.startsWith) {
|
||||
@ -347,10 +347,6 @@ function hideThemeButtonState() {
|
||||
document.getElementsByTagName("body")[0].style.marginTop = "";
|
||||
}
|
||||
|
||||
function isHidden(elem) {
|
||||
return elem.offsetHeight === 0;
|
||||
}
|
||||
|
||||
var toggleAllDocsId = "toggle-all-docs";
|
||||
var main = document.getElementById("main");
|
||||
var savedHash = "";
|
||||
@ -553,7 +549,7 @@ function hideThemeButtonState() {
|
||||
len = window.rootPath.match(/\.\.\//g).length + 1;
|
||||
|
||||
for (i = 0; i < len; ++i) {
|
||||
match = url.match(/\/[^\/]*$/);
|
||||
match = url.match(/\/[^/]*$/);
|
||||
if (i < len - 1) {
|
||||
stripped = match[0] + stripped;
|
||||
}
|
||||
@ -952,13 +948,11 @@ function hideThemeButtonState() {
|
||||
});
|
||||
|
||||
var currentType = document.getElementsByClassName("type-decl")[0];
|
||||
var className = null;
|
||||
if (currentType) {
|
||||
currentType = currentType.getElementsByClassName("rust")[0];
|
||||
if (currentType) {
|
||||
onEachLazy(currentType.classList, function(item) {
|
||||
if (item !== "main") {
|
||||
className = item;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@ -1047,7 +1041,7 @@ function hideThemeButtonState() {
|
||||
};
|
||||
}
|
||||
|
||||
function buildHelperPopup() {
|
||||
var buildHelperPopup = function() {
|
||||
var popup = document.createElement("aside");
|
||||
addClass(popup, "hidden");
|
||||
popup.id = "help";
|
||||
@ -1114,7 +1108,7 @@ function hideThemeButtonState() {
|
||||
insertAfter(popup, searchState.outputElement());
|
||||
// So that it's only built once and then it'll do nothing when called!
|
||||
buildHelperPopup = function() {};
|
||||
}
|
||||
};
|
||||
|
||||
onHashChange(null);
|
||||
window.addEventListener("hashchange", onHashChange);
|
||||
|
@ -1,3 +1,6 @@
|
||||
/* global addClass, getNakedUrl, getSettingValue, hasOwnPropertyRustdoc, initSearch, onEach */
|
||||
/* global onEachLazy, removeClass, searchState, updateLocalStorage */
|
||||
|
||||
(function() {
|
||||
// This mapping table should match the discriminants of
|
||||
// `rustdoc::html::item_type::ItemType` type in Rust.
|
||||
@ -170,7 +173,7 @@ window.initSearch = function(rawSearchIndex) {
|
||||
function sortResults(results, isType) {
|
||||
var ar = [];
|
||||
for (var entry in results) {
|
||||
if (hasOwnProperty(results, entry)) {
|
||||
if (hasOwnPropertyRustdoc(results, entry)) {
|
||||
ar.push(results[entry]);
|
||||
}
|
||||
}
|
||||
@ -254,7 +257,7 @@ window.initSearch = function(rawSearchIndex) {
|
||||
});
|
||||
|
||||
for (i = 0, len = results.length; i < len; ++i) {
|
||||
var result = results[i];
|
||||
result = results[i];
|
||||
|
||||
// this validation does not make sense when searching by types
|
||||
if (result.dontValidate) {
|
||||
@ -301,7 +304,7 @@ window.initSearch = function(rawSearchIndex) {
|
||||
if (obj.length > GENERICS_DATA &&
|
||||
obj[GENERICS_DATA].length >= val.generics.length) {
|
||||
var elems = Object.create(null);
|
||||
var elength = object[GENERICS_DATA].length;
|
||||
var elength = obj[GENERICS_DATA].length;
|
||||
for (var x = 0; x < elength; ++x) {
|
||||
elems[getObjectNameFromId(obj[GENERICS_DATA][x])] += 1;
|
||||
}
|
||||
@ -717,7 +720,7 @@ window.initSearch = function(rawSearchIndex) {
|
||||
query.output = val;
|
||||
query.search = val;
|
||||
// gather matching search results up to a certain maximum
|
||||
val = val.replace(/\_/g, "");
|
||||
val = val.replace(/_/g, "");
|
||||
|
||||
var valGenerics = extractGenerics(val);
|
||||
|
||||
@ -1242,7 +1245,9 @@ window.initSearch = function(rawSearchIndex) {
|
||||
function getFilterCrates() {
|
||||
var elem = document.getElementById("crate-search");
|
||||
|
||||
if (elem && elem.value !== "All crates" && hasOwnProperty(rawSearchIndex, elem.value)) {
|
||||
if (elem && elem.value !== "All crates" &&
|
||||
hasOwnPropertyRustdoc(rawSearchIndex, elem.value))
|
||||
{
|
||||
return elem.value;
|
||||
}
|
||||
return undefined;
|
||||
@ -1293,14 +1298,13 @@ window.initSearch = function(rawSearchIndex) {
|
||||
var id = 0;
|
||||
|
||||
for (var crate in rawSearchIndex) {
|
||||
if (!hasOwnProperty(rawSearchIndex, crate)) { continue; }
|
||||
if (!hasOwnPropertyRustdoc(rawSearchIndex, crate)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var crateSize = 0;
|
||||
|
||||
searchWords.push(crate);
|
||||
var normalizedName = crate.indexOf("_") === -1
|
||||
? crate
|
||||
: crate.replace(/_/g, "");
|
||||
// This object should have exactly the same set of fields as the "row"
|
||||
// object defined below. Your JavaScript runtime will thank you.
|
||||
// https://mathiasbynens.be/notes/shapes-ics
|
||||
@ -1313,7 +1317,7 @@ window.initSearch = function(rawSearchIndex) {
|
||||
parent: undefined,
|
||||
type: null,
|
||||
id: id,
|
||||
normalizedName: normalizedName,
|
||||
normalizedName: crate.indexOf("_") === -1 ? crate : crate.replace(/_/g, ""),
|
||||
};
|
||||
id += 1;
|
||||
searchIndex.push(crateRow);
|
||||
@ -1363,9 +1367,6 @@ window.initSearch = function(rawSearchIndex) {
|
||||
word = "";
|
||||
searchWords.push("");
|
||||
}
|
||||
var normalizedName = word.indexOf("_") === -1
|
||||
? word
|
||||
: word.replace(/_/g, "");
|
||||
var row = {
|
||||
crate: crate,
|
||||
ty: itemTypes[i],
|
||||
@ -1375,7 +1376,7 @@ window.initSearch = function(rawSearchIndex) {
|
||||
parent: itemParentIdxs[i] > 0 ? paths[itemParentIdxs[i] - 1] : undefined,
|
||||
type: itemFunctionSearchTypes[i],
|
||||
id: id,
|
||||
normalizedName: normalizedName,
|
||||
normalizedName: word.indexOf("_") === -1 ? word : word.replace(/_/g, ""),
|
||||
};
|
||||
id += 1;
|
||||
searchIndex.push(row);
|
||||
@ -1387,9 +1388,11 @@ window.initSearch = function(rawSearchIndex) {
|
||||
ALIASES[crate] = {};
|
||||
var j, local_aliases;
|
||||
for (var alias_name in aliases) {
|
||||
if (!aliases.hasOwnProperty(alias_name)) { continue; }
|
||||
if (!hasOwnPropertyRustdoc(aliases, alias_name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!ALIASES[crate].hasOwnProperty(alias_name)) {
|
||||
if (!hasOwnPropertyRustdoc(ALIASES[crate], alias_name)) {
|
||||
ALIASES[crate][alias_name] = [];
|
||||
}
|
||||
local_aliases = aliases[alias_name];
|
||||
|
@ -2,7 +2,8 @@
|
||||
/* global search, sourcesIndex */
|
||||
|
||||
// Local js definitions:
|
||||
/* global addClass, getCurrentValue, hasClass, removeClass, updateLocalStorage */
|
||||
/* global addClass, getCurrentValue, hasClass, onEachLazy, removeClass, searchState */
|
||||
/* global updateLocalStorage */
|
||||
(function() {
|
||||
|
||||
function getCurrentFilePath() {
|
||||
@ -153,7 +154,7 @@ function createSourceSidebar() {
|
||||
|
||||
var lineNumbersRegex = /^#?(\d+)(?:-(\d+))?$/;
|
||||
|
||||
function highlightSourceLines(match, ev) {
|
||||
function highlightSourceLines(scrollTo, match) {
|
||||
if (typeof match === "undefined") {
|
||||
match = window.location.hash.match(lineNumbersRegex);
|
||||
}
|
||||
@ -174,7 +175,7 @@ function highlightSourceLines(match, ev) {
|
||||
if (!elem) {
|
||||
return;
|
||||
}
|
||||
if (!ev) {
|
||||
if (scrollTo) {
|
||||
var x = document.getElementById(from);
|
||||
if (x) {
|
||||
x.scrollIntoView();
|
||||
@ -202,7 +203,7 @@ var handleSourceHighlight = (function() {
|
||||
y = window.scrollY;
|
||||
if (searchState.browserSupportsHistoryApi()) {
|
||||
history.replaceState(null, null, "#" + name);
|
||||
highlightSourceLines();
|
||||
highlightSourceLines(true);
|
||||
} else {
|
||||
location.replace("#" + name);
|
||||
}
|
||||
@ -234,7 +235,7 @@ var handleSourceHighlight = (function() {
|
||||
window.addEventListener("hashchange", function() {
|
||||
var match = window.location.hash.match(lineNumbersRegex);
|
||||
if (match) {
|
||||
return highlightSourceLines(match, ev);
|
||||
return highlightSourceLines(false, match);
|
||||
}
|
||||
});
|
||||
|
||||
@ -242,7 +243,7 @@ onEachLazy(document.getElementsByClassName("line-numbers"), function(el) {
|
||||
el.addEventListener("click", handleSourceHighlight);
|
||||
});
|
||||
|
||||
highlightSourceLines();
|
||||
highlightSourceLines(true);
|
||||
|
||||
window.createSourceSidebar = createSourceSidebar;
|
||||
})();
|
||||
|
@ -84,7 +84,7 @@ function onEachLazy(lazyArray, func, reversed) {
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function hasOwnProperty(obj, property) {
|
||||
function hasOwnPropertyRustdoc(obj, property) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, property);
|
||||
}
|
||||
|
||||
|
@ -267,9 +267,10 @@ function loadSearchJsAndIndex(searchJs, searchIndex, storageJs, crate) {
|
||||
"handleAliases", "getQuery", "buildIndex", "execQuery", "execSearch",
|
||||
"removeEmptyStringsFromArray"];
|
||||
|
||||
const functions = ["hasOwnPropertyRustdoc", "onEach"];
|
||||
ALIASES = {};
|
||||
finalJS += 'window = { "currentCrate": "' + crate + '", rootPath: "../" };\n';
|
||||
finalJS += loadThings(["hasOwnProperty", "onEach"], 'function', extractFunction, storageJs);
|
||||
finalJS += loadThings(functions, 'function', extractFunction, storageJs);
|
||||
finalJS += loadThings(arraysToLoad, 'array', extractArrayVariable, searchJs);
|
||||
finalJS += loadThings(variablesToLoad, 'variable', extractVariable, searchJs);
|
||||
finalJS += loadThings(functionsToLoad, 'function', extractFunction, searchJs);
|
||||
|
Loading…
Reference in New Issue
Block a user