Skip to content

fix(eslint-plugin): [no-unsafe-member-access] ignore MemberExpression's whose parents are either TSClassImplements or TSInterfaceHeritage #2753

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

Merged
merged 3 commits into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/eslint-plugin/src/rules/no-unsafe-member-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ export default util.createRule({
}

return {
MemberExpression: checkMemberExpression,
// ignore MemberExpression if it's parent is TSClassImplements or TSInterfaceHeritage
':not(TSClassImplements, TSInterfaceHeritage) > MemberExpression': checkMemberExpression,
'MemberExpression[computed = true] > *.property'(
node: TSESTree.Expression,
): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ function foo(x?: string[]) {
x?.[(1 as any)++];
}
`,
`
class B implements FG.A {}
`,
`
interface B extends FG.A {}
`,
],
invalid: [
...batchedSingleLineTests({
Expand Down