Skip to content

chore: replace invalid int type with number inside JSDocs. #19597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Makefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1056,16 +1056,16 @@ module.exports = [{

/**
* @callback TimeCallback
* @param {?int[]} results
* @param {number[] | null} results
* @returns {void}
*/

/**
* Calculates the time for each run for performance
* @param {string} cmd cmd
* @param {int} runs Total number of runs to do
* @param {int} runNumber Current run number
* @param {int[]} results Collection results from each run
* @param {number} runs Total number of runs to do
* @param {number} runNumber Current run number
* @param {number[]} results Collection results from each run
* @param {TimeCallback} cb Function to call when everything is done
* @returns {void} calls the cb with all the results
* @private
Expand Down
10 changes: 5 additions & 5 deletions docs/src/rules/require-jsdoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ This rule was removed in ESLint v9.0.0 and replaced by the [`eslint-plugin-jsdoc
```js
/**
* Adds two numbers together.
* @param {int} num1 The first number.
* @param {int} num2 The second number.
* @returns {int} The sum of the two numbers.
* @param {number} num1 The first number.
* @param {number} num2 The second number.
* @returns {number} The sum of the two numbers.
*/
function sum(num1, num2) {
return num1 + num2;
Expand Down Expand Up @@ -129,8 +129,8 @@ function foo() {

/**
* It returns test + 10
* @params {int} test - some number
* @returns {int} sum of test and 10
* @params {number} test - some number
* @returns {number} sum of test and 10
*/
var bar = (test) => {
return test + 10;
Expand Down
12 changes: 6 additions & 6 deletions docs/src/rules/valid-jsdoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ Examples of additional **incorrect** code for this rule with sample `"prefer": {

/**
* Add two numbers.
* @arg {int} num1 The first number.
* @arg {int} num2 The second number.
* @return {int} The sum of the two numbers.
* @arg {number} num1 The first number.
* @arg {number} num2 The second number.
* @return {number} The sum of the two numbers.
*/
function add(num1, num2) {
return num1 + num2;
Expand Down Expand Up @@ -397,9 +397,9 @@ Example of additional **correct** code for this rule with the `"requireParamDesc

/**
* Add two numbers.
* @param {int} num1
* @param {int} num2
* @returns {int} The sum of the two numbers.
* @param {number} num1
* @param {number} num2
* @returns {number} The sum of the two numbers.
*/
function add(num1, num2) {
return num1 + num2;
Expand Down
6 changes: 3 additions & 3 deletions lib/cli-engine/formatters/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function pageTemplate(it) {
/**
* Given a word and a count, append an s if count is not one.
* @param {string} word A word in its singular form.
* @param {int} count A number controlling whether word should be pluralized.
* @param {number} count A number controlling whether word should be pluralized.
* @returns {string} The original word with an s on the end if count is not one.
*/
function pluralize(word, count) {
Expand All @@ -209,7 +209,7 @@ function renderSummary(totalErrors, totalWarnings) {
* Get the color based on whether there are errors/warnings...
* @param {string} totalErrors Total errors
* @param {string} totalWarnings Total warnings
* @returns {int} The color code (0 = green, 1 = yellow, 2 = red)
* @returns {number} The color code (0 = green, 1 = yellow, 2 = red)
*/
function renderColor(totalErrors, totalWarnings) {
if (totalErrors !== 0) {
Expand Down Expand Up @@ -253,7 +253,7 @@ function messageTemplate(it) {
/**
* Get HTML (table rows) describing the messages.
* @param {Array} messages Messages.
* @param {int} parentIndex Index of the parent HTML row.
* @param {number} parentIndex Index of the parent HTML row.
* @param {Object} rulesMeta Dictionary containing metadata for each rule executed by the analysis.
* @returns {string} HTML (table rows) describing the messages.
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/cli-engine/formatters/stylish.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const chalk = require("chalk"),
/**
* Given a word and a count, append an s if count is not one.
* @param {string} word A word in its singular form.
* @param {int} count A number controlling whether word should be pluralized.
* @param {number} count A number controlling whether word should be pluralized.
* @returns {string} The original word with an s on the end if count is not one.
*/
function pluralize(word, count) {
Expand Down
6 changes: 3 additions & 3 deletions lib/languages/js/source-code/source-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,8 @@ class SourceCode extends TokenStore {
/**
* Gets the source code for the given node.
* @param {ASTNode} [node] The AST node to get the text for.
* @param {int} [beforeCount] The number of characters before the node to retrieve.
* @param {int} [afterCount] The number of characters after the node to retrieve.
* @param {number} [beforeCount] The number of characters before the node to retrieve.
* @param {number} [afterCount] The number of characters after the node to retrieve.
* @returns {string} The text representing the AST node.
* @public
*/
Expand Down Expand Up @@ -627,7 +627,7 @@ class SourceCode extends TokenStore {

/**
* Gets the deepest node containing a range index.
* @param {int} index Range index of the desired node.
* @param {number} index Range index of the desired node.
* @returns {ASTNode} The node if found or null if not found.
* @public
*/
Expand Down
6 changes: 3 additions & 3 deletions lib/languages/js/source-code/token-store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,8 @@ module.exports = class TokenStore {
/**
* Gets all tokens that are related to the given node.
* @param {ASTNode} node The AST node.
* @param {int} [beforeCount=0] The number of tokens before the node to retrieve.
* @param {int} [afterCount=0] The number of tokens after the node to retrieve.
* @param {number} [beforeCount=0] The number of tokens before the node to retrieve.
* @param {number} [afterCount=0] The number of tokens after the node to retrieve.
* @returns {Token[]} Array of objects representing tokens.
*/
getTokens(node, beforeCount, afterCount) {
Expand Down Expand Up @@ -635,7 +635,7 @@ module.exports = class TokenStore {
* Gets all of the tokens between two non-overlapping nodes.
* @param {ASTNode|Token|Comment} left Node before the desired token range.
* @param {ASTNode|Token|Comment} right Node after the desired token range.
* @param {int} [padding=0] Number of extra tokens on either side of center.
* @param {number} [padding=0] Number of extra tokens on either side of center.
* @returns {Token[]} Tokens between left and right.
*/
getTokensBetween(left, right, padding) {
Expand Down
2 changes: 1 addition & 1 deletion lib/linter/report-translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function assertValidFix(fix) {
* Compares items in a fixes array by range.
* @param {Fix} a The first message.
* @param {Fix} b The second message.
* @returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
* @returns {number} -1 if a comes before b, 1 if a comes after b, 0 if equal.
* @private
*/
function compareFixesByRange(a, b) {
Expand Down
18 changes: 13 additions & 5 deletions lib/linter/rule-fixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
*/
"use strict";

//------------------------------------------------------------------------------
// Typedefs
//------------------------------------------------------------------------------

/**
* @import { SourceRange } from "@eslint/core";
*/

/* eslint class-methods-use-this: off -- Methods desired on instance */

//------------------------------------------------------------------------------
Expand All @@ -18,7 +26,7 @@

/**
* Creates a fix command that inserts text at the specified index in the source text.
* @param {int} index The 0-based index at which to insert the new text.
* @param {number} index The 0-based index at which to insert the new text.
* @param {string} text The text to insert.
* @returns {Object} The fix command.
* @private
Expand Down Expand Up @@ -69,7 +77,7 @@ class RuleFixer {
/**
* Creates a fix command that inserts text after the specified range in the source text.
* The fix is not applied until applyFixes() is called.
* @param {int[]} range The range to replace, first item is start of range, second
* @param {SourceRange} range The range to replace, first item is start of range, second
* is end of range.
* @param {string} text The text to insert.
* @returns {Object} The fix command.
Expand All @@ -94,7 +102,7 @@ class RuleFixer {
/**
* Creates a fix command that inserts text before the specified range in the source text.
* The fix is not applied until applyFixes() is called.
* @param {int[]} range The range to replace, first item is start of range, second
* @param {SourceRange} range The range to replace, first item is start of range, second
* is end of range.
* @param {string} text The text to insert.
* @returns {Object} The fix command.
Expand All @@ -119,7 +127,7 @@ class RuleFixer {
/**
* Creates a fix command that replaces text at the specified range in the source text.
* The fix is not applied until applyFixes() is called.
* @param {int[]} range The range to replace, first item is start of range, second
* @param {SourceRange} range The range to replace, first item is start of range, second
* is end of range.
* @param {string} text The text to insert.
* @returns {Object} The fix command.
Expand All @@ -146,7 +154,7 @@ class RuleFixer {
/**
* Creates a fix command that removes the specified range of text from the source.
* The fix is not applied until applyFixes() is called.
* @param {int[]} range The range to remove, first item is start of range, second
* @param {SourceRange} range The range to remove, first item is start of range, second
* is end of range.
* @returns {Object} The fix command.
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/linter/source-code-fixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const BOM = "\uFEFF";
* Compares items in a messages array by range.
* @param {Message} a The first message.
* @param {Message} b The second message.
* @returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
* @returns {number} -1 if a comes before b, 1 if a comes after b, 0 if equal.
* @private
*/
function compareMessagesByFixRange(a, b) {
Expand All @@ -31,7 +31,7 @@ function compareMessagesByFixRange(a, b) {
* Compares items in a messages array by line and column.
* @param {Message} a The first message.
* @param {Message} b The second message.
* @returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
* @returns {number} -1 if a comes before b, 1 if a comes after b, 0 if equal.
* @private
*/
function compareMessagesByLocation(a, b) {
Expand Down
4 changes: 2 additions & 2 deletions lib/linter/timing.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const { startTime, endTime } = require("../shared/stats");
/**
* Align the string to left
* @param {string} str string to evaluate
* @param {int} len length of the string
* @param {number} len length of the string
* @param {string} ch delimiter character
* @returns {string} modified string
* @private
Expand All @@ -28,7 +28,7 @@ function alignLeft(str, len, ch) {
/**
* Align the string to right
* @param {string} str string to evaluate
* @param {int} len length of the string
* @param {number} len length of the string
* @param {string} ch delimiter character
* @returns {string} modified string
* @private
Expand Down
8 changes: 4 additions & 4 deletions lib/rules/for-direction.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ module.exports = {
/**
* check the right side of the assignment
* @param {ASTNode} update UpdateExpression to check
* @param {int} dir expected direction that could either be turned around or invalidated
* @returns {int} return dir, the negated dir, or zero if the counter does not change or the direction is not clear
* @param {number} dir expected direction that could either be turned around or invalidated
* @returns {number} return dir, the negated dir, or zero if the counter does not change or the direction is not clear
*/
function getRightDirection(update, dir) {
const staticValue = getStaticValue(
Expand All @@ -80,7 +80,7 @@ module.exports = {
* check UpdateExpression add/sub the counter
* @param {ASTNode} update UpdateExpression to check
* @param {string} counter variable name to check
* @returns {int} if add return 1, if sub return -1, if nochange, return 0
* @returns {number} if add return 1, if sub return -1, if nochange, return 0
*/
function getUpdateDirection(update, counter) {
if (
Expand All @@ -101,7 +101,7 @@ module.exports = {
* check AssignmentExpression add/sub the counter
* @param {ASTNode} update AssignmentExpression to check
* @param {string} counter variable name to check
* @returns {int} if add return 1, if sub return -1, if nochange, return 0
* @returns {number} if add return 1, if sub return -1, if nochange, return 0
*/
function getAssignmentDirection(update, counter) {
if (update.left.name === counter) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/func-name-matching.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function isModuleExports(pattern) {
/**
* Determines if a string name is a valid identifier
* @param {string} name The string to be checked
* @param {int} ecmaVersion The ECMAScript version if specified in the parserOptions config
* @param {number} ecmaVersion The ECMAScript version if specified in the parserOptions config
* @returns {boolean} True if the string is a valid identifier
*/
function isIdentifier(name, ecmaVersion) {
Expand Down
26 changes: 13 additions & 13 deletions lib/rules/indent-legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ module.exports = {

/**
* Creates an error message for a line, given the expected/actual indentation.
* @param {int} expectedAmount The expected amount of indentation characters for this line
* @param {int} actualSpaces The actual number of indentation spaces that were found on this line
* @param {int} actualTabs The actual number of indentation tabs that were found on this line
* @param {number} expectedAmount The expected amount of indentation characters for this line
* @param {number} actualSpaces The actual number of indentation spaces that were found on this line
* @param {number} actualTabs The actual number of indentation tabs that were found on this line
* @returns {string} An error message for this line
*/
function createErrorMessageData(
Expand Down Expand Up @@ -345,9 +345,9 @@ module.exports = {
/**
* Reports a given indent violation
* @param {ASTNode} node Node violating the indent rule
* @param {int} needed Expected indentation character count
* @param {int} gottenSpaces Indentation space count in the actual node/code
* @param {int} gottenTabs Indentation tab count in the actual node/code
* @param {number} needed Expected indentation character count
* @param {number} gottenSpaces Indentation space count in the actual node/code
* @param {number} gottenTabs Indentation tab count in the actual node/code
* @param {Object} [loc] Error line and column location
* @param {boolean} isLastNodeCheck Is the error for last node check
* @returns {void}
Expand Down Expand Up @@ -449,7 +449,7 @@ module.exports = {
/**
* Check indent for node
* @param {ASTNode} node Node to check
* @param {int} neededIndent needed indent
* @param {number} neededIndent needed indent
* @returns {void}
*/
function checkNodeIndent(node, neededIndent) {
Expand Down Expand Up @@ -502,7 +502,7 @@ module.exports = {
/**
* Check indent for nodes list
* @param {ASTNode[]} nodes list of node objects
* @param {int} indent needed indent
* @param {number} indent needed indent
* @returns {void}
*/
function checkNodesIndent(nodes, indent) {
Expand All @@ -512,7 +512,7 @@ module.exports = {
/**
* Check last node line indent this detects, that block closed correctly
* @param {ASTNode} node Node to examine
* @param {int} lastLineIndent needed indent
* @param {number} lastLineIndent needed indent
* @returns {void}
*/
function checkLastNodeLineIndent(node, lastLineIndent) {
Expand Down Expand Up @@ -542,7 +542,7 @@ module.exports = {
* Check last node line indent this detects, that block closed correctly
* This function for more complicated return statement case, where closing parenthesis may be followed by ';'
* @param {ASTNode} node Node to examine
* @param {int} firstLineIndent first line needed indent
* @param {number} firstLineIndent first line needed indent
* @returns {void}
*/
function checkLastReturnStatementLineIndent(node, firstLineIndent) {
Expand Down Expand Up @@ -583,7 +583,7 @@ module.exports = {
/**
* Check first node line indent is correct
* @param {ASTNode} node Node to examine
* @param {int} firstLineIndent needed indent
* @param {number} firstLineIndent needed indent
* @returns {void}
*/
function checkFirstNodeLineIndent(node, firstLineIndent) {
Expand Down Expand Up @@ -1130,8 +1130,8 @@ module.exports = {
/**
* Returns the expected indentation for the case statement
* @param {ASTNode} node node to examine
* @param {int} [providedSwitchIndent] indent for switch statement
* @returns {int} indent size
* @param {number} [providedSwitchIndent] indent for switch statement
* @returns {number} indent size
*/
function expectedCaseIndent(node, providedSwitchIndent) {
const switchNode =
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,9 +743,9 @@ module.exports = {

/**
* Creates an error message for a line, given the expected/actual indentation.
* @param {int} expectedAmount The expected amount of indentation characters for this line
* @param {int} actualSpaces The actual number of indentation spaces that were found on this line
* @param {int} actualTabs The actual number of indentation tabs that were found on this line
* @param {number} expectedAmount The expected amount of indentation characters for this line
* @param {number} actualSpaces The actual number of indentation spaces that were found on this line
* @param {number} actualTabs The actual number of indentation tabs that were found on this line
* @returns {string} An error message for this line
*/
function createErrorMessageData(
Expand Down
Loading
Loading