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

tools,lib: recommend using safe primordials #36026

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions lib/.eslintrc.yaml
Expand Up @@ -57,6 +57,7 @@ rules:
into: Number
- name: JSON
- name: Map
into: Safe
- name: Math
- name: Number
- name: Object
Expand All @@ -70,6 +71,7 @@ rules:
- name: Reflect
- name: RegExp
- name: Set
into: Safe
- name: String
- name: Symbol
- name: SyntaxError
Expand All @@ -80,7 +82,9 @@ rules:
- name: Uint8ClampedArray
- name: URIError
- name: WeakMap
into: Safe
- name: WeakSet
into: Safe
Leko marked this conversation as resolved.
Show resolved Hide resolved
globals:
Intl: false
# Parameters passed to internal modules
Expand Down
9 changes: 9 additions & 0 deletions test/parallel/test-eslint-prefer-primordials.js
Expand Up @@ -77,6 +77,10 @@ new RuleTester({
`,
options: [{ name: 'Reflect' }],
},
{
code: 'const { Map } = primordials; new Map()',
options: [{ name: 'Map', into: 'Safe' }],
Leko marked this conversation as resolved.
Show resolved Hide resolved
},
],
invalid: [
{
Expand Down Expand Up @@ -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/ }]
},
]
});