Skip to content

Commit 1aa3313

Browse files
committedJun 24, 2024·
feat(no-types): add TSMethodSignature; fixes #1249
1 parent 5497b03 commit 1aa3313

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed
 

‎docs/rules/no-types.md

+8
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ function quux () {
129129

130130
}
131131
// Message: Types are not permitted on @returns.
132+
133+
export interface B {
134+
/**
135+
* @param {string} paramA
136+
*/
137+
methodB(paramB: string): void
138+
}
139+
// Message: Types are not permitted on @param.
132140
````
133141

134142

‎src/rules/noTypes.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ export default iterateJsdoc(({
3131
}
3232
}
3333
}, {
34-
contextDefaults: true,
34+
contextDefaults: [
35+
'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction',
36+
// Add this to above defaults
37+
'TSMethodSignature'
38+
],
3539
meta: {
3640
docs: {
3741
description: 'This rule reports types being used on `@param` or `@returns`.',

‎test/rules/assertions/noTypes.js

+29
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as typescriptEslintParser from '@typescript-eslint/parser';
2+
13
export default {
24
invalid: [
35
{
@@ -226,6 +228,33 @@ export default {
226228
}
227229
`,
228230
},
231+
{
232+
code: `
233+
export interface B {
234+
/**
235+
* @param {string} paramA
236+
*/
237+
methodB(paramB: string): void
238+
}
239+
`,
240+
errors: [
241+
{
242+
line: 4,
243+
message: 'Types are not permitted on @param.',
244+
},
245+
],
246+
languageOptions: {
247+
parser: typescriptEslintParser
248+
},
249+
output: `
250+
export interface B {
251+
/**
252+
* @param paramA
253+
*/
254+
methodB(paramB: string): void
255+
}
256+
`,
257+
}
229258
],
230259
valid: [
231260
{

0 commit comments

Comments
 (0)
Please sign in to comment.