]> git.proxmox.com Git - pve-eslint.git/blobdiff - eslint/tests/lib/rules/array-callback-return.js
import 8.41.0 source
[pve-eslint.git] / eslint / tests / lib / rules / array-callback-return.js
index 13a01125c99df1e4cd412606d7f909390684dfcf..6343d3e4027ea3cc23cf39138b3501a81288853d 100644 (file)
@@ -57,6 +57,8 @@ ruleTester.run("array-callback-return", rule, {
         "foo.filter(function() { return true; })",
         "foo.find(function() { return true; })",
         "foo.findIndex(function() { return true; })",
+        "foo.findLast(function() { return true; })",
+        "foo.findLastIndex(function() { return true; })",
         "foo.flatMap(function() { return true; })",
         "foo.forEach(function() { return; })",
         "foo.map(function() { return true; })",
@@ -64,6 +66,7 @@ ruleTester.run("array-callback-return", rule, {
         "foo.reduceRight(function() { return true; })",
         "foo.some(function() { return true; })",
         "foo.sort(function() { return 0; })",
+        "foo.toSorted(function() { return 0; })",
         { code: "foo.every(() => { return true; })", parserOptions: { ecmaVersion: 6 } },
         "foo.every(function() { if (a) return true; else return false; })",
         "foo.every(function() { switch (a) { case 0: bar(); default: return true; } })",
@@ -77,6 +80,8 @@ ruleTester.run("array-callback-return", rule, {
         { code: "foo.filter(function() { return; })", options: allowImplicitOptions },
         { code: "foo.find(function() { return; })", options: allowImplicitOptions },
         { code: "foo.findIndex(function() { return; })", options: allowImplicitOptions },
+        { code: "foo.findLast(function() { return; })", options: allowImplicitOptions },
+        { code: "foo.findLastIndex(function() { return; })", options: allowImplicitOptions },
         { code: "foo.flatMap(function() { return; })", options: allowImplicitOptions },
         { code: "foo.forEach(function() { return; })", options: allowImplicitOptions },
         { code: "foo.map(function() { return; })", options: allowImplicitOptions },
@@ -84,6 +89,7 @@ ruleTester.run("array-callback-return", rule, {
         { code: "foo.reduceRight(function() { return; })", options: allowImplicitOptions },
         { code: "foo.some(function() { return; })", options: allowImplicitOptions },
         { code: "foo.sort(function() { return; })", options: allowImplicitOptions },
+        { code: "foo.toSorted(function() { return; })", options: allowImplicitOptions },
         { code: "foo.every(() => { return; })", options: allowImplicitOptions, parserOptions: { ecmaVersion: 6 } },
         { code: "foo.every(function() { if (a) return; else return a; })", options: allowImplicitOptions },
         { code: "foo.every(function() { switch (a) { case 0: bar(); default: return; } })", options: allowImplicitOptions },
@@ -129,8 +135,12 @@ ruleTester.run("array-callback-return", rule, {
         { code: "foo.filter(function foo() {})", errors: [{ messageId: "expectedInside", data: { name: "function 'foo'", arrayMethodName: "Array.prototype.filter" } }] },
         { code: "foo.find(function() {})", errors: [{ messageId: "expectedInside", data: { name: "function", arrayMethodName: "Array.prototype.find" } }] },
         { code: "foo.find(function foo() {})", errors: [{ messageId: "expectedInside", data: { name: "function 'foo'", arrayMethodName: "Array.prototype.find" } }] },
+        { code: "foo.findLast(function() {})", errors: [{ messageId: "expectedInside", data: { name: "function", arrayMethodName: "Array.prototype.findLast" } }] },
+        { code: "foo.findLast(function foo() {})", errors: [{ messageId: "expectedInside", data: { name: "function 'foo'", arrayMethodName: "Array.prototype.findLast" } }] },
         { code: "foo.findIndex(function() {})", errors: [{ messageId: "expectedInside", data: { name: "function", arrayMethodName: "Array.prototype.findIndex" } }] },
         { code: "foo.findIndex(function foo() {})", errors: [{ messageId: "expectedInside", data: { name: "function 'foo'", arrayMethodName: "Array.prototype.findIndex" } }] },
+        { code: "foo.findLastIndex(function() {})", errors: [{ messageId: "expectedInside", data: { name: "function", arrayMethodName: "Array.prototype.findLastIndex" } }] },
+        { code: "foo.findLastIndex(function foo() {})", errors: [{ messageId: "expectedInside", data: { name: "function 'foo'", arrayMethodName: "Array.prototype.findLastIndex" } }] },
         { code: "foo.flatMap(function() {})", errors: [{ messageId: "expectedInside", data: { name: "function", arrayMethodName: "Array.prototype.flatMap" } }] },
         { code: "foo.flatMap(function foo() {})", errors: [{ messageId: "expectedInside", data: { name: "function 'foo'", arrayMethodName: "Array.prototype.flatMap" } }] },
         { code: "foo.map(function() {})", errors: [{ messageId: "expectedInside", data: { name: "function", arrayMethodName: "Array.prototype.map" } }] },
@@ -143,6 +153,8 @@ ruleTester.run("array-callback-return", rule, {
         { code: "foo.some(function foo() {})", errors: [{ messageId: "expectedInside", data: { name: "function 'foo'", arrayMethodName: "Array.prototype.some" } }] },
         { code: "foo.sort(function() {})", errors: [{ messageId: "expectedInside", data: { name: "function", arrayMethodName: "Array.prototype.sort" } }] },
         { code: "foo.sort(function foo() {})", errors: [{ messageId: "expectedInside", data: { name: "function 'foo'", arrayMethodName: "Array.prototype.sort" } }] },
+        { code: "foo.toSorted(function() {})", errors: [{ messageId: "expectedInside", data: { name: "function", arrayMethodName: "Array.prototype.toSorted" } }] },
+        { code: "foo.toSorted(function foo() {})", errors: [{ messageId: "expectedInside", data: { name: "function 'foo'", arrayMethodName: "Array.prototype.toSorted" } }] },
         { code: "foo.bar.baz.every(function() {})", errors: [{ messageId: "expectedInside", data: { name: "function", arrayMethodName: "Array.prototype.every" } }] },
         { code: "foo.bar.baz.every(function foo() {})", errors: [{ messageId: "expectedInside", data: { name: "function 'foo'", arrayMethodName: "Array.prototype.every" } }] },
         { code: "foo[\"every\"](function() {})", errors: [{ messageId: "expectedInside", data: { name: "function", arrayMethodName: "Array.prototype.every" } }] },
@@ -182,6 +194,7 @@ ruleTester.run("array-callback-return", rule, {
         { code: "foo.bar.baz.every(function foo() {})", options: allowImplicitOptions, errors: [{ messageId: "expectedInside", data: { name: "function 'foo'", arrayMethodName: "Array.prototype.every" } }] },
         { code: "foo.every(cb || function() {})", options: allowImplicitOptions, errors: ["Array.prototype.every() expects a return value from function."] },
         { code: "[\"foo\",\"bar\"].sort(function foo() {})", options: allowImplicitOptions, errors: [{ messageId: "expectedInside", data: { name: "function 'foo'", arrayMethodName: "Array.prototype.sort" } }] },
+        { code: "[\"foo\",\"bar\"].toSorted(function foo() {})", options: allowImplicitOptions, errors: [{ messageId: "expectedInside", data: { name: "function 'foo'", arrayMethodName: "Array.prototype.toSorted" } }] },
         { code: "foo.forEach(x => x)", options: allowImplicitCheckForEach, parserOptions: { ecmaVersion: 6 }, errors: [{ messageId: "expectedNoReturnValue", data: { name: "arrow function", arrayMethodName: "Array.prototype.forEach" } }] },
         { code: "foo.forEach(function(x) { if (a == b) {return x;}})", options: allowImplicitCheckForEach, errors: [{ messageId: "expectedNoReturnValue", data: { name: "function", arrayMethodName: "Array.prototype.forEach" } }] },
         { code: "foo.forEach(function bar(x) { return x;})", options: allowImplicitCheckForEach, errors: [{ messageId: "expectedNoReturnValue", data: { name: "function 'bar'", arrayMethodName: "Array.prototype.forEach" } }] },