Skip to content

Commit b37b735

Browse files
authored
Rollup merge of #97462 - GuillaumeGomez:more-eslint-rules, r=notriddle
Add more eslint rules The last one is the most useful of this batch. :) Here are the links for the eslint rules: * [arrow-parens](https://eslint.org/docs/rules/arrow-parens) * [no-unused-vars](https://eslint.org/docs/rules/no-unused-vars) * [eqeqeq](https://eslint.org/docs/rules/eqeqeq) r? `@notriddle`
2 parents 0804ef6 + 334f12c commit b37b735

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

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

+9
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,14 @@ module.exports = {
5454
"comma-style": ["error", "last"],
5555
"max-len": ["error", { "code": 100, "tabWidth": 4 }],
5656
"eol-last": ["error", "always"],
57+
"arrow-parens": ["error", "as-needed"],
58+
"no-unused-vars": [
59+
"error",
60+
{
61+
"argsIgnorePattern": "^_",
62+
"varsIgnorePattern": "^_"
63+
}
64+
],
65+
"eqeqeq": "error",
5766
}
5867
};

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ function showMain() {
9797
//
9898
// So I guess you could say things are getting pretty interoperable.
9999
function getVirtualKey(ev) {
100-
if ("key" in ev && typeof ev.key != "undefined") {
100+
if ("key" in ev && typeof ev.key !== "undefined") {
101101
return ev.key;
102102
}
103103

104104
const c = ev.charCode || ev.keyCode;
105-
if (c == 27) {
105+
if (c === 27) {
106106
return "Escape";
107107
}
108108
return String.fromCharCode(c);

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function printTab(nb) {
7070
});
7171
if (foundCurrentTab && foundCurrentResultSet) {
7272
searchState.currentTab = nb;
73-
} else if (nb != 0) {
73+
} else if (nb !== 0) {
7474
printTab(0);
7575
}
7676
}
@@ -200,7 +200,7 @@ function initSearch(rawSearchIndex) {
200200
* @return {boolean}
201201
*/
202202
function isPathStart(parserState) {
203-
return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) == "::";
203+
return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) === "::";
204204
}
205205

206206
/**
@@ -211,7 +211,7 @@ function initSearch(rawSearchIndex) {
211211
* @return {boolean}
212212
*/
213213
function isReturnArrow(parserState) {
214-
return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) == "->";
214+
return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) === "->";
215215
}
216216

217217
/**
@@ -1726,7 +1726,7 @@ function initSearch(rawSearchIndex) {
17261726
crates = " in <select id=\"crate-search\"><option value=\"All crates\">" +
17271727
"All crates</option>";
17281728
for (const c of window.ALL_CRATES) {
1729-
crates += `<option value="${c}" ${c == filterCrates && "selected"}>${c}</option>`;
1729+
crates += `<option value="${c}" ${c === filterCrates && "selected"}>${c}</option>`;
17301730
}
17311731
crates += "</select>";
17321732
}

0 commit comments

Comments
 (0)