Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more eslint rules #97462

Merged
merged 3 commits into from
May 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/librustdoc/html/static/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,14 @@ module.exports = {
"comma-style": ["error", "last"],
"max-len": ["error", { "code": 100, "tabWidth": 4 }],
"eol-last": ["error", "always"],
"arrow-parens": ["error", "as-needed"],
"no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
],
"eqeqeq": "error",
}
};
4 changes: 2 additions & 2 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ function showMain() {
//
// So I guess you could say things are getting pretty interoperable.
function getVirtualKey(ev) {
if ("key" in ev && typeof ev.key != "undefined") {
if ("key" in ev && typeof ev.key !== "undefined") {
return ev.key;
}

const c = ev.charCode || ev.keyCode;
if (c == 27) {
if (c === 27) {
return "Escape";
}
return String.fromCharCode(c);
Expand Down
8 changes: 4 additions & 4 deletions src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function printTab(nb) {
});
if (foundCurrentTab && foundCurrentResultSet) {
searchState.currentTab = nb;
} else if (nb != 0) {
} else if (nb !== 0) {
printTab(0);
}
}
Expand Down Expand Up @@ -200,7 +200,7 @@ function initSearch(rawSearchIndex) {
* @return {boolean}
*/
function isPathStart(parserState) {
return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) == "::";
return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) === "::";
}

/**
Expand All @@ -211,7 +211,7 @@ function initSearch(rawSearchIndex) {
* @return {boolean}
*/
function isReturnArrow(parserState) {
return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) == "->";
return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) === "->";
}

/**
Expand Down Expand Up @@ -1726,7 +1726,7 @@ function initSearch(rawSearchIndex) {
crates = " in <select id=\"crate-search\"><option value=\"All crates\">" +
"All crates</option>";
for (const c of window.ALL_CRATES) {
crates += `<option value="${c}" ${c == filterCrates && "selected"}>${c}</option>`;
crates += `<option value="${c}" ${c === filterCrates && "selected"}>${c}</option>`;
}
crates += "</select>";
}
Expand Down