Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy missing globals from builtin to es* #140

Open
silverwind opened this issue Aug 28, 2018 · 3 comments
Open

Copy missing globals from builtin to es* #140

silverwind opened this issue Aug 28, 2018 · 3 comments

Comments

@silverwind
Copy link
Contributor

While investigating why eslint wouldn't pick up the BigInt globals, I noticed eslint does not use builtin like I previously assumed. I'd like to propose to copy any globals missing in either es5, es2015, es2017 but present in builtin to one of those respective environments.

Afterwards, I'd copy back any potential globals from the es* categories to builtin so that it ends up containing all globals from those categories. Alternatively, builtincould be generated dynamically in index.js, I think actually, that'd be my preference to avoid future inconsistency.

@silverwind
Copy link
Contributor Author

Alternatively, we could also drop builtin which serves no clear purpose in my eyes. Nowadays, es5 should be considered as the baseline.

@sindresorhus
Copy link
Owner

If anyone wants to work on this, see the initial attempt and feedback in #158.

@fisker
Copy link
Collaborator

fisker commented Jun 16, 2024

This already fixed, tests

globals/test.mjs

Lines 62 to 88 in d4082e2

test('es versions', t => {
const builtins = new Map(Object.entries(globals.builtin));
const esVersions = ['es5', ...Array.from({length: 2024 - 2015 + 1}, (_, index) => `es${2015 + index}`)];
let previousVersion;
for (const esVersion of esVersions) {
const data = globals[esVersion];
for (const [key, value] of Object.entries(data)) {
t.true(builtins.has(key), `The builtin '${key}' in '${esVersion}' is missing in 'builtin'.`);
t.is(value, builtins.get(key), `Value of '${key}' should be the same as 'builtin'.`);
}
if (previousVersion) {
t.deepEqual(
previousVersion.globals.filter(key => !Object.hasOwn(data, key)),
[],
`The builtins in '${previousVersion.esVersion}' are missing in '${esVersion}'.`,
);
}
previousVersion = {esVersion, globals: Object.keys(globals[esVersion])};
}
const latestVersion = esVersions.at(-1);
t.deepEqual(globals[latestVersion], globals.builtin, `'${latestVersion}' should be the same as 'builtin'.`);
});

About dripping "builtin", see #158 (comment) add #252 (comment), let's keep it.

But do you think we should name it as "es-latest"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants