Skip to content

Commit 006c140

Browse files
committed
fix(check-indentation): check for indentation when no line breaks in doc block
1 parent 1a13d8e commit 006c140

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,12 @@ Reports invalid padding inside JSDoc block.
833833
The following patterns are considered problems:
834834

835835
````js
836+
/*** foo */
837+
function quux () {
838+
839+
}
840+
// Message: There must be no indentation.
841+
836842
/**
837843
* foo
838844
*
@@ -863,6 +869,11 @@ The following patterns are not considered problems:
863869
*/
864870
function quux () {
865871

872+
}
873+
874+
/*** foo */
875+
function quux () {
876+
866877
}
867878
````
868879

src/rules/checkIndentation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default iterateJsdoc(({
55
jsdocNode,
66
report
77
}) => {
8-
const reg = new RegExp(/^[ \t]+\*[ \t]{2}/gm);
8+
const reg = new RegExp(/^(?:\/?\**|[ \t]*)\*[ \t]{2}/gm);
99
const text = sourceCode.getText(jsdocNode);
1010

1111
if (reg.test(text)) {

test/rules/assertions/checkIndentation.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
export default {
22
invalid: [
3+
{
4+
code: `
5+
/*** foo */
6+
function quux () {
7+
8+
}
9+
`,
10+
errors: [
11+
{
12+
line: 2,
13+
message: 'There must be no indentation.'
14+
}
15+
]
16+
},
317
{
418
code: `
519
/**
@@ -46,6 +60,14 @@ export default {
4660
*/
4761
function quux () {
4862
63+
}
64+
`
65+
},
66+
{
67+
code: `
68+
/*** foo */
69+
function quux () {
70+
4971
}
5072
`
5173
}

0 commit comments

Comments
 (0)