Skip to content

Fix every JS lint and TypeScript error - #236

Merged
bordoni merged 7 commits into
mainfrom
fix/js-lint
Oct 17, 2026
Merged

bordoni merged 7 commits into
mainfrom
fix/js-lint

Conversation

@bordoni

@bordoni bordoni commented Oct 17, 2026

Copy link
Copy Markdown
Owner

Takes bun run lint:js from 2678 problems to 0 and adds a clean tsc pass.

  • Add @wordpress/api-fetch and @wordpress/i18n as devDependencies for their types (they stay externals; the build is byte-identical).
  • Meta rule config schema uses z.record(z.string(), z.unknown()) for zod v4.
  • .eslintrc.js resolves the @fp alias through eslint-import-resolver-typescript and ignores the vendored qs and Select2 builds.
  • React admin: the remaining rule errors fixed by hand, and … in translated strings.
  • Legacy jQuery scripts: var to let/const and the other rule fixes.

Stacked on #235.

Checked: build, Jest (69), typecheck and lint:js all exit 0. The 5 admin pages generate through the UI and the Taxonomy/Meta rule flows pass.

Both are webpack externals provided by WordPress at runtime. Installing
them lets ESLint (import/no-unresolved) and tsc resolve the imports and
types. build/admin.asset.php still lists wp-api-fetch and wp-i18n, and no
bundle grows.
zod v4's z.record() needs a key schema. With one argument the value
schema is undefined, so parsing any non-empty config threw
("def.valueType._zod"). Use z.record( z.string(), z.unknown() ).
Add .eslintrc.js (the default @wordpress/scripts config plus the
TypeScript import resolver) so import/no-unresolved resolves @fp/* the
same way tsconfig.json, webpack and Jest do. Fixes 26 false
import/no-unresolved errors in the shadcn ui components, and still flags
a mistyped @fp path. Exclude the config from the release zip.
- i18n-ellipsis: use … in the 15 translated placeholder/label strings.
- no-nested-ternary: Budugbox empty message and slider values become
  plain if/else (same results).
- @typescript-eslint/no-shadow: rename the destructured className/props
  in the calendar's Root, Chevron and WeekNumber slots.
- curly: brace two single-line ifs.
- jsdoc/require-param: document cn() and mergeDefaultMeta() params.
fields.js, module.js and field.dependency.js, behaviour unchanged:
- var -> const/let. No var was used outside its block or before its
  declaration; configure()'s duplicate `name` declaration now reads
  __name once for the config key.
- Rename internal snake_case locals to camelCase. Request payload keys
  (post_type, posts_per_page, page_limit, ...) are untouched.
- Method/property shorthand, === for the indexOf and null checks,
  else-if instead of a lonely if, no early-return-unused assignments.
- Drop unused params/locals. The fp.fields callbacks use the closure's
  $ and _ instead of shadowing them with the same window globals.
- Declare the jQuery/_ globals, fix JSDoc, add translator comments.
- module.js: remove two debug console.log calls; keep the console.error
  for a form missing data-endpoint (targeted disable with reason).
- field.dependency.js (not enqueued) is an unfinished stub; reduced to
  its only effect.

A jsdom run of the old and new builds with WordPress' jQuery, Underscore,
jQuery UI datepicker and Select2 3.5 gives identical DOM, field values
and REST payload.
So a plain `wp-scripts lint-js src/` is clean too, not only lint:js
with its --ignore-pattern flags.
@bordoni
bordoni merged commit 32f0755 into main Oct 17, 2026
3 of 5 checks passed
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.

1 participant