Repository navigation
Fix every JS lint and TypeScript error - #236
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Takes
bun run lint:jsfrom 2678 problems to 0 and adds a cleantscpass.@wordpress/api-fetchand@wordpress/i18nas devDependencies for their types (they stay externals; the build is byte-identical).z.record(z.string(), z.unknown())for zod v4..eslintrc.jsresolves the@fpalias througheslint-import-resolver-typescriptand ignores the vendoredqsand Select2 builds.…in translated strings.vartolet/constand the other rule fixes.Stacked on #235.
Checked: build, Jest (69), typecheck and
lint:jsall exit 0. The 5 admin pages generate through the UI and the Taxonomy/Meta rule flows pass.