Skip to content

eslint-config: drop the globals dependency and browser-env override - #267

Merged
ocean90 merged 3 commits into
masterfrom
refactor/drop-globals-dependency
Jul 19, 2026
Merged

eslint-config: drop the globals dependency and browser-env override#267
ocean90 merged 3 commits into
masterfrom
refactor/drop-globals-dependency

Conversation

@ocean90

@ocean90 ocean90 commented Jul 19, 2026

Copy link
Copy Markdown
Member

Why

@wordpress/eslint-plugin deliberately does not enable the browser environment — its own config even says so in a comment (configs/jsdoc.js: "we don't have the browser environment enabled for the project"). The v7 flat config re-added the full browser globals set via a globals dependency (mirroring the old v6 env: { browser: true }), which diverges from the WordPress default and adds a dependency (+ Dependabot noise, e.g. #264).

This removes it so @wearerequired/eslint-config stays a thin layer on top of WordPress — and it now has no dependencies at all.

What we lose (measured)

Files Impact
.ts / .tsx None@wordpress/eslint-plugin turns no-undef off for TypeScript.
.js / .jsx Only bare DOM-only globals not in node/es2015 now report no-undef: MutationObserver, getComputedStyle, requestAnimationFrame, IntersectionObserver, ResizeObserver, … window, document, navigator, localStorage, fetch, console, setTimeout stay defined.

Consumers that use bare DOM globals in .js add them per project (languageOptions.globals) or access via window. — the WordPress-idiomatic way. Documented in the changeset + README migration notes.

Changes

  • Remove languageOptions.globals: { ...globals.browser } from the flat config and the globals dependency.
  • Update the eslint-config changeset (still major) and README "Migrating from v6".

Closes the need for Dependabot #264 (globals 16 → 17).

ocean90 added 3 commits July 19, 2026 12:41
`@wordpress/eslint-plugin` deliberately does not enable the browser environment
(see its jsdoc config comment). The v7 config re-added the full browser globals
set via a `globals` dependency, diverging from the WordPress default. Remove it
to stay a thin layer on top of WordPress.

- Remove `languageOptions.globals: { ...globals.browser }` from the flat config.
- Drop the `globals` dependency (eslint-config now has no dependencies).

Impact: `.ts`/`.tsx` are unaffected (`no-undef` is off for TS). In `.js`/`.jsx`,
bare DOM-only globals (MutationObserver, getComputedStyle, IntersectionObserver,
…) are no longer predefined and must be added per project or used via `window.`.
Documented in the changeset + README migration notes.
The flat-config migration changeset is already consumed by 7.0.0-alpha.0
(recorded in .changeset/pre.json), so editing it would not trigger a new
release. Move the "no browser globals" note into its own changeset instead, so
the change gets versioned into the next alpha (testable live) and lands as its
own entry in the stable 7.0.0 changelog.
@ocean90
ocean90 merged commit c4a8a1f into master Jul 19, 2026
6 checks passed
ocean90 added a commit that referenced this pull request Jul 19, 2026
* Group Dependabot updates and guard against missing changesets

Two low-risk improvements instead of an auto-changeset writer — that writer
would be dormant here, since the published packages have no runtime
dependencies and Dependabot only touches root dev tooling + composer.

- dependabot.yml: group the npm lint toolchain (@wordpress/*, eslint*,
  stylelint*, prettier, typescript) into one weekly PR, and batch all
  github-actions bumps. Composer stays ungrouped on purpose — the PHP stack is
  exact-pinned and each bump is a deliberate review against the PHP_CodeSniffer
  3 ceiling.
- ci.yml: add a "Changeset guard" job that fails a PR when a published
  package's package.json changes without a changeset — the peer/dependency
  class we handled by hand during the v7 alphas (#264/#266/#267). Skips pushes
  and the changesets "Version Packages" PR.

* Changeset guard: only count newly added changesets

Address Copilot review on #272: `changeset_added` came from `git diff
--name-only`, so a merely *modified* (or moved) existing changeset would satisfy
the guard despite the name/message meaning a new one. Editing an existing
changeset does not version a new change (and in pre mode does not trigger a
release), so switch to `git diff --name-status` and require an added (`A`) file.
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