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`
This commit is contained in:
Matthias Krüger 2022-05-28 01:11:51 +02:00 committed by GitHub
commit b37b735038
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 6 deletions

View File

@ -54,5 +54,14 @@ module.exports = {
"comma-style": ["error", "last"], "comma-style": ["error", "last"],
"max-len": ["error", { "code": 100, "tabWidth": 4 }], "max-len": ["error", { "code": 100, "tabWidth": 4 }],
"eol-last": ["error", "always"], "eol-last": ["error", "always"],
"arrow-parens": ["error", "as-needed"],
"no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
],
"eqeqeq": "error",
} }
}; };

View File

@ -97,12 +97,12 @@ function showMain() {
// //
// So I guess you could say things are getting pretty interoperable. // So I guess you could say things are getting pretty interoperable.
function getVirtualKey(ev) { function getVirtualKey(ev) {
if ("key" in ev && typeof ev.key != "undefined") { if ("key" in ev && typeof ev.key !== "undefined") {
return ev.key; return ev.key;
} }
const c = ev.charCode || ev.keyCode; const c = ev.charCode || ev.keyCode;
if (c == 27) { if (c === 27) {
return "Escape"; return "Escape";
} }
return String.fromCharCode(c); return String.fromCharCode(c);

View File

@ -70,7 +70,7 @@ function printTab(nb) {
}); });
if (foundCurrentTab && foundCurrentResultSet) { if (foundCurrentTab && foundCurrentResultSet) {
searchState.currentTab = nb; searchState.currentTab = nb;
} else if (nb != 0) { } else if (nb !== 0) {
printTab(0); printTab(0);
} }
} }
@ -200,7 +200,7 @@ function initSearch(rawSearchIndex) {
* @return {boolean} * @return {boolean}
*/ */
function isPathStart(parserState) { function isPathStart(parserState) {
return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) == "::"; return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) === "::";
} }
/** /**
@ -211,7 +211,7 @@ function initSearch(rawSearchIndex) {
* @return {boolean} * @return {boolean}
*/ */
function isReturnArrow(parserState) { function isReturnArrow(parserState) {
return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) == "->"; return parserState.userQuery.slice(parserState.pos, parserState.pos + 2) === "->";
} }
/** /**
@ -1726,7 +1726,7 @@ function initSearch(rawSearchIndex) {
crates = " in <select id=\"crate-search\"><option value=\"All crates\">" + crates = " in <select id=\"crate-search\"><option value=\"All crates\">" +
"All crates</option>"; "All crates</option>";
for (const c of window.ALL_CRATES) { 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>"; crates += "</select>";
} }