Skip to content

Commit

Permalink
Add BigInt64Array and BigUint64Array to the new-for-builtins ru…
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker authored and sindresorhus committed Sep 6, 2019
1 parent 1c50548 commit e7ff2de
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/rules/new-for-builtins.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Enforces the use of `new` for following builtins:
- `Object`
- `Array`
- `ArrayBuffer`
- `BigInt64Array`
- `BigUint64Array`
- `DataView`
- `Date`
- `Error`
Expand Down
2 changes: 2 additions & 0 deletions rules/new-for-builtins.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const enforceNew = new Set([
'Object',
'Array',
'ArrayBuffer',
'BigInt64Array',
'BigUint64Array',
'DataView',
'Date',
'Error',
Expand Down
12 changes: 12 additions & 0 deletions test/new-for-builtins.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ ruleTester.run('new-for-builtins', rule, {
'const foo = new Object()',
'const foo = new Array()',
'const foo = new ArrayBuffer()',
'const foo = new BigInt64Array()',
'const foo = new BigUint64Array()',
'const foo = new DataView()',
'const foo = new Date()',
'const foo = new Error()',
Expand Down Expand Up @@ -65,6 +67,16 @@ ruleTester.run('new-for-builtins', rule, {
errors: [enforceNewError('ArrayBuffer')],
output: 'const foo = new ArrayBuffer()'
},
{
code: 'const foo = BigInt64Array()',
errors: [enforceNewError('BigInt64Array')],
output: 'const foo = new BigInt64Array()'
},
{
code: 'const foo = BigUint64Array()',
errors: [enforceNewError('BigUint64Array')],
output: 'const foo = new BigUint64Array()'
},
{
code: 'const foo = DataView()',
errors: [enforceNewError('DataView')],
Expand Down

0 comments on commit e7ff2de

Please sign in to comment.