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

perf: switch from object spread to Object.assign when merging globals #16311

Merged
merged 1 commit into from Sep 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 12 additions & 6 deletions lib/linter/linter.js
Expand Up @@ -1601,12 +1601,18 @@ class Linter {
languageOptions.ecmaVersion
);

// add configured globals and language globals
const configuredGlobals = {
...(getGlobalsForEcmaVersion(languageOptions.ecmaVersion)),
...(languageOptions.sourceType === "commonjs" ? globals.commonjs : void 0),
...languageOptions.globals
};
/*
* add configured globals and language globals
*
* using Object.assign instead of object spread for performance reasons
* https://github.com/eslint/eslint/issues/16302
*/
const configuredGlobals = Object.assign(
{},
getGlobalsForEcmaVersion(languageOptions.ecmaVersion),
languageOptions.sourceType === "commonjs" ? globals.commonjs : void 0,
languageOptions.globals
);

// double check that there is a parser to avoid mysterious error messages
if (!languageOptions.parser) {
Expand Down