mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
tools,lib: recommend using safe primordials
Make the linter recommend replacing `globalThis.Map` by `primordials.SafeMap`, and similar for `Set`, `WeakSet`, and `WeakMap`. PR-URL: https://github.com/nodejs/node/pull/36026 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
This commit is contained in:
1 parent
5f848a612d
commit
e19478aa76
2 files changed
+13
No files matched your search
@@ -55,6 +55,7 @@ rules:
|
||||
into: Number
|
||||
- name: JSON
|
||||
- name: Map
|
||||
into: Safe
|
||||
- name: Math
|
||||
- name: Number
|
||||
- name: Object
|
||||
@@ -68,6 +69,7 @@ rules:
|
||||
- name: Reflect
|
||||
- name: RegExp
|
||||
- name: Set
|
||||
into: Safe
|
||||
- name: String
|
||||
- name: Symbol
|
||||
- name: SyntaxError
|
||||
@@ -78,7 +80,9 @@ rules:
|
||||
- name: Uint8ClampedArray
|
||||
- name: URIError
|
||||
- name: WeakMap
|
||||
into: Safe
|
||||
- name: WeakSet
|
||||
into: Safe
|
||||
globals:
|
||||
Intl: false
|
||||
# Parameters passed to internal modules
|
||||
|
||||
@@ -77,6 +77,10 @@ new RuleTester({
|
||||
`,
|
||||
options: [{ name: 'Reflect' }],
|
||||
},
|
||||
{
|
||||
code: 'const { Map } = primordials; new Map()',
|
||||
options: [{ name: 'Map', into: 'Safe' }],
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
@@ -154,5 +158,10 @@ new RuleTester({
|
||||
options: [{ name: 'Reflect' }],
|
||||
errors: [{ message: /const { ReflectOwnKeys } = primordials/ }]
|
||||
},
|
||||
{
|
||||
code: 'new Map()',
|
||||
options: [{ name: 'Map', into: 'Safe' }],
|
||||
errors: [{ message: /const { SafeMap } = primordials/ }]
|
||||
},
|
||||
]
|
||||
});
|
||||
Reference in new issue
Block a user