|
| 1 | +/** |
| 2 | + * @author Yosuke Ota |
| 3 | + * See LICENSE file in root directory for full license. |
| 4 | + */ |
| 5 | +"use strict" |
| 6 | + |
| 7 | +const RuleTester = require("../../tester") |
| 8 | +const rule = require("../../../lib/rules/no-regexp-unicode-property-escapes-2022.js") |
| 9 | + |
| 10 | +if (!RuleTester.isSupported(2022)) { |
| 11 | + //eslint-disable-next-line no-console |
| 12 | + console.log("Skip the tests of no-regexp-unicode-property-escapes-2022.") |
| 13 | + return |
| 14 | +} |
| 15 | + |
| 16 | +new RuleTester().run("no-regexp-unicode-property-escapes-2022", rule, { |
| 17 | + valid: [ |
| 18 | + String.raw`/\p{Script=Cpmn}/u`, |
| 19 | + String.raw`/\p{Letter}/u`, |
| 20 | + String.raw`/\P{Letter}/u`, |
| 21 | + String.raw`/\p{Script=Hiragana}/u`, |
| 22 | + String.raw`/\P{Script=Hiragana}/u`, |
| 23 | + String.raw`/\p{Extended_Pictographic}/`, |
| 24 | + String.raw`/\P{Extended_Pictographic}/`, |
| 25 | + String.raw`/\p{Script=Dogr}/`, |
| 26 | + String.raw`/\P{Script=Dogr}/`, |
| 27 | + String.raw`new RegExp('\\p{Extended_Pictographic}')`, |
| 28 | + String.raw`new RegExp('\\\\p{Extended_Pictographic}', 'u')`, |
| 29 | + String.raw`/\p{Extended_Pictographic}/u`, |
| 30 | + String.raw`/\p{Script=Dogr}/u`, |
| 31 | + String.raw`/\p{Script=Elym}/u`, |
| 32 | + String.raw`/\p{EBase}/u`, |
| 33 | + String.raw`/\p{Script=Chorasmian}/u`, |
| 34 | + ], |
| 35 | + invalid: [ |
| 36 | + { |
| 37 | + code: String.raw`/\p{Script=Cpmn}/u`, |
| 38 | + errors: ["ES2022 '\\p{Script=Cpmn}' is forbidden."], |
| 39 | + }, |
| 40 | + { |
| 41 | + code: String.raw`/\p{Script=Cypro_Minoan}/u`, |
| 42 | + errors: ["ES2022 '\\p{Script=Cypro_Minoan}' is forbidden."], |
| 43 | + }, |
| 44 | + { |
| 45 | + code: String.raw`/\p{Script=Old_Uyghur}/u`, |
| 46 | + errors: ["ES2022 '\\p{Script=Old_Uyghur}' is forbidden."], |
| 47 | + }, |
| 48 | + { |
| 49 | + code: String.raw`/\p{Script=Ougr}/u`, |
| 50 | + errors: ["ES2022 '\\p{Script=Ougr}' is forbidden."], |
| 51 | + }, |
| 52 | + { |
| 53 | + code: String.raw`/\p{Script=Tangsa}/u`, |
| 54 | + errors: ["ES2022 '\\p{Script=Tangsa}' is forbidden."], |
| 55 | + }, |
| 56 | + { |
| 57 | + code: String.raw`/\p{Script=Tnsa}/u`, |
| 58 | + errors: ["ES2022 '\\p{Script=Tnsa}' is forbidden."], |
| 59 | + }, |
| 60 | + { |
| 61 | + code: String.raw`/\p{Script=Toto}/u`, |
| 62 | + errors: ["ES2022 '\\p{Script=Toto}' is forbidden."], |
| 63 | + }, |
| 64 | + { |
| 65 | + code: String.raw`/\p{Script=Vith}/u`, |
| 66 | + errors: ["ES2022 '\\p{Script=Vith}' is forbidden."], |
| 67 | + }, |
| 68 | + { |
| 69 | + code: String.raw`/\p{Script=Vithkuqi}/u`, |
| 70 | + errors: ["ES2022 '\\p{Script=Vithkuqi}' is forbidden."], |
| 71 | + }, |
| 72 | + ], |
| 73 | +}) |
0 commit comments