From c1e928ca96934ff39041f6c1588dbbe1c594382b Mon Sep 17 00:00:00 2001 From: silverwind Date: Tue, 9 Jun 2026 12:14:13 +0200 Subject: [PATCH] chore: enable `unicorn/better-dom-traversing`, drop obsolete type stub - Enable `unicorn/better-dom-traversing` and switch the flagged `.children[0]` / `.childNodes[0]` accesses to `.firstElementChild` / `.firstChild`. - Remove the obsolete `eslint-plugin-no-use-extend-native` type stub; it is no longer a dependency. - Drop misleading comments on `no-thenable` (enabled here, not disabled) and `try-complexity`. Assisted-by: claude-code:opus-4.8 --- eslint.config.ts | 6 +++--- types.d.ts | 6 ------ web_src/js/markup/html2markdown.ts | 4 ++-- web_src/js/modules/errors.ts | 2 +- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/eslint.config.ts b/eslint.config.ts index 589bd2cba4..58274becdc 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -723,7 +723,7 @@ export default defineConfig([ 'strict': [0], 'symbol-description': [2], 'unicode-bom': [2, 'never'], - 'unicorn/better-dom-traversing': [0], // false-positives on non-DOM `.children` access + 'unicorn/better-dom-traversing': [2], 'unicorn/catch-error-name': [0], 'unicorn/consistent-assert': [0], 'unicorn/consistent-compound-words': [0], // too opinionated @@ -790,7 +790,7 @@ export default defineConfig([ 'unicorn/no-process-exit': [0], 'unicorn/no-single-promise-in-promise-methods': [2], 'unicorn/no-static-only-class': [2], - 'unicorn/no-thenable': [2], // false-positives on json schemas + 'unicorn/no-thenable': [2], 'unicorn/no-this-assignment': [2], 'unicorn/no-this-outside-of-class': [0], // false-positives on `this` in standalone functions 'unicorn/no-typeof-undefined': [2], @@ -898,7 +898,7 @@ export default defineConfig([ 'unicorn/template-indent': [2], 'unicorn/text-encoding-identifier-case': [0], 'unicorn/throw-new-error': [2], - 'unicorn/try-complexity': [0], // overly strict at its default max complexity of 1 + 'unicorn/try-complexity': [0], 'use-isnan': [2], 'valid-typeof': [2, {requireStringLiterals: true}], 'vars-on-top': [0], diff --git a/types.d.ts b/types.d.ts index 39d51f36e2..abca4b8982 100644 --- a/types.d.ts +++ b/types.d.ts @@ -1,9 +1,3 @@ -declare module 'eslint-plugin-no-use-extend-native' { - import type {Eslint} from 'eslint'; - const plugin: Eslint.Plugin; - export = plugin; -} - declare module 'eslint-plugin-array-func' { import type {Eslint} from 'eslint'; const plugin: Eslint.Plugin; diff --git a/web_src/js/markup/html2markdown.ts b/web_src/js/markup/html2markdown.ts index 9331f6b29a..fea8d3e574 100644 --- a/web_src/js/markup/html2markdown.ts +++ b/web_src/js/markup/html2markdown.ts @@ -86,8 +86,8 @@ function prepareProcessors(ctx:ProcessorContext): Processors { function processElement(ctx :ProcessorContext, processors: Processors, el: HTMLElement): string | void { if (el.hasAttribute('data-markdown-generated-content')) return el.textContent; - if (el.tagName === 'A' && el.children.length === 1 && el.children[0].tagName === 'IMG') { - return processElement(ctx, processors, el.children[0] as HTMLElement); + if (el.tagName === 'A' && el.children.length === 1 && el.firstElementChild!.tagName === 'IMG') { + return processElement(ctx, processors, el.firstElementChild as HTMLElement); } const isListContainer = el.tagName === 'OL' || el.tagName === 'UL'; diff --git a/web_src/js/modules/errors.ts b/web_src/js/modules/errors.ts index 07e845ef00..185f2e53a3 100644 --- a/web_src/js/modules/errors.ts +++ b/web_src/js/modules/errors.ts @@ -24,7 +24,7 @@ export function showGlobalErrorMessage(msg: string, msgType: Intent = 'error', d if (!msgContainer) { const el = document.createElement('div'); el.innerHTML = html`
`; - msgContainer = el.childNodes[0] as HTMLDivElement; + msgContainer = el.firstChild as HTMLDivElement; } // merge duplicated messages into "the message (count)" format