Skip to content

Commit 0817840

Browse files
targosZYSzys
authored andcommitted
lib: force using primordials for JSON, Math and Reflect
Use the "no-restricted-globals" ESLint rule to lint for it. PR-URL: #27027 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 8a6dcd0 commit 0817840

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+83
-3
lines changed

lib/.eslintrc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
rules:
22
prefer-object-spread: error
33
no-buffer-constructor: error
4+
no-restricted-globals: ["error", "JSON", "Math", "Reflect"]
45
no-restricted-syntax:
56
# Config copied from .eslintrc.js
67
- error

lib/_http_common.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
'use strict';
2323

24+
const { Math } = primordials;
25+
2426
const { getOptionValue } = require('internal/options');
2527

2628
const { methods, HTTPParser } =

lib/async_hooks.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const { Reflect } = primordials;
4+
35
const {
46
ERR_ASYNC_CALLBACK,
57
ERR_INVALID_ASYNC_ID

lib/buffer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
'use strict';
2323

24+
const { Math } = primordials;
25+
2426
const {
2527
byteLengthUtf8,
2628
copy: _copy,

lib/domain.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
// No new pull requests targeting this module will be accepted
2727
// unless they address existing, critical bugs.
2828

29+
const { Reflect } = primordials;
30+
2931
const util = require('util');
3032
const EventEmitter = require('events');
3133
const {

lib/events.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
'use strict';
2323

24+
const { Math, Reflect } = primordials;
25+
2426
var spliceOne;
2527

2628
const {

lib/fs.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
'use strict';
2626

27+
const { Math, Reflect } = primordials;
28+
2729
const { fs: constants } = internalBinding('constants');
2830
const {
2931
S_IFIFO,

lib/inspector.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const { JSON } = primordials;
4+
35
const {
46
ERR_INSPECTOR_ALREADY_CONNECTED,
57
ERR_INSPECTOR_CLOSED,

lib/internal/assert/assertion_error.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const { Math } = primordials;
4+
35
const { inspect } = require('internal/util/inspect');
46
const { codes: {
57
ERR_INVALID_ARG_TYPE

lib/internal/async_hooks.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const { Reflect } = primordials;
4+
35
const {
46
ERR_ASYNC_TYPE,
57
ERR_INVALID_ASYNC_ID

0 commit comments

Comments
 (0)