test: compute list of expected globals from ESLint config file
We don't want to rely on mutable globals for core modules. Instead of
maintaining a separate list of known globals in our test files, parse
the ESLint config to ensure all globals are restricted in the lib/
directory.
- All globals must be in the allow list. Previously, only enumerable globals were verified.
- This now to verify globals using their name rather than their value. This avoids triggering warnings for globals that are getters with an experimental or deprecation warning (e.g.
fetch
). It also solves the case where there are two global variables referencing the same object (e.g.global
andglobalThis
). - For convenience and backward compatibility, it's still possible to pass the value of the global rather than its name so current tests can still pass.
@targos This may have consequences for V8 updates (if the new V8 version ships with new globals).
/cc @benjamingr
Blocked on https://github.com/nodejs/node/pull/42049 https://github.com/nodejs/build/pull/2879.