Skip to content

chore: fix all ESLint + tsc --noEmit errors#3

Merged
AllTerrainDeveloper merged 6 commits into
trunkfrom
fix/lint-errors
Apr 23, 2026
Merged

chore: fix all ESLint + tsc --noEmit errors#3
AllTerrainDeveloper merged 6 commits into
trunkfrom
fix/lint-errors

Conversation

@epeicher

Copy link
Copy Markdown
Collaborator

Summary

CI's js lane was failing because trunk carried 294 ESLint errors and 5 TypeScript errors. This branch cleans both to zero.

  • ca6acc0 — ESLint: eslint --fix handled 284 mechanical issues (indent, curly, jsdoc alignment). The remaining 10 are hand-fixed: drop an unused DesktopConfig import, swap three document.activeElement calls for this._el.ownerDocument.activeElement (satisfies @wordpress/no-global-active-element), convert a ternary-as-statement to if/else, flatten a nested ternary, rename shadowed registry and type-parameter body, disable no-alert on the one intentional window.confirm() with an inline reason, and add the missing parent @param options JSDoc line.
  • f1c436e — TypeScript: drop the unused _unsubCommands field (panel is page-lifetime, subscription dies with the page); rename unused cmd parameter to _cmd; replace a call to the nonexistent this._clearResults() with inline clear+hide; make x / y optional on NativeWindowDef (server-declared native windows never set them, and createRegisterWindow already nullish-coalesces with ?? 0 — the type was out of sync with runtime).

No runtime behavior changes — both commits are type-/style-only.

Test plan

  • js job on CI: ESLint, tsc --noEmit, and Vitest all green
  • npm run lint locally: 0 errors
  • npx tsc --noEmit locally: 0 errors
  • Vitest still passes (~360 tests)

Runs `eslint --fix` for the 284 auto-fixable style issues (indent,
curly, jsdoc alignment, etc.) and hand-fixes the remaining 10:

- Drop unused `DesktopConfig` import in ai-assistant.ts.
- Replace `document.activeElement` with `this._el.ownerDocument.activeElement`
  in three spots (AiAssistant.open() + the focus trap) to satisfy
  `@wordpress/no-global-active-element`.
- Convert `this._isOpen ? this.close() : this.open()` to an if/else.
- Flatten the nested ternary that picks the entity-card dashicon.
- Disable `no-alert` on the single intentional `window.confirm()`
  with an inline reason — the default impl is meant to be swapped.
- Rename a local that shadowed the `registry` import in desktop.ts,
  and rename a type-signature parameter that shadowed `body`.
- Add the parent `@param options` JSDoc line missing from
  WindowManager.closeAll so `options.exceptIds` has somewhere to hang.

No runtime behavior change; pre-existing TypeScript errors are
unchanged (5 before, 5 after).
Four TypeScript errors were tripping the workflow's type-check step:

- `ai-assistant.ts`: drop the `_unsubCommands` field. It was assigned
  in the constructor but never read, so `noUnusedLocals` flagged it.
  The panel is a page-lifetime singleton; `subscribeCommands()` can
  run for side-effect only and die with the page.
- `ai-assistant.ts`: rename the unused `cmd` parameter in
  `_renderCommandResult` to `_cmd` so it clears `noUnusedParameters`.
- `ai-assistant.ts`: the silent-success branch called a
  non-existent `this._clearResults()`. Replace with the two-line
  clear+hide inline — that matches how every other branch in the
  file shows/hides `_resultsEl`.
- `types.ts`: `NativeWindowDef` inherited `x`/`y` as required from
  `WindowConfig`, but `NativeWindowServerEntry` never supplies them
  and `createRegisterWindow` already nullish-coalesces with `?? 0`.
  Omit `x`/`y` from the `extends` clause and redeclare them as
  optional — the type now matches the runtime.
The old lockfile held only macOS-arm64 entries for `@esbuild/*`, so
CI's Linux runner couldn't resolve them and `npm ci` bailed with
"Missing: @esbuild/linux-x64@0.28.0 from lock file" (and 20+ more).
A clean `npm install` writes the lockfile with every platform's
optional binary, which is what npm 7+ expects.
Same fix as fix/php-tests 66cc8c5 — `npm install` on Node 24 / npm
11 leaves ~28 `@esbuild/<platform>` optional-binary entries marked
`"extraneous": true` in the lockfile. CI's `npm ci` (Node 20)
refuses those because the platform metadata doesn't match Linux
x64, even though they're nominally optional. `npm prune` drops the
extras cleanly.
Replace the previous Mac-generated (and partially-pruned) lockfile
with one written by npm 10 on node:20-alpine via Docker. That matches
CI's runtime exactly, so `npm ci` on the Linux runner stops choking
on stray `"extraneous": true` entries and missing platform binaries.

Verified locally via `npm ci` (read-only install from this lockfile)
on macOS — Vitest all-green, lockfile unchanged.
…dentation

The WP/ESLint indent rule has JSX-aware smarts that preserve ternary
indentation in `prop={ cond ? x : y }` shapes, but no equivalent for
tagged-template DSLs. Inside `` html`...${ cond ? x : y }...` `` it
treats the interpolation as a plain JS ConditionalExpression and
aligns it to the enclosing block — which flattens ternaries against
the left margin and loses the author's visual alignment with the
surrounding template.

Add `ignoredNodes: [ 'TemplateLiteral *' ]` to the indent rule so
ESLint stops reformatting content inside template literals. Also add
`SwitchCase: 1` (the WP convention) while we're there to match
what's expected in regular switch statements.

Then restore the visually-nicer ternary indentation that the first
`eslint --fix` run flattened in the affected src/ files.

Also gitignore /vendor so the Composer deps (for PHP tests on the
other branch) don't accidentally get staged.

No runtime change. ~360 Vitest tests still green; `tsc --noEmit`
still clean.

@AllTerrainDeveloper AllTerrainDeveloper left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Works locally as expected too 👍

@AllTerrainDeveloper AllTerrainDeveloper merged commit 4f4b08a into trunk Apr 23, 2026
1 of 3 checks passed
@AllTerrainDeveloper AllTerrainDeveloper deleted the fix/lint-errors branch April 23, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants