From ad95df2214342f98602e33153c9271c5569f7011 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Tue, 6 Aug 2024 18:27:07 +0200 Subject: [PATCH 1/2] Enable the `unicorn/prefer-includes` linting rule For more information refer to https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-includes.md. Fortunately this only required one change because we already use `.includes()` everywhere else. Note that that is mostly due to the `mozilla/use-includes-instead-of-indexOf` rule which we replace with this new rule now because it's more complete. --- .eslintrc | 2 +- test/driver.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.eslintrc b/.eslintrc index 77433e7c9..2b2d0a580 100644 --- a/.eslintrc +++ b/.eslintrc @@ -45,7 +45,6 @@ "ignore": ["display", "pdfjs", "pdfjs-lib", "pdfjs-web", "web", "fluent-bundle", "fluent-dom"], }], "mozilla/avoid-removeChild": "error", - "mozilla/use-includes-instead-of-indexOf": "error", "no-unsanitized/method": "error", "no-unsanitized/property": "error", "sort-exports/sort-exports": ["error", { @@ -70,6 +69,7 @@ "unicorn/prefer-date-now": "error", "unicorn/prefer-dom-node-append": "error", "unicorn/prefer-dom-node-remove": "error", + "unicorn/prefer-includes": "error", "unicorn/prefer-logical-operator-over-ternary": "error", "unicorn/prefer-modern-dom-apis": "error", "unicorn/prefer-modern-math-apis": "error", diff --git a/test/driver.js b/test/driver.js index 362c3d33d..c79c30601 100644 --- a/test/driver.js +++ b/test/driver.js @@ -1075,7 +1075,7 @@ class Driver { this.output.textContent += message; } - if (message.lastIndexOf("\n") >= 0 && !this.disableScrolling.checked) { + if (message.includes("\n") && !this.disableScrolling.checked) { // Scroll to the bottom of the page this.output.scrollTop = this.output.scrollHeight; } From 318433b2d8916b2971e2c7333ded1cc89f21abfd Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Tue, 6 Aug 2024 18:36:25 +0200 Subject: [PATCH 2/2] Enable the `unicorn/throw-new-error` linting rule For more information refer to https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/throw-new-error.md. This didn't require any changes because we already do this correctly, but it ensures that new code remains consistent and explicit. --- .eslintrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc b/.eslintrc index 2b2d0a580..e942b58f3 100644 --- a/.eslintrc +++ b/.eslintrc @@ -79,6 +79,7 @@ "unicorn/prefer-string-replace-all": "error", "unicorn/prefer-string-starts-ends-with": "error", "unicorn/prefer-ternary": ["error", "only-single-line"], + "unicorn/throw-new-error": "error", // Possible errors "for-direction": "error",