From c505863ac41755383e08893ba0bc4c0fd937eb1d Mon Sep 17 00:00:00 2001 From: thomas michael wallace Date: Sun, 18 Oct 2020 19:50:06 +0100 Subject: [PATCH] fix(eslint-plugin): [naming-convention] check bodyless function parameters (#2675) --- .../eslint-plugin/src/rules/naming-convention.ts | 5 +++-- .../tests/rules/naming-convention.test.ts | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/src/rules/naming-convention.ts b/packages/eslint-plugin/src/rules/naming-convention.ts index 3acfa116b8f..295e8209e89 100644 --- a/packages/eslint-plugin/src/rules/naming-convention.ts +++ b/packages/eslint-plugin/src/rules/naming-convention.ts @@ -529,10 +529,11 @@ export default util.createRule({ // #endregion function // #region parameter - - 'FunctionDeclaration, TSDeclareFunction, FunctionExpression, ArrowFunctionExpression'( + 'FunctionDeclaration, TSDeclareFunction, TSEmptyBodyFunctionExpression, FunctionExpression, ArrowFunctionExpression'( node: | TSESTree.FunctionDeclaration + | TSESTree.TSDeclareFunction + | TSESTree.TSEmptyBodyFunctionExpression | TSESTree.FunctionExpression | TSESTree.ArrowFunctionExpression, ): void { diff --git a/packages/eslint-plugin/tests/rules/naming-convention.test.ts b/packages/eslint-plugin/tests/rules/naming-convention.test.ts index 634ad424559..c57dfc984d4 100644 --- a/packages/eslint-plugin/tests/rules/naming-convention.test.ts +++ b/packages/eslint-plugin/tests/rules/naming-convention.test.ts @@ -1316,5 +1316,20 @@ ruleTester.run('naming-convention', rule, { }, ], }, + { + code: ` + declare class Foo { + Bar(Baz: string): void; + } + `, + parserOptions, + options: [{ selector: 'parameter', format: ['camelCase'] }], + errors: [ + { + line: 3, + messageId: 'doesNotMatchFormat', + }, + ], + }, ], });