Skip to content

Commit

Permalink
feat(no-types): add TSMethodSignature; fixes #1249
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed Jun 24, 2024
1 parent 5497b03 commit 1aa3313
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docs/rules/no-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ function quux () {

}
// Message: Types are not permitted on @returns.

export interface B {
/**
* @param {string} paramA
*/
methodB(paramB: string): void
}
// Message: Types are not permitted on @param.
````


Expand Down
6 changes: 5 additions & 1 deletion src/rules/noTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ export default iterateJsdoc(({
}
}
}, {
contextDefaults: true,
contextDefaults: [
'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction',
// Add this to above defaults
'TSMethodSignature'
],
meta: {
docs: {
description: 'This rule reports types being used on `@param` or `@returns`.',
Expand Down
29 changes: 29 additions & 0 deletions test/rules/assertions/noTypes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as typescriptEslintParser from '@typescript-eslint/parser';

export default {
invalid: [
{
Expand Down Expand Up @@ -226,6 +228,33 @@ export default {
}
`,
},
{
code: `
export interface B {
/**
* @param {string} paramA
*/
methodB(paramB: string): void
}
`,
errors: [
{
line: 4,
message: 'Types are not permitted on @param.',
},
],
languageOptions: {
parser: typescriptEslintParser
},
output: `
export interface B {
/**
* @param paramA
*/
methodB(paramB: string): void
}
`,
}
],
valid: [
{
Expand Down

0 comments on commit 1aa3313

Please sign in to comment.