Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(eslint-plugin): [prefer-optional-chain] collect MetaProperty type #6083

Merged
merged 4 commits into from Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/eslint-plugin/src/rules/prefer-optional-chain.ts
Expand Up @@ -381,6 +381,10 @@ export default util.createRule({
objectText = getMemberExpressionText(node.object);
break;

case AST_NODE_TYPES.MetaProperty:
objectText = getText(node.object.meta);
break;

case AST_NODE_TYPES.ThisExpression:
objectText = getText(node.object);
break;
Expand Down
Expand Up @@ -211,6 +211,7 @@ ruleTester.run('prefer-optional-chain', rule, {
'!foo!.bar || !foo!.bar.baz;',
'!foo!.bar!.baz || !foo!.bar!.baz!.paz;',
'!foo.bar!.baz || !foo.bar!.baz!.paz;',
'!import.meta.url || true;',
JoshuaKGoldberg marked this conversation as resolved.
Show resolved Hide resolved
],
invalid: [
...baseCases,
Expand Down