@@ -70,8 +70,14 @@ ruleTester.run("no-underscore-dangle", rule, {
7070 { code : "function foo( { _bar }) {}" , options : [ { allowFunctionParams : false } ] , parserOptions : { ecmaVersion : 6 } } ,
7171 { code : "function foo( { _bar = 0 } = {}) {}" , options : [ { allowFunctionParams : false } ] , parserOptions : { ecmaVersion : 6 } } ,
7272 { code : "function foo(...[_bar]) {}" , options : [ { allowFunctionParams : false } ] , parserOptions : { ecmaVersion : 2016 } } ,
73+ { code : "const [_foo] = arr" , parserOptions : { ecmaVersion : 6 } } ,
74+ { code : "const [_foo] = arr" , options : [ { } ] , parserOptions : { ecmaVersion : 6 } } ,
75+ { code : "const [_foo] = arr" , options : [ { allowInArrayDestructuring : true } ] , parserOptions : { ecmaVersion : 6 } } ,
7376 { code : "const [foo, ...rest] = [1, 2, 3]" , options : [ { allowInArrayDestructuring : false } ] , parserOptions : { ecmaVersion : 2022 } } ,
7477 { code : "const [foo, _bar] = [1, 2, 3]" , options : [ { allowInArrayDestructuring : false , allow : [ "_bar" ] } ] , parserOptions : { ecmaVersion : 2022 } } ,
78+ { code : "const { _foo } = obj" , parserOptions : { ecmaVersion : 6 } } ,
79+ { code : "const { _foo } = obj" , options : [ { } ] , parserOptions : { ecmaVersion : 6 } } ,
80+ { code : "const { _foo } = obj" , options : [ { allowInObjectDestructuring : true } ] , parserOptions : { ecmaVersion : 6 } } ,
7581 { code : "const { foo, bar: _bar } = { foo: 1, bar: 2 }" , options : [ { allowInObjectDestructuring : false , allow : [ "_bar" ] } ] , parserOptions : { ecmaVersion : 2022 } } ,
7682 { code : "const { foo, _bar } = { foo: 1, _bar: 2 }" , options : [ { allowInObjectDestructuring : false , allow : [ "_bar" ] } ] , parserOptions : { ecmaVersion : 2022 } } ,
7783 { code : "const { foo, _bar: bar } = { foo: 1, _bar: 2 }" , options : [ { allowInObjectDestructuring : false } ] , parserOptions : { ecmaVersion : 2022 } } ,
@@ -112,6 +118,11 @@ ruleTester.run("no-underscore-dangle", rule, {
112118 options : [ { allowInArrayDestructuring : false } ] ,
113119 parserOptions : { ecmaVersion : 2022 } ,
114120 errors : [ { messageId : "unexpectedUnderscore" , data : { identifier : "_bar" } } ]
121+ } , {
122+ code : "const [_foo = 1] = arr" ,
123+ options : [ { allowInArrayDestructuring : false } ] ,
124+ parserOptions : { ecmaVersion : 2022 } ,
125+ errors : [ { messageId : "unexpectedUnderscore" , data : { identifier : "_foo" } } ]
115126 } , {
116127 code : "const [foo, ..._rest] = [1, 2, 3]" ,
117128 options : [ { allowInArrayDestructuring : false } ] ,
@@ -127,6 +138,16 @@ ruleTester.run("no-underscore-dangle", rule, {
127138 options : [ { allowInObjectDestructuring : false } ] ,
128139 parserOptions : { ecmaVersion : 2022 } ,
129140 errors : [ { messageId : "unexpectedUnderscore" , data : { identifier : "_foo" } } ]
141+ } , {
142+ code : "const { _foo = 1 } = obj" ,
143+ options : [ { allowInObjectDestructuring : false } ] ,
144+ parserOptions : { ecmaVersion : 2022 } ,
145+ errors : [ { messageId : "unexpectedUnderscore" , data : { identifier : "_foo" } } ]
146+ } , {
147+ code : "const { bar: _foo = 1 } = obj" ,
148+ options : [ { allowInObjectDestructuring : false } ] ,
149+ parserOptions : { ecmaVersion : 2022 } ,
150+ errors : [ { messageId : "unexpectedUnderscore" , data : { identifier : "_foo" } } ]
130151 } , {
131152 code : "const { foo: _foo, bar } = { foo: 1, bar: 2 }" ,
132153 options : [ { allowInObjectDestructuring : false } ] ,
0 commit comments