Skip to content

Commit

Permalink
fix(eslint-plugin): [dot-notation] handle missing declarations (#1947)
Browse files Browse the repository at this point in the history
also minor perf improvement
  • Loading branch information
bradzacher committed Apr 29, 2020
1 parent f7ec192 commit 383f931
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions packages/eslint-plugin/src/rules/dot-notation.ts
Expand Up @@ -62,16 +62,17 @@ export default createRule<Options, MessageIds>({

return {
MemberExpression(node: TSESTree.MemberExpression): void {
const objectSymbol = typeChecker.getSymbolAtLocation(
parserServices.esTreeNodeToTSNodeMap.get(node.property),
);

if (
allowPrivateClassPropertyAccess &&
objectSymbol?.declarations[0]?.modifiers?.[0].kind ===
if (allowPrivateClassPropertyAccess && node.computed) {
// for perf reasons - only fetch the symbol if we have to
const objectSymbol = typeChecker.getSymbolAtLocation(
parserServices.esTreeNodeToTSNodeMap.get(node.property),
);
if (
objectSymbol?.getDeclarations()?.[0]?.modifiers?.[0].kind ===
ts.SyntaxKind.PrivateKeyword
) {
return;
) {
return;
}
}
rules.MemberExpression(node);
},
Expand Down

0 comments on commit 383f931

Please sign in to comment.