Skip to content

Commit 343816e

Browse files
committed
test(require-param): add line numbers
1 parent 4f2ec35 commit 343816e

File tree

3 files changed

+54
-30
lines changed

3 files changed

+54
-30
lines changed

docs/rules/require-param.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,11 +1202,11 @@ function foo({ foo: { bar: { baz } }}) {}
12021202
// Message: Missing JSDoc @param "options.foo.bar.baz" declaration.
12031203

12041204
/**
1205-
* Returns a number.
1206-
* @param {Object} props Props.
1207-
* @param {Object} props.prop Prop.
1208-
* @return {number} A number.
1209-
*/
1205+
* Returns a number.
1206+
* @param {Object} props Props.
1207+
* @param {Object} props.prop Prop.
1208+
* @return {number} A number.
1209+
*/
12101210
export function testFn1 ({ prop = { a: 1, b: 2 } }) {
12111211
}
12121212
// "jsdoc/require-param": ["error"|"warn", {"useDefaultObjectProperties":true}]

test/rules/assertions/requireParam.js

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ export default /** @type {import('../index.js').TestCases} */ ({
287287
`,
288288
errors: [
289289
{
290+
line: 2,
290291
message: 'Missing JSDoc @param "options.foo" declaration.',
291292
},
292293
],
@@ -1780,6 +1781,7 @@ export default /** @type {import('../index.js').TestCases} */ ({
17801781
`,
17811782
errors: [
17821783
{
1784+
line: 2,
17831785
message: 'Missing JSDoc @param "options.foo" declaration.',
17841786
},
17851787
],
@@ -1825,6 +1827,7 @@ export default /** @type {import('../index.js').TestCases} */ ({
18251827
`,
18261828
errors: [
18271829
{
1830+
line: 3,
18281831
message: 'Missing JSDoc @param "options.permissions" declaration.',
18291832
},
18301833
],
@@ -1933,6 +1936,7 @@ export default /** @type {import('../index.js').TestCases} */ ({
19331936
`,
19341937
errors: [
19351938
{
1939+
line: 2,
19361940
message: 'Missing JSDoc @param "cfg.extra" declaration.',
19371941
},
19381942
],
@@ -1966,6 +1970,7 @@ export default /** @type {import('../index.js').TestCases} */ ({
19661970
`,
19671971
errors: [
19681972
{
1973+
line: 2,
19691974
message: 'Missing JSDoc @param "cfg.opts.extra" declaration.',
19701975
},
19711976
],
@@ -2000,6 +2005,7 @@ export default /** @type {import('../index.js').TestCases} */ ({
20002005
`,
20012006
errors: [
20022007
{
2008+
line: 2,
20032009
message: 'Missing JSDoc @param "cfg."1"" declaration.',
20042010
},
20052011
],
@@ -2057,15 +2063,19 @@ export default /** @type {import('../index.js').TestCases} */ ({
20572063
`,
20582064
errors: [
20592065
{
2066+
line: 2,
20602067
message: 'Missing JSDoc @param "bbox.x" declaration.',
20612068
},
20622069
{
2070+
line: 2,
20632071
message: 'Missing JSDoc @param "bbox.y" declaration.',
20642072
},
20652073
{
2074+
line: 2,
20662075
message: 'Missing JSDoc @param "bbox.width" declaration.',
20672076
},
20682077
{
2078+
line: 2,
20692079
message: 'Missing JSDoc @param "bbox.height" declaration.',
20702080
},
20712081
],
@@ -2100,15 +2110,19 @@ export default /** @type {import('../index.js').TestCases} */ ({
21002110
`,
21012111
errors: [
21022112
{
2113+
line: 2,
21032114
message: 'Missing JSDoc @param "bbox.x" declaration.',
21042115
},
21052116
{
2117+
line: 2,
21062118
message: 'Missing JSDoc @param "bbox.y" declaration.',
21072119
},
21082120
{
2121+
line: 2,
21092122
message: 'Missing JSDoc @param "bbox.width" declaration.',
21102123
},
21112124
{
2125+
line: 2,
21122126
message: 'Missing JSDoc @param "bbox.height" declaration.',
21132127
},
21142128
],
@@ -2139,9 +2153,11 @@ export default /** @type {import('../index.js').TestCases} */ ({
21392153
`,
21402154
errors: [
21412155
{
2156+
line: 3,
21422157
message: 'Missing JSDoc @param "fetchOptions.url" declaration.',
21432158
},
21442159
{
2160+
line: 3,
21452161
message: 'Missing JSDoc @param "fetchOptions.options" declaration.',
21462162
},
21472163
],
@@ -2208,6 +2224,7 @@ export default /** @type {import('../index.js').TestCases} */ ({
22082224
`,
22092225
errors: [
22102226
{
2227+
line: 2,
22112228
message: 'Missing JSDoc @param "options.foo.bar" declaration.',
22122229
},
22132230
],
@@ -2232,6 +2249,7 @@ export default /** @type {import('../index.js').TestCases} */ ({
22322249
`,
22332250
errors: [
22342251
{
2252+
line: 2,
22352253
message: 'Missing JSDoc @param "options.foo.bar" declaration.',
22362254
},
22372255
],
@@ -2261,9 +2279,11 @@ export default /** @type {import('../index.js').TestCases} */ ({
22612279
`,
22622280
errors: [
22632281
{
2282+
line: 2,
22642283
message: 'Missing JSDoc @param "options.foo" declaration.',
22652284
},
22662285
{
2286+
line: 2,
22672287
message: 'Missing JSDoc @param "options.foo.bar" declaration.',
22682288
},
22692289
],
@@ -2289,6 +2309,7 @@ export default /** @type {import('../index.js').TestCases} */ ({
22892309
`,
22902310
errors: [
22912311
{
2312+
line: 2,
22922313
message: 'Missing JSDoc @param "options.foo.bar" declaration.',
22932314
},
22942315
],
@@ -2314,6 +2335,7 @@ export default /** @type {import('../index.js').TestCases} */ ({
23142335
`,
23152336
errors: [
23162337
{
2338+
line: 2,
23172339
message: 'Missing JSDoc @param "options.foo.bar.baz" declaration.',
23182340
},
23192341
],
@@ -2331,19 +2353,21 @@ export default /** @type {import('../index.js').TestCases} */ ({
23312353
{
23322354
code: `
23332355
/**
2334-
* Returns a number.
2335-
* @param {Object} props Props.
2336-
* @param {Object} props.prop Prop.
2337-
* @return {number} A number.
2338-
*/
2356+
* Returns a number.
2357+
* @param {Object} props Props.
2358+
* @param {Object} props.prop Prop.
2359+
* @return {number} A number.
2360+
*/
23392361
export function testFn1 ({ prop = { a: 1, b: 2 } }) {
23402362
}
23412363
`,
23422364
errors: [
23432365
{
2366+
line: 2,
23442367
message: 'Missing JSDoc @param "props.prop.a" declaration.',
23452368
},
23462369
{
2370+
line: 2,
23472371
message: 'Missing JSDoc @param "props.prop.b" declaration.',
23482372
},
23492373
],
@@ -2357,13 +2381,13 @@ export default /** @type {import('../index.js').TestCases} */ ({
23572381
],
23582382
output: `
23592383
/**
2360-
* Returns a number.
2361-
* @param {Object} props Props.
2362-
* @param {Object} props.prop Prop.
2363-
* @param props.prop.a
2364-
* @param props.prop.b
2365-
* @return {number} A number.
2366-
*/
2384+
* Returns a number.
2385+
* @param {Object} props Props.
2386+
* @param {Object} props.prop Prop.
2387+
* @param props.prop.a
2388+
* @param props.prop.b
2389+
* @return {number} A number.
2390+
*/
23672391
export function testFn1 ({ prop = { a: 1, b: 2 } }) {
23682392
}
23692393
`,
@@ -2375,12 +2399,15 @@ export default /** @type {import('../index.js').TestCases} */ ({
23752399
`,
23762400
errors: [
23772401
{
2402+
line: 2,
23782403
message: 'Missing JSDoc @param "a" declaration.',
23792404
},
23802405
{
2406+
line: 2,
23812407
message: 'Missing JSDoc @param "b" declaration.',
23822408
},
23832409
{
2410+
line: 2,
23842411
message: 'Missing JSDoc @param "c" declaration.',
23852412
},
23862413
],
@@ -2404,6 +2431,7 @@ export default /** @type {import('../index.js').TestCases} */ ({
24042431
`,
24052432
errors: [
24062433
{
2434+
line: 2,
24072435
message: 'Missing JSDoc @param "baz" declaration.',
24082436
},
24092437
],
@@ -2445,6 +2473,7 @@ export default /** @type {import('../index.js').TestCases} */ ({
24452473
`,
24462474
errors: [
24472475
{
2476+
line: 2,
24482477
message: 'Missing JSDoc @param "verbose" declaration.',
24492478
},
24502479
],
@@ -2492,6 +2521,7 @@ export default /** @type {import('../index.js').TestCases} */ ({
24922521
`,
24932522
errors: [
24942523
{
2524+
line: 6,
24952525
message: 'Missing JSDoc @param "btnState" declaration.',
24962526
},
24972527
],
@@ -2536,9 +2566,11 @@ export default /** @type {import('../index.js').TestCases} */ ({
25362566
`,
25372567
errors: [
25382568
{
2569+
line: 3,
25392570
message: 'Missing JSDoc @param "root1" declaration.',
25402571
},
25412572
{
2573+
line: 3,
25422574
message: 'Missing JSDoc @param "root1.bar" declaration.',
25432575
},
25442576
],
@@ -2566,6 +2598,7 @@ export default /** @type {import('../index.js').TestCases} */ ({
25662598
`,
25672599
errors: [
25682600
{
2601+
line: 2,
25692602
message: 'Missing JSDoc @param "b" declaration.',
25702603
},
25712604
],
@@ -2592,6 +2625,7 @@ export default /** @type {import('../index.js').TestCases} */ ({
25922625
`,
25932626
errors: [
25942627
{
2628+
line: 2,
25952629
message: 'Missing JSDoc @param "foo" declaration.',
25962630
},
25972631
],

test/rules/index.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,10 @@ export const runRuleTests = ({
8383
return assertion;
8484
});
8585
if (count) {
86-
// Make an exception for now for `require-param` as it helps to find the
87-
// many lines were it is missing to know which tests to check without
88-
// adding false (or failing) expectations now
89-
if (ruleName === 'require-param') {
90-
// eslint-disable-next-line no-console -- CLI
91-
console.log(
92-
`Rule, \`${ruleName}\`, missing line numbers in errors: ${count}`,
93-
);
94-
} else {
95-
// eslint-disable-next-line no-console -- CLI
96-
console.error(`Rule, \`${ruleName}\`, missing line numbers in errors: ${count}`);
86+
// eslint-disable-next-line no-console -- CLI
87+
console.error(`Rule, \`${ruleName}\`, missing line numbers in errors: ${count}`);
9788

98-
return;
99-
}
89+
return;
10090
}
10191

10292
assertions.valid = assertions.valid.map((assertion) => {

0 commit comments

Comments
 (0)