Skip to content

Commit

Permalink
lib: add legacy built-in functions to primordials
Browse files Browse the repository at this point in the history
PR-URL: #42049
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
  • Loading branch information
aduh95 authored and danielleadams committed Apr 24, 2022
1 parent 11f747b commit 91a06bd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/.eslintrc.yaml
Expand Up @@ -134,6 +134,8 @@ rules:
- name: decodeURIComponent
- name: encodeURI
- name: encodeURIComponent
- name: escape
- name: eval
- name: Error
ignore:
- prepareStackTrace
Expand Down Expand Up @@ -177,6 +179,7 @@ rules:
- name: Uint32Array
- name: Uint8Array
- name: Uint8ClampedArray
- name: unescape
- name: URIError
- name: WeakMap
into: Safe
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/freeze_intrinsics.js
Expand Up @@ -121,7 +121,9 @@ const {
decodeURIComponent,
encodeURI,
encodeURIComponent,
escape,
globalThis,
unescape,
} = primordials;

const {
Expand Down Expand Up @@ -232,6 +234,7 @@ module.exports = function() {

// 19 The Global Object
// 19.2 Function Properties of the Global Object
// eslint-disable-next-line node-core/prefer-primordials
eval,
// eslint-disable-next-line node-core/prefer-primordials
isFinite,
Expand Down
9 changes: 9 additions & 0 deletions lib/internal/per_context/primordials.js
Expand Up @@ -154,6 +154,15 @@ function copyPrototype(src, dest, prefix) {
primordials[fn.name] = fn;
});

// Create copies of legacy functions
[
escape,
eval,
unescape,
].forEach((fn) => {
primordials[fn.name] = fn;
});

// Create copies of the namespace objects
[
'JSON',
Expand Down

0 comments on commit 91a06bd

Please sign in to comment.