Skip to content

Commit 8090ce7

Browse files
Trotttargos
authored andcommitted
tools: enable ESLint no-sparse-arrays rule
PR-URL: #41463 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Geoffrey Booth <[email protected]>
1 parent afa4f37 commit 8090ce7

File tree

5 files changed

+8
-2
lines changed

5 files changed

+8
-2
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ module.exports = {
275275
'no-self-compare': 'error',
276276
'no-setter-return': 'error',
277277
'no-shadow-restricted-names': 'error',
278+
'no-sparse-arrays': 'error',
278279
'no-tabs': 'error',
279280
'no-template-curly-in-string': 'error',
280281
'no-this-before-super': 'error',

lib/internal/modules/esm/get_format.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const protocolHandlers = ObjectAssign(ObjectCreate(null), {
4545
const { 1: mime } = RegExpPrototypeExec(
4646
/^([^/]+\/[^;,]+)(?:[^,]*?)(;base64)?,/,
4747
parsed.pathname,
48-
) || [, null];
48+
) || [, null]; // eslint-disable-line no-sparse-arrays
4949
const format = ({
5050
'__proto__': null,
5151
'text/javascript': 'module',

test/parallel/test-assert-deep.js

+2
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,10 @@ assertNotDeepOrStrict(
567567

568568
// Handle sparse arrays.
569569
{
570+
/* eslint-disable no-sparse-arrays */
570571
assertDeepAndStrictEqual([1, , , 3], [1, , , 3]);
571572
assertNotDeepOrStrict([1, , , 3], [1, , , 3, , , ]);
573+
/* eslint-enable no-sparse-arrays */
572574
const a = new Array(3);
573575
const b = new Array(3);
574576
a[2] = true;

test/parallel/test-util-inspect.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ assert.strictEqual(
434434

435435
// Array with extra properties.
436436
{
437-
const arr = [1, 2, 3, , ];
437+
const arr = [1, 2, 3, , ]; // eslint-disable-line no-sparse-arrays
438438
arr.foo = 'bar';
439439
assert.strictEqual(util.inspect(arr),
440440
"[ 1, 2, 3, <1 empty item>, foo: 'bar' ]");
@@ -2142,6 +2142,7 @@ assert.strictEqual(util.inspect('"\'${a}'), "'\"\\'${a}'");
21422142
[function() {}, '[Function (anonymous)]'],
21432143
[() => {}, '[Function (anonymous)]'],
21442144
[[1, 2], '[ 1, 2 ]'],
2145+
// eslint-disable-next-line no-sparse-arrays
21452146
[[, , 5, , , , ], '[ <2 empty items>, 5, <3 empty items> ]'],
21462147
[{ a: 5 }, '{ a: 5 }'],
21472148
[new Set([1, 2]), 'Set(2) { 1, 2 }'],

test/parallel/test-util-isDeepStrictEqual.js

+2
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,10 @@ notUtilIsDeepStrict(
409409
}
410410

411411
// Handle sparse arrays
412+
/* eslint-disable no-sparse-arrays */
412413
utilIsDeepStrict([1, , , 3], [1, , , 3]);
413414
notUtilIsDeepStrict([1, , , 3], [1, , , 3, , , ]);
415+
/* eslint-enable no-sparse-arrays */
414416

415417
// Handle different error messages
416418
{

0 commit comments

Comments
 (0)