|
| 1 | +"use strict" |
| 2 | + |
| 3 | +const RuleTester = require("../../tester") |
| 4 | +const rule = require("../../../lib/rules/no-array-fromasync") |
| 5 | + |
| 6 | +new RuleTester().run("no-array-fromasync", rule, { |
| 7 | + valid: [ |
| 8 | + "Array", |
| 9 | + "Array.from", |
| 10 | + "let Array = 0; Array.fromAsync", |
| 11 | + { |
| 12 | + code: "if (Array.fromAsync) { Array.fromAsync }", |
| 13 | + options: [{ allowTestedProperty: true }], |
| 14 | + }, |
| 15 | + { |
| 16 | + code: "if (Array.fromAsync) { Array.fromAsync }", |
| 17 | + settings: { "es-x": { allowTestedProperty: true } }, |
| 18 | + }, |
| 19 | + { |
| 20 | + code: "if (Array.fromAsync) { const {fromAsync} = Array }", |
| 21 | + options: [{ allowTestedProperty: true }], |
| 22 | + }, |
| 23 | + ], |
| 24 | + invalid: [ |
| 25 | + { |
| 26 | + code: "Array.fromAsync", |
| 27 | + errors: ["ES2026 'Array.fromAsync' method is forbidden."], |
| 28 | + }, |
| 29 | + { |
| 30 | + code: "const {fromAsync} = Array", |
| 31 | + errors: ["ES2026 'Array.fromAsync' method is forbidden."], |
| 32 | + }, |
| 33 | + { |
| 34 | + code: "const {a:{fromAsync} = Array} = {}", |
| 35 | + errors: ["ES2026 'Array.fromAsync' method is forbidden."], |
| 36 | + }, |
| 37 | + { |
| 38 | + code: "if (Array.fromAsync) { Array.fromAsync }", |
| 39 | + errors: 2, |
| 40 | + }, |
| 41 | + { |
| 42 | + code: "if (Array.fromAsync) { }", |
| 43 | + options: [{ allowTestedProperty: true }], |
| 44 | + errors: ["ES2026 'Array.fromAsync' method is forbidden."], |
| 45 | + }, |
| 46 | + ], |
| 47 | +}) |
0 commit comments