Skip to content

Commit

Permalink
refactor: improve jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Aug 20, 2024
1 parent 4351985 commit 6984803
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions rules/consistent-indexof-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ function isIndexOfCallExpression(node) {
}

/**
* Determine the appropriate replacement based on the operator and value.
*/
Determine the appropriate replacement based on the operator and value.
@param {string} operator
@param {number} value
@param {string} variableName
@returns {string | undefined}
*/
function getReplacement(operator, value, variableName) {
if ((operator === '<' && value <= 0) || (operator === '<=' && value <= -1)) {
return `${variableName} === -1`;
Expand All @@ -43,8 +48,11 @@ function getReplacement(operator, value, variableName) {
}

/**
* Check if the node is a number literal or a unary expression resolving to a number.
*/
Check if the node is a number literal or a unary expression resolving to a number.
@param {import('estree').Node} node

Check failure on line 53 in rules/consistent-indexof-check.js

View workflow job for this annotation

GitHub Actions / lint-test (ubuntu-latest)

Trailing spaces not allowed.
@returns {node is import('estree').Literal}
*/
function isNumberLiteral(node) {
if (node.type === 'UnaryExpression' && ['-', '+', '~'].includes(node.operator)) {
return isNumberLiteral(node.argument);
Expand Down

0 comments on commit 6984803

Please sign in to comment.