Skip to content

Commit d9b9cc4

Browse files
committed
docs: improve jsdoc statements
1 parent f35a9a5 commit d9b9cc4

22 files changed

+248
-84
lines changed

Diff for: .eslintrc.json

+12-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"eslint:recommended",
99
"plugin:eslint-plugin/recommended",
1010
"plugin:n/recommended",
11-
"plugin:prettier/recommended"
11+
"plugin:prettier/recommended",
12+
"plugin:jsdoc/recommended"
1213
],
1314
"rules": {
1415
"no-var": "error",
@@ -22,6 +23,15 @@
2223
],
2324
"eslint-plugin/prefer-placeholders": "error",
2425
"eslint-plugin/test-case-shorthand-strings": "error",
25-
"prettier/prettier": "error"
26+
"prettier/prettier": "error",
27+
"jsdoc/check-types": "off",
28+
"jsdoc/no-undefined-types": "off",
29+
"jsdoc/require-jsdoc": "off",
30+
"jsdoc/require-param-description": "off",
31+
"jsdoc/require-property-description": "off",
32+
"jsdoc/require-returns-description": "off",
33+
"jsdoc/require-yields": "off",
34+
"jsdoc/tag-lines": ["warn", "never", { "startLines": 1 }],
35+
"jsdoc/valid-types": "off"
2636
}
2737
}

Diff for: __tests__/rule-tester.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @fileoverview Helpers for tests.
2+
* @file Helpers for tests.
33
* @author 唯然<[email protected]>
44
*/
55
'use strict'

Diff for: package-lock.json

+137-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
},
7777
"devDependencies": {
7878
"@types/eslint": "^9.6.0",
79+
"@types/estree": "^1.0.5",
7980
"@types/node": "^18.19.42",
8081
"@typescript-eslint/parser": "^7.17.0",
8182
"doctoc": "^2.2.1",
@@ -84,6 +85,7 @@
8485
"eslint-doc-generator": "^1.7.1",
8586
"eslint-plugin-eslint-plugin": "^6.2.0",
8687
"eslint-plugin-jest": "^28.6.0",
88+
"eslint-plugin-jsdoc": "^48.8.3",
8789
"eslint-plugin-n": "^17.9.0",
8890
"eslint-plugin-prettier": "^5.2.1",
8991
"globals": "^15.8.0",

Diff for: rules/always-return.js

+30-22
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ const getDocsUrl = require('./lib/get-docs-url')
1515
* @typedef { (FunctionExpression | ArrowFunctionExpression) & { parent: CallExpression }} InlineThenFunctionExpression
1616
*/
1717

18-
/** @param {Node} node */
18+
/**
19+
* @param {Node} node
20+
* @returns {boolean}
21+
*/
1922
function isFunctionWithBlockStatement(node) {
2023
if (node.type === 'FunctionExpression') {
2124
return true
@@ -41,7 +44,10 @@ function isMemberCall(memberName, node) {
4144
)
4245
}
4346

44-
/** @param {Node} node */
47+
/**
48+
* @param {Node} node
49+
* @returns {boolean}
50+
*/
4551
function isFirstArgument(node) {
4652
return Boolean(
4753
node.parent && node.parent.arguments && node.parent.arguments[0] === node,
@@ -62,7 +68,9 @@ function isInlineThenFunctionExpression(node) {
6268

6369
/**
6470
* Checks whether the given node is the last `then()` callback in a promise chain.
71+
*
6572
* @param {InlineThenFunctionExpression} node
73+
* @returns {boolean}
6674
*/
6775
function isLastCallback(node) {
6876
/** @type {Node} */
@@ -124,7 +132,7 @@ function peek(arr) {
124132
return arr[arr.length - 1]
125133
}
126134

127-
module.exports = {
135+
module.exports = /** @satisfies {import('eslint').Rule.RuleModule} */ ({
128136
meta: {
129137
type: 'problem',
130138
docs: {
@@ -156,7 +164,6 @@ module.exports = {
156164
* executing branches ("codePathSegment"s) within the given function
157165
* @property {Record<string, BranchInfo | undefined>} branchInfoMap This is an object representing information
158166
* about all branches within the given function
159-
*
160167
* @typedef {object} BranchInfo
161168
* @property {boolean} good This is a boolean representing whether
162169
* the given branch explicitly `return`s or `throw`s. It starts as `false`
@@ -168,24 +175,25 @@ module.exports = {
168175

169176
/**
170177
* funcInfoStack is a stack representing the stack of currently executing
171-
* functions
178+
* functions
172179
* example:
173-
* funcInfoStack = [ { branchIDStack: [ 's1_1' ],
174-
* branchInfoMap:
175-
* { s1_1:
176-
* { good: false,
177-
* loc: <loc> } } },
178-
* { branchIDStack: ['s2_1', 's2_4'],
179-
* branchInfoMap:
180-
* { s2_1:
181-
* { good: false,
182-
* loc: <loc> },
183-
* s2_2:
184-
* { good: true,
185-
* loc: <loc> },
186-
* s2_4:
187-
* { good: false,
188-
* loc: <loc> } } } ]
180+
* funcInfoStack = [ { branchIDStack: [ 's1_1' ],
181+
* branchInfoMap:
182+
* { s1_1:
183+
* { good: false,
184+
* loc: <loc> } } },
185+
* { branchIDStack: ['s2_1', 's2_4'],
186+
* branchInfoMap:
187+
* { s2_1:
188+
* { good: false,
189+
* loc: <loc> },
190+
* s2_2:
191+
* { good: true,
192+
* loc: <loc> },
193+
* s2_4:
194+
* { good: false,
195+
* loc: <loc> } } } ]
196+
*
189197
* @type {FuncInfo[]}
190198
*/
191199
const funcInfoStack = []
@@ -257,4 +265,4 @@ module.exports = {
257265
},
258266
}
259267
},
260-
}
268+
})

0 commit comments

Comments
 (0)