Skip to content

Commit ef11562

Browse files
authored
Merge pull request #344 from yeonjuan/master
docs: fix alignment in tests and ensure generated output shows alignment examples correctly
2 parents d33e11c + f3a0f2f commit ef11562

File tree

5 files changed

+82
-82
lines changed

5 files changed

+82
-82
lines changed

README.md

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -405,16 +405,16 @@ function quux (foo) {
405405
// Message: Expected JSDoc block to be aligned.
406406

407407
/**
408-
* @param {Number} foo
409-
*/
410-
function quux (foo) {
408+
* @param {Number} foo
409+
*/
410+
function quux (foo) {
411411

412-
}
412+
}
413413
// Message: Expected JSDoc block to be aligned.
414414

415415
/**
416-
* A jsdoc not attached to any node.
417-
*/
416+
* A jsdoc not attached to any node.
417+
*/
418418
// Message: Expected JSDoc block to be aligned.
419419

420420
class Foo {
@@ -775,10 +775,10 @@ function f () {
775775
// Message: `settings.jsdoc.captionRequired` has been removed, use options in the rule `check-examples` instead.
776776

777777
/**
778-
* @typedef {string} Foo
779-
* @example <caption></caption>
780-
* 'foo'
781-
*/
778+
* @typedef {string} Foo
779+
* @example <caption></caption>
780+
* 'foo'
781+
*/
782782
// Options: [{"captionRequired":true,"eslintrcForExamples":false}]
783783
// Message: Caption is expected for examples.
784784
````
@@ -3260,19 +3260,19 @@ function quux () {
32603260
// Message: There must be no newline after the description of the JSDoc block.
32613261

32623262
/**
3263-
* A.
3264-
*
3265-
* @typedef {Object} A
3266-
* @prop {boolean} a A.
3267-
*/
3263+
* A.
3264+
*
3265+
* @typedef {Object} A
3266+
* @prop {boolean} a A.
3267+
*/
32683268
// Options: ["never"]
32693269
// Message: There must be no newline after the description of the JSDoc block.
32703270

32713271
/**
3272-
* A.
3273-
* @typedef {Object} A
3274-
* @prop {boolean} a A.
3275-
*/
3272+
* A.
3273+
* @typedef {Object} A
3274+
* @prop {boolean} a A.
3275+
*/
32763276
// Options: ["always"]
32773277
// Message: There must be a newline after the description of the JSDoc block.
32783278
````
@@ -3410,18 +3410,18 @@ An option object may have the following key:
34103410
The following patterns are considered problems:
34113411

34123412
````js
3413-
/**
3414-
* @param {HerType} baz - Foo.
3415-
*/
3413+
/**
3414+
* @param {HerType} baz - Foo.
3415+
*/
34163416
function quux(foo, bar, baz) {
34173417

34183418
}
34193419
// Settings: {"jsdoc":{"preferredTypes":{"HerType":1000}}}
34203420
// Message: Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.
34213421

3422-
/**
3423-
* @param {HerType} baz - Foo.
3424-
*/
3422+
/**
3423+
* @param {HerType} baz - Foo.
3424+
*/
34253425
function quux(foo, bar, baz) {
34263426

34273427
}
@@ -3437,20 +3437,20 @@ function quux(foo) {
34373437
// Message: The type 'strnig' is undefined.
34383438

34393439
/**
3440-
* @param {MyType} foo - Bar.
3441-
* @param {HisType} bar - Foo.
3442-
*/
3440+
* @param {MyType} foo - Bar.
3441+
* @param {HisType} bar - Foo.
3442+
*/
34433443
function quux(foo, bar) {
34443444

34453445
}
34463446
// Options: [{"definedTypes":["MyType"]}]
34473447
// Message: The type 'HisType' is undefined.
34483448

3449-
/**
3450-
* @param {MyType} foo - Bar.
3451-
* @param {HisType} bar - Foo.
3452-
* @param {HerType} baz - Foo.
3453-
*/
3449+
/**
3450+
* @param {MyType} foo - Bar.
3451+
* @param {HisType} bar - Foo.
3452+
* @param {HerType} baz - Foo.
3453+
*/
34543454
function quux(foo, bar, baz) {
34553455

34563456
}
@@ -3634,30 +3634,30 @@ function foo () {
36343634
}
36353635

36363636
/**
3637-
* @param {MyType} foo - Bar.
3638-
* @param {HisType} bar - Foo.
3639-
*/
3637+
* @param {MyType} foo - Bar.
3638+
* @param {HisType} bar - Foo.
3639+
*/
36403640
function quux(foo, bar) {
36413641

36423642
}
36433643
// Options: [{"definedTypes":["MyType","HisType"]}]
36443644

3645-
/**
3646-
* @param {MyType} foo - Bar.
3647-
* @param {HisType} bar - Foo.
3648-
* @param {HerType} baz - Foo.
3649-
*/
3645+
/**
3646+
* @param {MyType} foo - Bar.
3647+
* @param {HisType} bar - Foo.
3648+
* @param {HerType} baz - Foo.
3649+
*/
36503650
function quux(foo, bar, baz) {
36513651

36523652
}
36533653
// Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType"},"histype":"HisType"}}}
36543654
// Options: [{"definedTypes":["MyType"]}]
36553655

3656-
/**
3657-
* @param {MyType} foo - Bar.
3658-
* @param {HisType} bar - Foo.
3659-
* @param {HerType} baz - Foo.
3660-
*/
3656+
/**
3657+
* @param {MyType} foo - Bar.
3658+
* @param {HisType} bar - Foo.
3659+
* @param {HerType} baz - Foo.
3660+
*/
36613661
function quux(foo, bar, baz) {
36623662

36633663
}
@@ -5351,14 +5351,14 @@ module.exports = {
53515351
// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
53525352

53535353
/**
5354-
*
5355-
*/
5354+
*
5355+
*/
53565356
function test() {
53575357

53585358
}
53595359

53605360
module.exports = {
5361-
prop: { prop2: test }
5361+
prop: { prop2: test }
53625362
}
53635363
// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
53645364

@@ -6816,8 +6816,8 @@ const quux = async () => {}
68166816
// Message: Missing JSDoc @returns declaration.
68176817

68186818
/**
6819-
*
6820-
*/
6819+
*
6820+
*/
68216821
async function quux () {}
68226822
// Options: [{"forceRequireReturn":true}]
68236823
// Message: Missing JSDoc @returns declaration.

src/bin/readme-assertions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ const trimCode = (code) => {
1616
const lastIndentSize = lastLineIndentation ? lastLineIndentation[0].length : 0;
1717

1818
lines = lines.map((line, index) => {
19-
if (index === 0) {
20-
return line.slice(Math.min(firstIndentSize, lastIndentSize));
21-
}
19+
const lineIndentSize = firstIndentSize !== 0 || index === 0 ?
20+
Math.min(firstIndentSize, lastIndentSize) :
21+
lastIndentSize;
2222

23-
return line.slice(lastIndentSize);
23+
return line.slice(lineIndentSize);
2424
});
2525

2626
return lines.join('\n');

test/rules/assertions/noUndefinedTypes.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ export default {
22
invalid: [
33
{
44
code: `
5-
/**
6-
* @param {HerType} baz - Foo.
7-
*/
5+
/**
6+
* @param {HerType} baz - Foo.
7+
*/
88
function quux(foo, bar, baz) {
99
1010
}
@@ -28,9 +28,9 @@ export default {
2828
},
2929
{
3030
code: `
31-
/**
32-
* @param {HerType} baz - Foo.
33-
*/
31+
/**
32+
* @param {HerType} baz - Foo.
33+
*/
3434
function quux(foo, bar, baz) {
3535
3636
}
@@ -73,9 +73,9 @@ export default {
7373
* @param {MyType} foo - Bar.
7474
* @param {HisType} bar - Foo.
7575
*/
76-
function quux(foo, bar) {
76+
function quux(foo, bar) {
7777
78-
}
78+
}
7979
`,
8080
errors: [
8181
{
@@ -89,11 +89,11 @@ export default {
8989
},
9090
{
9191
code: `
92-
/**
93-
* @param {MyType} foo - Bar.
94-
* @param {HisType} bar - Foo.
95-
* @param {HerType} baz - Foo.
96-
*/
92+
/**
93+
* @param {MyType} foo - Bar.
94+
* @param {HisType} bar - Foo.
95+
* @param {HerType} baz - Foo.
96+
*/
9797
function quux(foo, bar, baz) {
9898
9999
}
@@ -404,9 +404,9 @@ export default {
404404
* @param {MyType} foo - Bar.
405405
* @param {HisType} bar - Foo.
406406
*/
407-
function quux(foo, bar) {
407+
function quux(foo, bar) {
408408
409-
}
409+
}
410410
`,
411411
options: [{
412412
definedTypes: ['MyType', 'HisType']
@@ -419,9 +419,9 @@ export default {
419419
* @param {HisType} bar - Foo.
420420
* @param {HerType} baz - Foo.
421421
*/
422-
function quux(foo, bar, baz) {
422+
function quux(foo, bar, baz) {
423423
424-
}
424+
}
425425
`,
426426
options: [{
427427
definedTypes: ['MyType']
@@ -444,9 +444,9 @@ export default {
444444
* @param {HisType} bar - Foo.
445445
* @param {HerType} baz - Foo.
446446
*/
447-
function quux(foo, bar, baz) {
447+
function quux(foo, bar, baz) {
448448
449-
}
449+
}
450450
`,
451451
options: [{
452452
definedTypes: ['MyType']

test/rules/assertions/requireJsdoc.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,13 +1432,13 @@ export default {
14321432
/**
14331433
*
14341434
*/
1435-
function test() {
1435+
function test() {
14361436
1437-
}
1437+
}
14381438
1439-
module.exports = {
1440-
prop: { prop2: test }
1441-
}
1439+
module.exports = {
1440+
prop: { prop2: test }
1441+
}
14421442
`,
14431443
env: {
14441444
node: true

test/rules/assertions/requireReturns.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ export default {
171171
},
172172
{
173173
code: `
174-
/**
175-
*
176-
*/
174+
/**
175+
*
176+
*/
177177
async function quux () {}
178178
`,
179179
errors: [

0 commit comments

Comments
 (0)