@@ -10,12 +10,19 @@ const { builtin } = require("globals")
10
10
const { Range } = require ( "semver" )
11
11
const rule = require ( "../../../../lib/rules/no-unsupported-features/es-syntax" )
12
12
13
- const ES2020Supported = ( ( ) => {
14
- const config = { parserOptions : { ecmaVersion : 2020 } }
13
+ const ES2021Supported = ( ( ) => {
14
+ const config = { parserOptions : { ecmaVersion : 2021 } }
15
15
const messages = new Linter ( ) . verify ( "0n" , config )
16
16
return messages . length === 0
17
17
} ) ( )
18
- const ecmaVersion = ES2020Supported ? 2020 : 2019
18
+ const ES2020Supported =
19
+ ES2021Supported ||
20
+ ( ( ) => {
21
+ const config = { parserOptions : { ecmaVersion : 2020 } }
22
+ const messages = new Linter ( ) . verify ( "0n" , config )
23
+ return messages . length === 0
24
+ } ) ( )
25
+ const ecmaVersion = ES2021Supported ? 2021 : ES2020Supported ? 2020 : 2019
19
26
20
27
/**
21
28
* Makes a file path to a fixture.
@@ -1553,7 +1560,6 @@ ruleTester.run(
1553
1560
] ,
1554
1561
} ,
1555
1562
] ,
1556
- /*eslint-enable no-template-curly-in-string */
1557
1563
} ,
1558
1564
{
1559
1565
keyword : "unicodeCodePointEscapes" ,
@@ -2592,6 +2598,93 @@ ruleTester.run(
2592
2598
] ,
2593
2599
} ,
2594
2600
2601
+ //----------------------------------------------------------------------
2602
+ // ES2021
2603
+ //----------------------------------------------------------------------
2604
+ {
2605
+ keyword : "logicalAssignmentOperators" ,
2606
+ requiredEcmaVersion : 2021 ,
2607
+ valid : [
2608
+ {
2609
+ code : "a ||= b" ,
2610
+ options : [ { version : "15.0.0" } ] ,
2611
+ } ,
2612
+ {
2613
+ code : "a &&= b" ,
2614
+ options : [ { version : "15.0.0" } ] ,
2615
+ } ,
2616
+ {
2617
+ code : "a ??= b" ,
2618
+ options : [ { version : "15.0.0" } ] ,
2619
+ } ,
2620
+ ] ,
2621
+ invalid : [
2622
+ {
2623
+ code : "a ||= b" ,
2624
+ options : [ { version : "14.0.0" } ] ,
2625
+ errors : [
2626
+ {
2627
+ messageId : "no-logical-assignment-operators" ,
2628
+ data : {
2629
+ supported : "15.0.0" ,
2630
+ version : "14.0.0" ,
2631
+ } ,
2632
+ } ,
2633
+ ] ,
2634
+ } ,
2635
+ {
2636
+ code : "a &&= b" ,
2637
+ options : [ { version : "14.0.0" } ] ,
2638
+ errors : [
2639
+ {
2640
+ messageId : "no-logical-assignment-operators" ,
2641
+ data : {
2642
+ supported : "15.0.0" ,
2643
+ version : "14.0.0" ,
2644
+ } ,
2645
+ } ,
2646
+ ] ,
2647
+ } ,
2648
+ {
2649
+ code : "a ??= b" ,
2650
+ options : [ { version : "14.0.0" } ] ,
2651
+ errors : [
2652
+ {
2653
+ messageId : "no-logical-assignment-operators" ,
2654
+ data : {
2655
+ supported : "15.0.0" ,
2656
+ version : "14.0.0" ,
2657
+ } ,
2658
+ } ,
2659
+ ] ,
2660
+ } ,
2661
+ ] ,
2662
+ } ,
2663
+ {
2664
+ keyword : "numericSeparators" ,
2665
+ requiredEcmaVersion : 2021 ,
2666
+ valid : [
2667
+ {
2668
+ code : "a = 123_456_789" ,
2669
+ options : [ { version : "12.5.0" } ] ,
2670
+ } ,
2671
+ ] ,
2672
+ invalid : [
2673
+ {
2674
+ code : "a = 123_456_789" ,
2675
+ options : [ { version : "12.4.0" } ] ,
2676
+ errors : [
2677
+ {
2678
+ messageId : "no-numeric-separators" ,
2679
+ data : {
2680
+ supported : "12.5.0" ,
2681
+ version : "12.4.0" ,
2682
+ } ,
2683
+ } ,
2684
+ ] ,
2685
+ } ,
2686
+ ] ,
2687
+ } ,
2595
2688
//----------------------------------------------------------------------
2596
2689
// MISC
2597
2690
//----------------------------------------------------------------------
@@ -2663,7 +2756,7 @@ ruleTester.run(
2663
2756
{
2664
2757
filename : fixture ( "invalid/a.js" ) ,
2665
2758
code : "var a = { ...obj }" ,
2666
- options : [ { version : ' >=8.0.0' } ] ,
2759
+ options : [ { version : " >=8.0.0" } ] ,
2667
2760
errors : [
2668
2761
{
2669
2762
messageId : "no-rest-spread-properties" ,
@@ -2684,7 +2777,7 @@ ruleTester.run(
2684
2777
{
2685
2778
filename : fixture ( "nothing/a.js" ) ,
2686
2779
code : "var a = { ...obj }" ,
2687
- options : [ { version : ' >=8.0.0' } ] ,
2780
+ options : [ { version : " >=8.0.0" } ] ,
2688
2781
errors : [
2689
2782
{
2690
2783
messageId : "no-rest-spread-properties" ,
0 commit comments