File tree 2 files changed +24
-4
lines changed 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 10
10
*
11
11
* @example {"name": "ok.md"}
12
12
*
13
+ * ```bash
14
+ * echo a
15
+ * ```
16
+ *
13
17
* ```sh
14
18
* echo a
15
19
* echo a > file
34
38
*
35
39
* @example {"name": "not-ok.md", "label": "input"}
36
40
*
41
+ * ```sh
42
+ * $ echo a
43
+ * ```
44
+ *
37
45
* ```bash
38
46
* $ echo a
39
47
* $ echo a > file
40
48
* ```
41
49
*
42
50
* @example {"name": "not-ok.md", "label": "output"}
43
51
*
44
- * 1:1-4:4: Do not use dollar signs before shell commands
52
+ * 1:1-3:4: Do not use dollar signs before shell commands
53
+ * 5:1-8:4: Do not use dollar signs before shell commands
45
54
*/
46
55
47
56
'use strict'
@@ -81,11 +90,13 @@ function noShellDollars(tree, file) {
81
90
82
91
// Check both known shell code and unknown code.
83
92
if ( ! generated ( node ) && node . lang && flags . indexOf ( node . lang ) !== - 1 ) {
84
- lines = node . value . split ( '\n' )
93
+ lines = node . value . split ( '\n' ) . filter ( function ( line ) {
94
+ return line
95
+ } )
85
96
length = lines . length
86
97
index = - 1
87
98
88
- if ( length <= 1 ) {
99
+ if ( length === 0 ) {
89
100
return
90
101
}
91
102
Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ This rule is included in the following presets:
29
29
###### In
30
30
31
31
```` markdown
32
+ ```bash
33
+ echo a
34
+ ```
35
+
32
36
```sh
33
37
echo a
34
38
echo a > file
@@ -61,6 +65,10 @@ No messages.
61
65
###### In
62
66
63
67
```` markdown
68
+ ```sh
69
+ $ echo a
70
+ ```
71
+
64
72
```bash
65
73
$ echo a
66
74
$ echo a > file
@@ -70,7 +78,8 @@ $ echo a > file
70
78
###### Out
71
79
72
80
``` text
73
- 1:1-4:4: Do not use dollar signs before shell commands
81
+ 1:1-3:4: Do not use dollar signs before shell commands
82
+ 5:1-8:4: Do not use dollar signs before shell commands
74
83
```
75
84
76
85
## Install
You can’t perform that action at this time.
0 commit comments