8000 fix(eslint-plugin): [dot-notation] handle missing declarations (#1947) · DudaGod/typescript-eslint@383f931 · GitHub
[go: up one dir, main page]

Skip to content

Commit 383f931

Browse files
authored
fix(eslint-plugin): [dot-notation] handle missing declarations (typescript-eslint#1947)
also minor perf improvement
1 parent f7ec192 commit 383f931

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

packages/eslint-plugin/src/rules/dot-notation.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,17 @@ export default createRule<Options, MessageIds>({
6262

6363
return {
6464
MemberExpression(node: TSESTree.MemberExpression): void {
65-
const objectSymbol = typeChecker.getSymbolAtLocation(
66-
parserServices.esTreeNodeToTSNodeMap.get(node.property),
67-
);
68-
69-
if (
70-
allowPrivateClassPropertyAccess &&
71-
objectSymbol?.declarations[0]?.modifiers?.[0].kind ===
65+
if (allowPrivateClassPropertyAccess && node.computed) {
66+
// for perf reasons - only fetch the symbol if we have to
67+
const objectSymbol = typeChecker.getSymbolAtLocation(
68+
parserServices.esTreeNodeToTSNodeMap.get(node.property),
69+
);
70+
if (
71+
objectSymbol?.getDeclarations()?.[0]?.modifiers?.[0].kind ===
7272
ts.SyntaxKind.PrivateKeyword
73-
) {
74-
return;
73+
) {
74+
return;
75+
}
7576
}
7677
rules.MemberExpression(node);
7778
},

0 commit comments

Comments
 (0)
0