Skip to content

Commit df0e665

Browse files
authored
lib: add legacy built-in functions to primordials
PR-URL: #42049 Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Mestery <mestery@protonmail.com>
1 parent 916227b commit df0e665

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

lib/.eslintrc.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ rules:
140140
- name: decodeURIComponent
141141
- name: encodeURI
142142
- name: encodeURIComponent
143+
- name: escape
144+
- name: eval
143145
- name: Error
144146
ignore:
145147
- prepareStackTrace
@@ -183,6 +185,7 @@ rules:
183185
- name: Uint32Array
184186
- name: Uint8Array
185187
- name: Uint8ClampedArray
188+
- name: unescape
186189
- name: URIError
187190
- name: WeakMap
188191
into: Safe

lib/internal/freeze_intrinsics.js

+3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ const {
121121
decodeURIComponent,
122122
encodeURI,
123123
encodeURIComponent,
124+
escape,
124125
globalThis,
126+
unescape,
125127
} = primordials;
126128

127129
const {
@@ -232,6 +234,7 @@ module.exports = function() {
232234

233235
// 19 The Global Object
234236
// 19.2 Function Properties of the Global Object
237+
// eslint-disable-next-line node-core/prefer-primordials
235238
eval,
236239
// eslint-disable-next-line node-core/prefer-primordials
237240
isFinite,

lib/internal/per_context/primordials.js

+9
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,15 @@ function copyPrototype(src, dest, prefix) {
154154
primordials[fn.name] = fn;
155155
});
156156

157+
// Create copies of legacy functions
158+
[
159+
escape,
160+
eval,
161+
unescape,
162+
].forEach((fn) => {
163+
primordials[fn.name] = fn;
164+
});
165+
157166
// Create copies of the namespace objects
158167
[
159168
'JSON',

0 commit comments

Comments
 (0)