Files
8f584653dc Replace remaining whitelist/blacklist with inclusive alternatives (#17830)
* Replace remaining "whitelist"/"blacklist" with inclusive alternatives

Follow-up to #11758 and #17671: replaces the remaining non-inclusive
terminology in source code for the Babel 8 release.

Changes:
- @babel/plugin-external-helpers: rename `whitelist` option to `allowlist`
- @babel/template: rename `placeholderWhitelist` option to `placeholderAllowlist`
- @babel/traverse: remove leftover `"blacklist"` from TypeScript type union
  in `shouldIgnoreKey` (runtime support was already removed in #17671)

Intentionally kept:
- `removed.ts` entries for `blacklist`/`whitelist` (detect legacy config)
- `--whitelist` CLI flag in build-external-helpers (throws helpful error)
- Integration test patches for external dependencies (jest, vue-cli)
- Historical changelogs

* Add runtime errors for deprecated *whitelist/*blacklist option names

When users pass the old option names, throw a clear error pointing
them to the new equivalents:

- `whitelist` → `allowlist` in @babel/plugin-external-helpers
- `placeholderWhitelist` → `placeholderAllowlist` in @babel/template
- `blacklist` → `denylist` in @babel/traverse visitor options

These runtime errors help users migrate their configuration. They
can be removed in Babel 9.

* fix: only error on deprecated option names when new option is absent\n\nPer reviewer suggestion, allow plugin authors to pass both old and new\noption names to support Babel 7/8 cross-version compatibility. When both\nare present, the new option takes precedence silently. An error is only\nthrown when the old deprecated name is used without the new name.\n\nCo-Authored-By: Claude Sonnet 4.6 <[email protected]>

* test: add tests for cross-version compat with both old and new option names

Add tests verifying that providing both deprecated and new option names
simultaneously does not throw, enabling plugin authors to support both
Babel 7 and Babel 8 with the same configuration.

- @babel/template: test both placeholderWhitelist + placeholderAllowlist
- @babel/traverse: test both blacklist + denylist in visitor options
- @babel/plugin-external-helpers: fix whitelist check to match template
  and traverse pattern (only throw when new option is absent)

* fix: remove unnecessary type assertions in template options

The `as object` cast is redundant — TypeScript already narrows
`opts` to `object` after the typeof check and null guard.
Fixes @typescript-eslint/no-unnecessary-type-assertion lint error.

---------

Co-authored-by: stuckvgn <[email protected]>
2026-04-11 12:11:38 +02:00
..