Skip to content

Commit 22ea18b

Browse files
authored
chore: replace invalid int type with number inside JSDocs. (#19597)
* chore: replace invalid `int` type with `number` inside JSDocs. * Change implicit nullable type `{?number[]}` to `{number[] | null}` * Change `number` to `SourceRange`
1 parent 865aed6 commit 22ea18b

34 files changed

Lines changed: 129 additions & 89 deletions

Makefile.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,16 +1056,16 @@ module.exports = [{
10561056

10571057
/**
10581058
* @callback TimeCallback
1059-
* @param {?int[]} results
1059+
* @param {number[] | null} results
10601060
* @returns {void}
10611061
*/
10621062

10631063
/**
10641064
* Calculates the time for each run for performance
10651065
* @param {string} cmd cmd
1066-
* @param {int} runs Total number of runs to do
1067-
* @param {int} runNumber Current run number
1068-
* @param {int[]} results Collection results from each run
1066+
* @param {number} runs Total number of runs to do
1067+
* @param {number} runNumber Current run number
1068+
* @param {number[]} results Collection results from each run
10691069
* @param {TimeCallback} cb Function to call when everything is done
10701070
* @returns {void} calls the cb with all the results
10711071
* @private

docs/src/rules/require-jsdoc.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ This rule was removed in ESLint v9.0.0 and replaced by the [`eslint-plugin-jsdoc
1414
```js
1515
/**
1616
* Adds two numbers together.
17-
* @param {int} num1 The first number.
18-
* @param {int} num2 The second number.
19-
* @returns {int} The sum of the two numbers.
17+
* @param {number} num1 The first number.
18+
* @param {number} num2 The second number.
19+
* @returns {number} The sum of the two numbers.
2020
*/
2121
function sum(num1, num2) {
2222
return num1 + num2;
@@ -129,8 +129,8 @@ function foo() {
129129

130130
/**
131131
* It returns test + 10
132-
* @params {int} test - some number
133-
* @returns {int} sum of test and 10
132+
* @params {number} test - some number
133+
* @returns {number} sum of test and 10
134134
*/
135135
var bar = (test) => {
136136
return test + 10;

docs/src/rules/valid-jsdoc.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ Examples of additional **incorrect** code for this rule with sample `"prefer": {
194194

195195
/**
196196
* Add two numbers.
197-
* @arg {int} num1 The first number.
198-
* @arg {int} num2 The second number.
199-
* @return {int} The sum of the two numbers.
197+
* @arg {number} num1 The first number.
198+
* @arg {number} num2 The second number.
199+
* @return {number} The sum of the two numbers.
200200
*/
201201
function add(num1, num2) {
202202
return num1 + num2;
@@ -397,9 +397,9 @@ Example of additional **correct** code for this rule with the `"requireParamDesc
397397

398398
/**
399399
* Add two numbers.
400-
* @param {int} num1
401-
* @param {int} num2
402-
* @returns {int} The sum of the two numbers.
400+
* @param {number} num1
401+
* @param {number} num2
402+
* @returns {number} The sum of the two numbers.
403403
*/
404404
function add(num1, num2) {
405405
return num1 + num2;

lib/cli-engine/formatters/html.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ function pageTemplate(it) {
182182
/**
183183
* Given a word and a count, append an s if count is not one.
184184
* @param {string} word A word in its singular form.
185-
* @param {int} count A number controlling whether word should be pluralized.
185+
* @param {number} count A number controlling whether word should be pluralized.
186186
* @returns {string} The original word with an s on the end if count is not one.
187187
*/
188188
function pluralize(word, count) {
@@ -209,7 +209,7 @@ function renderSummary(totalErrors, totalWarnings) {
209209
* Get the color based on whether there are errors/warnings...
210210
* @param {string} totalErrors Total errors
211211
* @param {string} totalWarnings Total warnings
212-
* @returns {int} The color code (0 = green, 1 = yellow, 2 = red)
212+
* @returns {number} The color code (0 = green, 1 = yellow, 2 = red)
213213
*/
214214
function renderColor(totalErrors, totalWarnings) {
215215
if (totalErrors !== 0) {
@@ -253,7 +253,7 @@ function messageTemplate(it) {
253253
/**
254254
* Get HTML (table rows) describing the messages.
255255
* @param {Array} messages Messages.
256-
* @param {int} parentIndex Index of the parent HTML row.
256+
* @param {number} parentIndex Index of the parent HTML row.
257257
* @param {Object} rulesMeta Dictionary containing metadata for each rule executed by the analysis.
258258
* @returns {string} HTML (table rows) describing the messages.
259259
*/

lib/cli-engine/formatters/stylish.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const chalk = require("chalk"),
1515
/**
1616
* Given a word and a count, append an s if count is not one.
1717
* @param {string} word A word in its singular form.
18-
* @param {int} count A number controlling whether word should be pluralized.
18+
* @param {number} count A number controlling whether word should be pluralized.
1919
* @returns {string} The original word with an s on the end if count is not one.
2020
*/
2121
function pluralize(word, count) {

lib/languages/js/source-code/source-code.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,8 @@ class SourceCode extends TokenStore {
511511
/**
512512
* Gets the source code for the given node.
513513
* @param {ASTNode} [node] The AST node to get the text for.
514-
* @param {int} [beforeCount] The number of characters before the node to retrieve.
515-
* @param {int} [afterCount] The number of characters after the node to retrieve.
514+
* @param {number} [beforeCount] The number of characters before the node to retrieve.
515+
* @param {number} [afterCount] The number of characters after the node to retrieve.
516516
* @returns {string} The text representing the AST node.
517517
* @public
518518
*/
@@ -627,7 +627,7 @@ class SourceCode extends TokenStore {
627627

628628
/**
629629
* Gets the deepest node containing a range index.
630-
* @param {int} index Range index of the desired node.
630+
* @param {number} index Range index of the desired node.
631631
* @returns {ASTNode} The node if found or null if not found.
632632
* @public
633633
*/

lib/languages/js/source-code/token-store/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,8 @@ module.exports = class TokenStore {
605605
/**
606606
* Gets all tokens that are related to the given node.
607607
* @param {ASTNode} node The AST node.
608-
* @param {int} [beforeCount=0] The number of tokens before the node to retrieve.
609-
* @param {int} [afterCount=0] The number of tokens after the node to retrieve.
608+
* @param {number} [beforeCount=0] The number of tokens before the node to retrieve.
609+
* @param {number} [afterCount=0] The number of tokens after the node to retrieve.
610610
* @returns {Token[]} Array of objects representing tokens.
611611
*/
612612
getTokens(node, beforeCount, afterCount) {
@@ -635,7 +635,7 @@ module.exports = class TokenStore {
635635
* Gets all of the tokens between two non-overlapping nodes.
636636
* @param {ASTNode|Token|Comment} left Node before the desired token range.
637637
* @param {ASTNode|Token|Comment} right Node after the desired token range.
638-
* @param {int} [padding=0] Number of extra tokens on either side of center.
638+
* @param {number} [padding=0] Number of extra tokens on either side of center.
639639
* @returns {Token[]} Tokens between left and right.
640640
*/
641641
getTokensBetween(left, right, padding) {

lib/linter/report-translator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function assertValidFix(fix) {
133133
* Compares items in a fixes array by range.
134134
* @param {Fix} a The first message.
135135
* @param {Fix} b The second message.
136-
* @returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
136+
* @returns {number} -1 if a comes before b, 1 if a comes after b, 0 if equal.
137137
* @private
138138
*/
139139
function compareFixesByRange(a, b) {

lib/linter/rule-fixer.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
*/
55
"use strict";
66

7+
//------------------------------------------------------------------------------
8+
// Typedefs
9+
//------------------------------------------------------------------------------
10+
11+
/**
12+
* @import { SourceRange } from "@eslint/core";
13+
*/
14+
715
/* eslint class-methods-use-this: off -- Methods desired on instance */
816

917
//------------------------------------------------------------------------------
@@ -18,7 +26,7 @@
1826

1927
/**
2028
* Creates a fix command that inserts text at the specified index in the source text.
21-
* @param {int} index The 0-based index at which to insert the new text.
29+
* @param {number} index The 0-based index at which to insert the new text.
2230
* @param {string} text The text to insert.
2331
* @returns {Object} The fix command.
2432
* @private
@@ -69,7 +77,7 @@ class RuleFixer {
6977
/**
7078
* Creates a fix command that inserts text after the specified range in the source text.
7179
* The fix is not applied until applyFixes() is called.
72-
* @param {int[]} range The range to replace, first item is start of range, second
80+
* @param {SourceRange} range The range to replace, first item is start of range, second
7381
* is end of range.
7482
* @param {string} text The text to insert.
7583
* @returns {Object} The fix command.
@@ -94,7 +102,7 @@ class RuleFixer {
94102
/**
95103
* Creates a fix command that inserts text before the specified range in the source text.
96104
* The fix is not applied until applyFixes() is called.
97-
* @param {int[]} range The range to replace, first item is start of range, second
105+
* @param {SourceRange} range The range to replace, first item is start of range, second
98106
* is end of range.
99107
* @param {string} text The text to insert.
100108
* @returns {Object} The fix command.
@@ -119,7 +127,7 @@ class RuleFixer {
119127
/**
120128
* Creates a fix command that replaces text at the specified range in the source text.
121129
* The fix is not applied until applyFixes() is called.
122-
* @param {int[]} range The range to replace, first item is start of range, second
130+
* @param {SourceRange} range The range to replace, first item is start of range, second
123131
* is end of range.
124132
* @param {string} text The text to insert.
125133
* @returns {Object} The fix command.
@@ -146,7 +154,7 @@ class RuleFixer {
146154
/**
147155
* Creates a fix command that removes the specified range of text from the source.
148156
* The fix is not applied until applyFixes() is called.
149-
* @param {int[]} range The range to remove, first item is start of range, second
157+
* @param {SourceRange} range The range to remove, first item is start of range, second
150158
* is end of range.
151159
* @returns {Object} The fix command.
152160
*/

lib/linter/source-code-fixer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const BOM = "\uFEFF";
2020
* Compares items in a messages array by range.
2121
* @param {Message} a The first message.
2222
* @param {Message} b The second message.
23-
* @returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
23+
* @returns {number} -1 if a comes before b, 1 if a comes after b, 0 if equal.
2424
* @private
2525
*/
2626
function compareMessagesByFixRange(a, b) {
@@ -31,7 +31,7 @@ function compareMessagesByFixRange(a, b) {
3131
* Compares items in a messages array by line and column.
3232
* @param {Message} a The first message.
3333
* @param {Message} b The second message.
34-
* @returns {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
34+
* @returns {number} -1 if a comes before b, 1 if a comes after b, 0 if equal.
3535
* @private
3636
*/
3737
function compareMessagesByLocation(a, b) {

0 commit comments

Comments
 (0)