From 80b853db90ae3d4e32c4b7ec9d45a5c41dc459c9 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 31 Oct 2021 23:30:18 -0400 Subject: [PATCH] fix(eslint-plugin): ignore private identifiers in explicit-module-boundary-types (#4046) --- .../src/rules/explicit-module-boundary-types.ts | 10 ++++++++-- .../tests/rules/explicit-module-boundary-types.test.ts | 10 ++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts index e189727463f..adaacaf363f 100644 --- a/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts +++ b/packages/eslint-plugin/src/rules/explicit-module-boundary-types.ts @@ -336,7 +336,10 @@ export default util.createRule({ return; case AST_NODE_TYPES.PropertyDefinition: - if (node.accessibility === 'private') { + if ( + node.accessibility === 'private' || + node.key.type === AST_NODE_TYPES.PrivateIdentifier + ) { return; } return checkNode(node.value); @@ -353,7 +356,10 @@ export default util.createRule({ case AST_NODE_TYPES.MethodDefinition: case AST_NODE_TYPES.TSAbstractMethodDefinition: - if (node.accessibility === 'private') { + if ( + node.accessibility === 'private' || + node.key.type === AST_NODE_TYPES.PrivateIdentifier + ) { return; } return checkNode(node.value); diff --git a/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts b/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts index ba80da5b588..e511e29d682 100644 --- a/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts +++ b/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts @@ -82,6 +82,16 @@ export class Test { } `, }, + ` +export class PrivateProperty { + #property = () => null; +} + `, + ` +export class PrivateMethod { + #method() {} +} + `, { // https://github.com/typescript-eslint/typescript-eslint/issues/2150 code: `