Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 5ba2f58

Browse files
committed
Add rule jsdoc/require-returns-type
1 parent 9aba2e3 commit 5ba2f58

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

src/rules/jsdoc/index.d.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@ import type { MatchDescriptionRule } from './match-description';
22
import type { NoTypesRule } from './no-types';
33
import type { RequireJsdocRule } from './require-jsdoc';
44
import type { RequireParamTypeRule } from './require-param-type';
5+
import type { RequireReturnsTypeRule } from './require-returns-type';
56

67
/**
78
* All jsdoc rules.
89
*/
9-
export type JSDocRules = MatchDescriptionRule & NoTypesRule & RequireJsdocRule & RequireParamTypeRule;
10+
export type JSDocRules = MatchDescriptionRule &
11+
NoTypesRule &
12+
RequireJsdocRule &
13+
RequireParamTypeRule &
14+
RequireReturnsTypeRule;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import type { RuleConfig } from '../rule-config';
2+
3+
/**
4+
* Option.
5+
*/
6+
export type RequireReturnsTypeOption = {
7+
/**
8+
* Set this to an array of strings representing the AST context where you wish the rule to be applied.
9+
*
10+
* Set to `"any"` if you want the rule to apply to any jsdoc block throughout your files (as is necessary for finding function blocks not attached to a function declaration or expression, i.e., `@callback` or `@function` (or its aliases `@func` or `@method`) (including those associated with an `@interface`).
11+
*
12+
* See the ["AST and Selectors"](https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-advanced-ast-and-selectors) section of our README for more on the expected format.
13+
*
14+
* @see [contexts](https://github.com/gajus/eslint-plugin-jsdoc#contexts-3)
15+
*/
16+
contexts?: string[];
17+
};
18+
19+
/**
20+
* Options.
21+
*/
22+
export type RequireReturnsTypeOptions = [RequireReturnsTypeOption?];
23+
24+
/**
25+
* Requires that `@returns` tag has `type` value.
26+
*
27+
* @see [require-returns-type](https://github.com/gajus/eslint-plugin-jsdoc#require-returns-type)
28+
*/
29+
export type RequireReturnsTypeRuleConfig = RuleConfig<RequireReturnsTypeOptions>;
30+
31+
/**
32+
* Requires that `@returns` tag has `type` value.
33+
*
34+
* @see [require-returns-type](https://github.com/gajus/eslint-plugin-jsdoc#require-returns-type)
35+
*/
36+
export interface RequireReturnsTypeRule {
37+
/**
38+
* Requires that `@returns` tag has `type` value.
39+
*
40+
* @see [require-returns-type](https://github.com/gajus/eslint-plugin-jsdoc#require-returns-type)
41+
*/
42+
'jsdoc/require-returns-type': RequireReturnsTypeRuleConfig;
43+
}

0 commit comments

Comments
 (0)