+ code: "const [foo, _bar] = [1, 2]",
+ options: [{ allowInArrayDestructuring: false }],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [{ messageId: "unexpectedUnderscore", data: { identifier: "_bar" } }]
+ }, {
+ code: "const [_foo = 1] = arr",
+ options: [{ allowInArrayDestructuring: false }],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [{ messageId: "unexpectedUnderscore", data: { identifier: "_foo" } }]
+ }, {
+ code: "const [foo, ..._rest] = [1, 2, 3]",
+ options: [{ allowInArrayDestructuring: false }],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [{ messageId: "unexpectedUnderscore", data: { identifier: "_rest" } }]
+ }, {
+ code: "const [foo, [bar_, baz]] = [1, [2, 3]]",
+ options: [{ allowInArrayDestructuring: false }],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [{ messageId: "unexpectedUnderscore", data: { identifier: "bar_" } }]
+ }, {
+ code: "const { _foo, bar } = { _foo: 1, bar: 2 }",
+ options: [{ allowInObjectDestructuring: false }],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [{ messageId: "unexpectedUnderscore", data: { identifier: "_foo" } }]
+ }, {
+ code: "const { _foo = 1 } = obj",
+ options: [{ allowInObjectDestructuring: false }],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [{ messageId: "unexpectedUnderscore", data: { identifier: "_foo" } }]
+ }, {
+ code: "const { bar: _foo = 1 } = obj",
+ options: [{ allowInObjectDestructuring: false }],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [{ messageId: "unexpectedUnderscore", data: { identifier: "_foo" } }]
+ }, {
+ code: "const { foo: _foo, bar } = { foo: 1, bar: 2 }",
+ options: [{ allowInObjectDestructuring: false }],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [{ messageId: "unexpectedUnderscore", data: { identifier: "_foo" } }]
+ }, {
+ code: "const { foo, ..._rest} = { foo: 1, bar: 2, baz: 3 }",
+ options: [{ allowInObjectDestructuring: false }],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [{ messageId: "unexpectedUnderscore", data: { identifier: "_rest" } }]
+ }, {
+ code: "const { foo: [_bar, { a: _a, b } ] } = { foo: [1, { a: 'a', b: 'b' }] }",
+ options: [{ allowInArrayDestructuring: false, allowInObjectDestructuring: false }],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [
+ { messageId: "unexpectedUnderscore", data: { identifier: "_bar" } },
+ { messageId: "unexpectedUnderscore", data: { identifier: "_a" } }
+ ]
+ }, {
+ code: "const { foo: [_bar, { a: _a, b } ] } = { foo: [1, { a: 'a', b: 'b' }] }",
+ options: [{ allowInArrayDestructuring: true, allowInObjectDestructuring: false }],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [{ messageId: "unexpectedUnderscore", data: { identifier: "_a" } }]
+ }, {
+ code: "const [{ foo: [_bar, _, { bar: _baz }] }] = [{ foo: [1, 2, { bar: 'a' }] }]",
+ options: [{ allowInArrayDestructuring: false, allowInObjectDestructuring: false }],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [
+ { messageId: "unexpectedUnderscore", data: { identifier: "_bar" } },
+ { messageId: "unexpectedUnderscore", data: { identifier: "_baz" } }
+ ]
+ }, {
+ code: "const { foo, bar: { baz, _qux } } = { foo: 1, bar: { baz: 3, _qux: 4 } }",
+ options: [{ allowInObjectDestructuring: false }],
+ parserOptions: { ecmaVersion: 2022 },
+ errors: [{ messageId: "unexpectedUnderscore", data: { identifier: "_qux" } }]
+ }, {