Skip to content

Commit

Permalink
More cases and format
Browse files Browse the repository at this point in the history
  • Loading branch information
Omri Luzon committed Nov 18, 2022
1 parent a3b6eda commit a68b13a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/eslint-plugin/src/rules/prefer-optional-chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,12 @@ export default util.createRule({

/* istanbul ignore next */
default:
if (![AST_NODE_TYPES.Identifier, AST_NODE_TYPES.ThisExpression].includes(node.object.type)) {
if (
![
AST_NODE_TYPES.Identifier,
AST_NODE_TYPES.ThisExpression,
].includes(node.object.type)
) {
throw new Error(
`Unexpected member property type: ${node.object.type}`,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ ruleTester.run('prefer-optional-chain', rule, {
'!a.#foo || !a.#foo.bar;',
'a.#foo?.bar;',
'!a.#foo?.bar;',
'foo().#a;',
'a.b.#a;',
'new A().#b;',
'(await a).#b;',
// currently do not handle complex computed properties
'foo && foo[bar as string] && foo[bar as string].baz;',
'foo && foo[1 + 2] && foo[1 + 2].baz;',
Expand Down

0 comments on commit a68b13a

Please sign in to comment.