mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
tools: enable ESLint no-sparse-arrays rule
PR-URL: https://github.com/nodejs/node/pull/41463 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
This commit is contained in:
1 parent
94abcbde8b
commit
9bfe60fc20
5 files changed
+8
-2
No files matched your search
@@ -275,6 +275,7 @@ module.exports = {
|
||||
'no-self-compare': 'error',
|
||||
'no-setter-return': 'error',
|
||||
'no-shadow-restricted-names': 'error',
|
||||
'no-sparse-arrays': 'error',
|
||||
'no-tabs': 'error',
|
||||
'no-template-curly-in-string': 'error',
|
||||
'no-this-before-super': 'error',
|
||||
|
||||
@@ -45,7 +45,7 @@ const protocolHandlers = ObjectAssign(ObjectCreate(null), {
|
||||
const { 1: mime } = RegExpPrototypeExec(
|
||||
/^([^/]+\/[^;,]+)(?:[^,]*?)(;base64)?,/,
|
||||
parsed.pathname,
|
||||
) || [, null];
|
||||
) || [, null]; // eslint-disable-line no-sparse-arrays
|
||||
const format = ({
|
||||
'__proto__': null,
|
||||
'text/javascript': 'module',
|
||||
|
||||
@@ -567,8 +567,10 @@ assertNotDeepOrStrict(
|
||||
|
||||
// Handle sparse arrays.
|
||||
{
|
||||
/* eslint-disable no-sparse-arrays */
|
||||
assertDeepAndStrictEqual([1, , , 3], [1, , , 3]);
|
||||
assertNotDeepOrStrict([1, , , 3], [1, , , 3, , , ]);
|
||||
/* eslint-enable no-sparse-arrays */
|
||||
const a = new Array(3);
|
||||
const b = new Array(3);
|
||||
a[2] = true;
|
||||
|
||||
@@ -434,7 +434,7 @@ assert.strictEqual(
|
||||
|
||||
// Array with extra properties.
|
||||
{
|
||||
const arr = [1, 2, 3, , ];
|
||||
const arr = [1, 2, 3, , ]; // eslint-disable-line no-sparse-arrays
|
||||
arr.foo = 'bar';
|
||||
assert.strictEqual(util.inspect(arr),
|
||||
"[ 1, 2, 3, <1 empty item>, foo: 'bar' ]");
|
||||
@@ -2142,6 +2142,7 @@ assert.strictEqual(util.inspect('"\'${a}'), "'\"\\'${a}'");
|
||||
[function() {}, '[Function (anonymous)]'],
|
||||
[() => {}, '[Function (anonymous)]'],
|
||||
[[1, 2], '[ 1, 2 ]'],
|
||||
// eslint-disable-next-line no-sparse-arrays
|
||||
[[, , 5, , , , ], '[ <2 empty items>, 5, <3 empty items> ]'],
|
||||
[{ a: 5 }, '{ a: 5 }'],
|
||||
[new Set([1, 2]), 'Set(2) { 1, 2 }'],
|
||||
|
||||
@@ -409,8 +409,10 @@ notUtilIsDeepStrict(
|
||||
}
|
||||
|
||||
// Handle sparse arrays
|
||||
/* eslint-disable no-sparse-arrays */
|
||||
utilIsDeepStrict([1, , , 3], [1, , , 3]);
|
||||
notUtilIsDeepStrict([1, , , 3], [1, , , 3, , , ]);
|
||||
/* eslint-enable no-sparse-arrays */
|
||||
|
||||
// Handle different error messages
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user