File tree Expand file tree Collapse file tree 3 files changed +9
-10
lines changed Expand file tree Collapse file tree 3 files changed +9
-10
lines changed Original file line number Diff line number Diff line change 18
18
* Heading node to check.
19
19
* @param {Style | null | undefined } [relative]
20
20
* Relative style (preferred style).
21
- * @returns {Style | null }
22
- * Style, if it can be inferred, `null ` otherwise.
21
+ * @returns {Style | undefined }
22
+ * Style, if it can be inferred, `undefined ` otherwise.
23
23
*/
24
- // To do: next major: use `undefined`.
25
24
export function headingStyle ( node , relative ) {
26
25
const last = node . children [ node . children . length - 1 ]
27
26
const depth = node . depth
28
27
const pos = node . position && node . position . end
29
28
const final = last && last . position && last . position . end
30
29
31
30
if ( ! pos ) {
32
- return null
31
+ return undefined
33
32
}
34
33
35
34
// This can only occur for `'atx'` and `'atx-closed'` headings.
@@ -59,12 +58,12 @@ export function headingStyle(node, relative) {
59
58
*
60
59
* @param {number } depth
61
60
* @param {Style | null | undefined } relative
62
- * @returns {Style | null }
61
+ * @returns {Style | undefined }
63
62
*/
64
63
function consolidate ( depth , relative ) {
65
64
return depth < 3
66
65
? 'atx'
67
66
: relative === 'atx' || relative === 'setext'
68
67
? relative
69
- : null
68
+ : undefined
70
69
}
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ headingStyle(fromMarkdown('# ATX').children[0]) // => 'atx'
77
77
headingStyle (fromMarkdown (' # ATX #\n ' ).children [0 ]) // => 'atx-closed'
78
78
headingStyle (fromMarkdown (' ATX\n ===' ).children [0 ]) // => 'setext'
79
79
80
- headingStyle (fromMarkdown (' ### ATX' ).children [0 ]) // => null
80
+ headingStyle (fromMarkdown (' ### ATX' ).children [0 ]) // => undefined
81
81
headingStyle (fromMarkdown (' ### ATX' ).children [0 ], ' setext' ) // => 'setext'
82
82
```
83
83
@@ -103,7 +103,7 @@ considered setext.
103
103
104
104
###### Returns
105
105
106
- Style ([ ` Style ` ] [ api-style ] ) if it can be inferred, ` null ` otherwise.
106
+ Style ([ ` Style ` ] [ api-style ] ) if it can be inferred, ` undefined ` otherwise.
107
107
108
108
### ` Style `
109
109
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ test('headingStyle', async function (t) {
28
28
type : 'heading' ,
29
29
children : [ { type : 'text' , value : 'foo' } ]
30
30
} ) ,
31
- null
31
+ undefined
32
32
)
33
33
} )
34
34
@@ -45,7 +45,7 @@ test('headingStyle', async function (t) {
45
45
} )
46
46
47
47
await t . test ( 'should work on ambiguous nodes' , async function ( ) {
48
- assert . equal ( headingStyle ( parseFirstNode ( '### ATX' ) ) , null )
48
+ assert . equal ( headingStyle ( parseFirstNode ( '### ATX' ) ) , undefined )
49
49
} )
50
50
51
51
await t . test (
You can’t perform that action at this time.
0 commit comments