From 1742c00ae5c4004d4203119b8772b2f3551ef3b1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jun 2026 01:14:22 +0000 Subject: [PATCH 1/2] build(deps-dev): bump eslint-plugin-unicorn from 64.0.0 to 65.0.1 Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 64.0.0 to 65.0.1. - [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases) - [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v64.0.0...v65.0.1) --- updated-dependencies: - dependency-name: eslint-plugin-unicorn dependency-version: 65.0.1 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- package-lock.json | 57 +++++++++++++++-------------------------------- package.json | 2 +- 2 files changed, 19 insertions(+), 40 deletions(-) diff --git a/package-lock.json b/package-lock.json index c9662dd45..02f919423 100644 --- a/package-lock.json +++ b/package-lock.json @@ -86,7 +86,7 @@ "eslint-plugin-jsdoc": "^63.0.2", "eslint-plugin-lit": "^2.3.1", "eslint-plugin-n": "^18.1.0", - "eslint-plugin-unicorn": "^64.0.0", + "eslint-plugin-unicorn": "^65.0.1", "eslint-plugin-wc": "^3.1.0", "globals": "^17.6.0", "lefthook": "^2.1.9", @@ -13095,29 +13095,6 @@ "dev": true, "license": "MIT" }, - "node_modules/clean-regexp": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/clean-regexp/-/clean-regexp-1.0.0.tgz", - "integrity": "sha512-GfisEZEJvzKrmGWkvfhgzcz/BllN1USeqD2V6tg14OAOgaCD2Z/PUEuxnAZ/nPvmaHRG7a8y77p1T/IRQ4D1Hw==", - "dev": true, - "license": "MIT", - "dependencies": { - "escape-string-regexp": "^1.0.5" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/clean-regexp/node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.8.0" - } - }, "node_modules/cli-cursor": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", @@ -15057,6 +15034,19 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/detect-indent": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-7.0.2.tgz", + "integrity": "sha512-y+8xyqdGLL+6sh0tVeHcfP/QDd8gUgbasolJJpY7NgeQGSZ739bDtSiaiDgtoicy+mtYB81dKLxO9xRhCyIB3A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.20" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/detect-libc": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", @@ -16375,9 +16365,9 @@ } }, "node_modules/eslint-plugin-unicorn": { - "version": "64.0.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-64.0.0.tgz", - "integrity": "sha512-rNZwalHh8i0UfPlhNwg5BTUO1CMdKNmjqe+TgzOTZnpKoi8VBgsW7u9qCHIdpxEzZ1uwrJrPF0uRb7l//K38gA==", + "version": "65.0.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-65.0.1.tgz", + "integrity": "sha512-daCrQrgxOoOz2uMPWB3Y3vvv/5q+ncwICI8IjoebiwtW87CaY4tAN5EEiRXTYVnf7qi1v1BGBdHOSnZLV0rx6A==", "dev": true, "license": "MIT", "dependencies": { @@ -16385,15 +16375,14 @@ "@eslint-community/eslint-utils": "^4.9.1", "change-case": "^5.4.4", "ci-info": "^4.4.0", - "clean-regexp": "^1.0.0", "core-js-compat": "^3.49.0", + "detect-indent": "^7.0.2", "find-up-simple": "^1.0.1", "globals": "^17.4.0", "indent-string": "^5.0.0", "is-builtin-module": "^5.0.0", "jsesc": "^3.1.0", "pluralize": "^8.0.0", - "regexp-tree": "^0.1.27", "regjsparser": "^0.13.0", "semver": "^7.7.4", "strip-indent": "^4.1.1" @@ -27625,16 +27614,6 @@ "dev": true, "license": "MIT" }, - "node_modules/regexp-tree": { - "version": "0.1.27", - "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.27.tgz", - "integrity": "sha512-iETxpjK6YoRWJG5o6hXLwvjYAoW+FEZn9os0PD/b6AP6xQwsa/Y7lCVgIixBbUPMfhu+i2LtdeAqVTgGlQarfA==", - "dev": true, - "license": "MIT", - "bin": { - "regexp-tree": "bin/regexp-tree" - } - }, "node_modules/regexp.prototype.flags": { "version": "1.5.4", "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz", diff --git a/package.json b/package.json index ef01f80f8..6458e2e7b 100644 --- a/package.json +++ b/package.json @@ -108,7 +108,7 @@ "eslint-plugin-jsdoc": "^63.0.2", "eslint-plugin-lit": "^2.3.1", "eslint-plugin-n": "^18.1.0", - "eslint-plugin-unicorn": "^64.0.0", + "eslint-plugin-unicorn": "^65.0.1", "eslint-plugin-wc": "^3.1.0", "globals": "^17.6.0", "lefthook": "^2.1.9", From 22d3810819464a5a381152163e60f61424e6c76f Mon Sep 17 00:00:00 2001 From: Leo McArdle Date: Fri, 12 Jun 2026 14:53:11 +0100 Subject: [PATCH 2/2] fix/disable updated eslint rules --- build/eslint-fred.js | 2 +- build/loaders/fix-light-dark.js | 1 + components/button/sandbox.js | 2 +- components/color-theme/element.js | 1 + components/compat-table/element.js | 2 +- components/cookie/utils.js | 2 +- components/curriculum-landing/server.js | 1 + components/dropdown/element.js | 4 +++- components/interactive-example/utils.js | 2 +- components/latest-news/server.js | 2 +- components/outer-layout/server.js | 2 +- components/play-runner/element.js | 2 +- components/recent-contributions/server.js | 2 +- components/sidebar-filter/sidebar-filterer.js | 12 +++++------- components/specifications-list/server.js | 2 +- entry.ssr.js | 4 ++-- hooks/toc-highlight.js | 2 +- l10n/fluent.js | 4 ++-- scripts/server.js | 2 +- server.js | 2 +- symmetric-context/client.js | 2 +- test/unit/l10n/fixtures/simple-different.js | 2 +- test/unit/l10n/fixtures/simple.js | 2 +- test/unit/l10n/fixtures/tags-with-duplicates.js | 2 +- test/unit/l10n/fixtures/tags-with-substitutions.js | 2 +- test/unit/l10n/fixtures/tags.js | 2 +- 26 files changed, 34 insertions(+), 31 deletions(-) diff --git a/build/eslint-fred.js b/build/eslint-fred.js index 3c01404a1..7ce79f1f2 100644 --- a/build/eslint-fred.js +++ b/build/eslint-fred.js @@ -132,7 +132,7 @@ export default { } if (node.source.value === "lit") { - const htmlSpecifier = node.specifiers.find( + const htmlSpecifier = node.specifiers.some( (spec) => spec.type === "ImportSpecifier" && spec.imported.type === "Identifier" && diff --git a/build/loaders/fix-light-dark.js b/build/loaders/fix-light-dark.js index 4df73bd19..67240fbde 100644 --- a/build/loaders/fix-light-dark.js +++ b/build/loaders/fix-light-dark.js @@ -1,3 +1,4 @@ +/* eslint-disable unicorn/no-this-outside-of-class */ import crypto from "node:crypto"; /** diff --git a/components/button/sandbox.js b/components/button/sandbox.js index 3d20c1741..cb645700d 100644 --- a/components/button/sandbox.js +++ b/components/button/sandbox.js @@ -10,7 +10,7 @@ import { Button } from "./server.js"; export class ButtonSandbox extends SandboxComponent { render() { - const hrefs = [undefined, "http://example.com"]; + const hrefs = [undefined, "https://example.com"]; const variants = [undefined, "primary", "secondary", "plain"]; const actions = [undefined, "positive", "negative"]; const icons = [ diff --git a/components/color-theme/element.js b/components/color-theme/element.js index 12b06864f..fc44b1848 100644 --- a/components/color-theme/element.js +++ b/components/color-theme/element.js @@ -1,3 +1,4 @@ +/* eslint-disable unicorn/prefer-includes-over-repeated-comparisons */ import { LitElement, html } from "lit"; import { L10nMixin } from "../../l10n/mixin.js"; diff --git a/components/compat-table/element.js b/components/compat-table/element.js index 110de8e93..120d12977 100644 --- a/components/compat-table/element.js +++ b/components/compat-table/element.js @@ -58,7 +58,7 @@ function browserToIconName(browser) { } else if (browser === "webview_ios") { return "safari"; } else { - return browser.split("_")[0] ?? ""; + return browser.split("_", 1)[0] ?? ""; } } diff --git a/components/cookie/utils.js b/components/cookie/utils.js index 3c0e75d38..e96911e31 100644 --- a/components/cookie/utils.js +++ b/components/cookie/utils.js @@ -5,7 +5,7 @@ export function getCookieValue(name) { .find((row) => row.startsWith(`${name}=`)); if (value && value.includes("=")) { - value = value.split("=")[1]; + value = value.split("=", 2)[1]; } return value; diff --git a/components/curriculum-landing/server.js b/components/curriculum-landing/server.js index 3a056cf79..06567d33b 100644 --- a/components/curriculum-landing/server.js +++ b/components/curriculum-landing/server.js @@ -1,3 +1,4 @@ +/* eslint-disable unicorn/better-dom-traversing */ import { html } from "@lit-labs/ssr"; import { nothing } from "lit"; diff --git a/components/dropdown/element.js b/components/dropdown/element.js index 2924cba12..2af01ac44 100644 --- a/components/dropdown/element.js +++ b/components/dropdown/element.js @@ -44,7 +44,9 @@ export class MDNDropdown extends LitElement { /** @param {string} name */ _slotElements(name) { - const slot = this.shadowRoot?.querySelector(`slot[name="${name}"]`); + const slot = this.shadowRoot?.querySelector( + `slot[name="${CSS.escape(name)}"]`, + ); if (slot instanceof HTMLSlotElement) { return slot.assignedElements(); } diff --git a/components/interactive-example/utils.js b/components/interactive-example/utils.js index e207fc9a0..33aafcee5 100644 --- a/components/interactive-example/utils.js +++ b/components/interactive-example/utils.js @@ -4,7 +4,7 @@ * @param {string} code */ export function isCSSSupported(code) { - // http://regexr.com/3fvik + // https://regexr.com/3fvik const cssCommentsMatch = /(\/\*)[\s\S]+(\*\/)/g; const element = document.createElement("div"); diff --git a/components/latest-news/server.js b/components/latest-news/server.js index 54d05dece..f53c2ade2 100644 --- a/components/latest-news/server.js +++ b/components/latest-news/server.js @@ -59,7 +59,7 @@ function getRelativeTime(seconds) { { amount: 60, unit: "minute" }, { amount: 24, unit: "hour" }, { amount: 7, unit: "day" }, - { amount: 4.345_24, unit: "week" }, // 365/12/7 + { amount: 4.34524, unit: "week" }, // 365/12/7 { amount: 12, unit: "month" }, { amount: Number.POSITIVE_INFINITY, unit: "year" }, ]; diff --git a/components/outer-layout/server.js b/components/outer-layout/server.js index de3eb7174..6e010cfa5 100644 --- a/components/outer-layout/server.js +++ b/components/outer-layout/server.js @@ -69,7 +69,7 @@ export class OuterLayout extends ServerComponent { .filter((x) => x !== undefined); const area = - context.path.split("/")[3]?.toLowerCase() === "learn_web_development" + context.path.split("/", 4)[3]?.toLowerCase() === "learn_web_development" ? "learn" : undefined; diff --git a/components/play-runner/element.js b/components/play-runner/element.js index b815c0c35..b844adbc3 100644 --- a/components/play-runner/element.js +++ b/components/play-runner/element.js @@ -70,7 +70,7 @@ export class MDNPlayRunner extends LitElement { /** @param {MessageEvent} e */ _onMessage({ data: { typ, prop, args, uuid }, origin }) { if (!uuid) { - uuid = new URL(origin, "https://example.com").hostname.split(".")[0]; + uuid = new URL(origin, "https://example.com").hostname.split(".", 1)[0]; } if (uuid !== this._subdomain) { return; diff --git a/components/recent-contributions/server.js b/components/recent-contributions/server.js index 557495edf..5c1c54ff9 100644 --- a/components/recent-contributions/server.js +++ b/components/recent-contributions/server.js @@ -58,7 +58,7 @@ function getRelativeTime(seconds) { { amount: 60, unit: "minute" }, { amount: 24, unit: "hour" }, { amount: 7, unit: "day" }, - { amount: 4.345_24, unit: "week" }, // 365/12/7 + { amount: 4.34524, unit: "week" }, // 365/12/7 { amount: 12, unit: "month" }, { amount: Number.POSITIVE_INFINITY, unit: "year" }, ]; diff --git a/components/sidebar-filter/sidebar-filterer.js b/components/sidebar-filter/sidebar-filterer.js index 0e774d501..de29b9897 100644 --- a/components/sidebar-filter/sidebar-filterer.js +++ b/components/sidebar-filter/sidebar-filterer.js @@ -355,13 +355,11 @@ export class SidebarFilterer { * @returns {HTMLElement|undefined} The found element or undefined if none found. */ findFirstElementBefore(el, candidates) { - return [...candidates] - .reverse() - .find( - (candidate) => - candidate.compareDocumentPosition(el) & - Node.DOCUMENT_POSITION_FOLLOWING, - ); + return candidates.findLast( + (candidate) => + candidate.compareDocumentPosition(el) & + Node.DOCUMENT_POSITION_FOLLOWING, + ); } /** diff --git a/components/specifications-list/server.js b/components/specifications-list/server.js index 3bc3921cc..bb3ab9d45 100644 --- a/components/specifications-list/server.js +++ b/components/specifications-list/server.js @@ -57,7 +57,7 @@ export class SpecificationsList extends ServerComponent { * @param {string} [title] */ renderLink(url, title) { - const hash = url.split("#")[1]; + const hash = url.split("#", 2)[1]; const label = [ title && html`${title}`, diff --git a/entry.ssr.js b/entry.ssr.js index d05f9603c..e6b0bade9 100644 --- a/entry.ssr.js +++ b/entry.ssr.js @@ -46,7 +46,7 @@ for (const [name, def] of customElements.__definitions) { * @param {import("@fred").CompilationStats} compilationStats */ export async function render(path, partialContext, compilationStats) { - const locale = path.split("/")[1] || "en-US"; + const locale = path.split("/", 2)[1] || "en-US"; const context = { path, @@ -135,7 +135,7 @@ export async function render(path, partialContext, compilationStats) { * @param {import("@fred").PartialContext} partialContext */ export async function renderSimplified(path, partialContext) { - const locale = path.split("/")[1] || "en-US"; + const locale = path.split("/", 2)[1] || "en-US"; const context = { path, ...(await addFluent(locale)), diff --git a/hooks/toc-highlight.js b/hooks/toc-highlight.js index 8871467be..3215647e5 100644 --- a/hooks/toc-highlight.js +++ b/hooks/toc-highlight.js @@ -11,7 +11,7 @@ function highlightTOC(toc) { const tocItemBySection = new Map(); for (const item of tocItems.reverse()) { const target = document.querySelector( - `[id="${decodeURIComponent(item.hash).slice(1)}"]`, + `[id="${CSS.escape(decodeURIComponent(item.hash).slice(1))}"]`, ); if (!target) { diff --git a/l10n/fluent.js b/l10n/fluent.js index 42beb5db1..644a4338c 100644 --- a/l10n/fluent.js +++ b/l10n/fluent.js @@ -14,7 +14,7 @@ const ftlMap = { "en-US": enUS_ftl, }; -const ALLOWED_TAGS = ["i", "strong", "br", "em"]; +const ALLOWED_TAGS = new Set(["i", "strong", "br", "em"]); const ALLOWED_ATTRIBUTES = ["title", "aria-label"]; export class Fluent { @@ -105,7 +105,7 @@ export class Fluent { } } if ( - ALLOWED_TAGS.includes(token.tag) || + ALLOWED_TAGS.has(token.tag) || (name && Object.keys(elements).includes(name) && elements[name]?.tag === token.tag) diff --git a/scripts/server.js b/scripts/server.js index c36959883..a683a5155 100755 --- a/scripts/server.js +++ b/scripts/server.js @@ -4,7 +4,7 @@ import { fileURLToPath } from "node:url"; import { rariBin } from "@mdn/rari"; import { concurrently } from "concurrently"; -export const server = fileURLToPath(import.meta.resolve("../server.js")); +const server = fileURLToPath(import.meta.resolve("../server.js")); const { commands, result } = concurrently( [ diff --git a/server.js b/server.js index 11c37b793..7c28710c1 100644 --- a/server.js +++ b/server.js @@ -240,7 +240,7 @@ export async function startServer() { selfHandleResponse: true, on: { proxyReq: async (req) => { - const locale = req.path.split("/")[1]; + const locale = req.path.split("/", 2)[1]; if (locale && /^q[a-t][a-z]$/.test(locale)) { // if the locale matches a qaa...qtz private use language tag, // which we use for testing fluent with pseudo-locales, diff --git a/symmetric-context/client.js b/symmetric-context/client.js index 14d1f623f..78c29b1f5 100644 --- a/symmetric-context/client.js +++ b/symmetric-context/client.js @@ -4,5 +4,5 @@ * @type {import("./types.js").SymmetricContext} */ globalThis.__MDNClientContext = { - locale: globalThis.location.pathname.split("/")[1] || "en-US", + locale: globalThis.location.pathname.split("/", 2)[1] || "en-US", }; diff --git a/test/unit/l10n/fixtures/simple-different.js b/test/unit/l10n/fixtures/simple-different.js index 0bcb4f6a7..bc85968ee 100644 --- a/test/unit/l10n/fixtures/simple-different.js +++ b/test/unit/l10n/fixtures/simple-different.js @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unused-expressions */ +/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unused-expressions, unicorn/no-this-outside-of-class */ // @ts-nocheck this.l10n("id1")`Hello world!`; diff --git a/test/unit/l10n/fixtures/simple.js b/test/unit/l10n/fixtures/simple.js index 2c2199be6..686ca51d2 100644 --- a/test/unit/l10n/fixtures/simple.js +++ b/test/unit/l10n/fixtures/simple.js @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unused-expressions */ +/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unused-expressions, unicorn/no-this-outside-of-class */ // @ts-nocheck this.l10n("id1")`Hello world!`; diff --git a/test/unit/l10n/fixtures/tags-with-duplicates.js b/test/unit/l10n/fixtures/tags-with-duplicates.js index 59f568974..07fa800e9 100644 --- a/test/unit/l10n/fixtures/tags-with-duplicates.js +++ b/test/unit/l10n/fixtures/tags-with-duplicates.js @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unused-expressions */ +/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unused-expressions, unicorn/no-this-outside-of-class */ // @ts-nocheck this.l10n("this-l10n")`This L10n`; diff --git a/test/unit/l10n/fixtures/tags-with-substitutions.js b/test/unit/l10n/fixtures/tags-with-substitutions.js index 2bab2c799..d188a8379 100644 --- a/test/unit/l10n/fixtures/tags-with-substitutions.js +++ b/test/unit/l10n/fixtures/tags-with-substitutions.js @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unused-expressions */ +/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unused-expressions, unicorn/no-this-outside-of-class */ // @ts-nocheck const foo = "has"; diff --git a/test/unit/l10n/fixtures/tags.js b/test/unit/l10n/fixtures/tags.js index 84672c6fb..57da68d06 100644 --- a/test/unit/l10n/fixtures/tags.js +++ b/test/unit/l10n/fixtures/tags.js @@ -1,4 +1,4 @@ -/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unused-expressions, no-undef */ +/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unused-expressions, no-undef, unicorn/no-this-outside-of-class */ // @ts-nocheck this.l10n("this-l10n")`This L10n`;