Skip to content

Commit

Permalink
docs: improve jsdoc statements
Browse files Browse the repository at this point in the history
  • Loading branch information
voxpelli committed Jul 24, 2024
1 parent f35a9a5 commit d9b9cc4
Show file tree
Hide file tree
Showing 22 changed files with 248 additions and 84 deletions.
14 changes: 12 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"eslint:recommended",
"plugin:eslint-plugin/recommended",
"plugin:n/recommended",
"plugin:prettier/recommended"
"plugin:prettier/recommended",
"plugin:jsdoc/recommended"
],
"rules": {
"no-var": "error",
Expand All @@ -22,6 +23,15 @@
],
"eslint-plugin/prefer-placeholders": "error",
"eslint-plugin/test-case-shorthand-strings": "error",
"prettier/prettier": "error"
"prettier/prettier": "error",
"jsdoc/check-types": "off",
"jsdoc/no-undefined-types": "off",
"jsdoc/require-jsdoc": "off",
"jsdoc/require-param-description": "off",
"jsdoc/require-property-description": "off",
"jsdoc/require-returns-description": "off",
"jsdoc/require-yields": "off",
"jsdoc/tag-lines": ["warn", "never", { "startLines": 1 }],
"jsdoc/valid-types": "off"
}
}
2 changes: 1 addition & 1 deletion __tests__/rule-tester.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @fileoverview Helpers for tests.
* @file Helpers for tests.
* @author 唯然<[email protected]>
*/
'use strict'
Expand Down
146 changes: 137 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
},
"devDependencies": {
"@types/eslint": "^9.6.0",
"@types/estree": "^1.0.5",
"@types/node": "^18.19.42",
"@typescript-eslint/parser": "^7.17.0",
"doctoc": "^2.2.1",
Expand All @@ -84,6 +85,7 @@
"eslint-doc-generator": "^1.7.1",
"eslint-plugin-eslint-plugin": "^6.2.0",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-jsdoc": "^48.8.3",
"eslint-plugin-n": "^17.9.0",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.8.0",
Expand Down
52 changes: 30 additions & 22 deletions rules/always-return.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ const getDocsUrl = require('./lib/get-docs-url')
* @typedef { (FunctionExpression | ArrowFunctionExpression) & { parent: CallExpression }} InlineThenFunctionExpression
*/

/** @param {Node} node */
/**
* @param {Node} node
* @returns {boolean}
*/
function isFunctionWithBlockStatement(node) {
if (node.type === 'FunctionExpression') {
return true
Expand All @@ -41,7 +44,10 @@ function isMemberCall(memberName, node) {
)
}

/** @param {Node} node */
/**
* @param {Node} node
* @returns {boolean}
*/
function isFirstArgument(node) {
return Boolean(
node.parent && node.parent.arguments && node.parent.arguments[0] === node,
Expand All @@ -62,7 +68,9 @@ function isInlineThenFunctionExpression(node) {

/**
* Checks whether the given node is the last `then()` callback in a promise chain.
*
* @param {InlineThenFunctionExpression} node
* @returns {boolean}
*/
function isLastCallback(node) {
/** @type {Node} */
Expand Down Expand Up @@ -124,7 +132,7 @@ function peek(arr) {
return arr[arr.length - 1]
}

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

/**
* funcInfoStack is a stack representing the stack of currently executing
* functions
* functions
* example:
* funcInfoStack = [ { branchIDStack: [ 's1_1' ],
* branchInfoMap:
* { s1_1:
* { good: false,
* loc: <loc> } } },
* { branchIDStack: ['s2_1', 's2_4'],
* branchInfoMap:
* { s2_1:
* { good: false,
* loc: <loc> },
* s2_2:
* { good: true,
* loc: <loc> },
* s2_4:
* { good: false,
* loc: <loc> } } } ]
* funcInfoStack = [ { branchIDStack: [ 's1_1' ],
* branchInfoMap:
* { s1_1:
* { good: false,
* loc: <loc> } } },
* { branchIDStack: ['s2_1', 's2_4'],
* branchInfoMap:
* { s2_1:
* { good: false,
* loc: <loc> },
* s2_2:
* { good: true,
* loc: <loc> },
* s2_4:
* { good: false,
* loc: <loc> } } } ]
*
* @type {FuncInfo[]}
*/
const funcInfoStack = []
Expand Down Expand Up @@ -257,4 +265,4 @@ module.exports = {
},
}
},
}
})
Loading

0 comments on commit d9b9cc4

Please sign in to comment.