File tree Expand file tree Collapse file tree 5 files changed +51
-52
lines changed Expand file tree Collapse file tree 5 files changed +51
-52
lines changed Original file line number Diff line number Diff line change
1
+ coverage /
2
+ hast-util-sectioning.js
3
+ hast-util-sectioning.min.js
Original file line number Diff line number Diff line change 1
- 'use strict' ;
1
+ 'use strict'
2
2
3
- /* Dependencies. */
4
- var is = require ( 'hast-util-is-element' ) ;
3
+ var is = require ( 'hast-util-is-element' )
5
4
6
- /* Expose. */
7
- module . exports = sectioning ;
5
+ module . exports = sectioning
8
6
9
- /* Tag-names. */
10
- var names = [
11
- 'article' ,
12
- 'aside' ,
13
- 'nav' ,
14
- 'section'
15
- ] ;
7
+ var names = [ 'article' , 'aside' , 'nav' , 'section' ]
16
8
17
9
/* Check if a node is a sectioning element */
18
10
function sectioning ( node ) {
19
- return is ( node , names ) ;
11
+ return is ( node , names )
20
12
}
Original file line number Diff line number Diff line change 27
27
"browserify" : " ^16.0.0" ,
28
28
"esmangle" : " ^1.0.1" ,
29
29
"nyc" : " ^12.0.0" ,
30
+ "prettier" : " ^1.13.5" ,
30
31
"remark-cli" : " ^5.0.0" ,
31
32
"remark-preset-wooorm" : " ^4.0.0" ,
32
33
"tape" : " ^4.4.0" ,
33
34
"xo" : " ^0.21.0"
34
35
},
35
36
"scripts" : {
36
- "build-md " : " remark . --quiet --frail --output " ,
37
+ "format " : " remark . -qfo && prettier --write '**/*.js' && xo --fix " ,
37
38
"build-bundle" : " browserify index.js --bare -s hastUtilSectioning > hast-util-sectioning.js" ,
38
39
"build-mangle" : " esmangle hast-util-sectioning.js > hast-util-sectioning.min.js" ,
39
- "build" : " npm run build-md && npm run build-bundle && npm run build-mangle" ,
40
- "lint" : " xo" ,
41
- "test-api" : " node test.js" ,
40
+ "build" : " npm run build-bundle && npm run build-mangle" ,
41
+ "test-api" : " node test" ,
42
42
"test-coverage" : " nyc --reporter lcov tape test.js" ,
43
- "test" : " npm run build && npm run lint && npm run test-coverage"
43
+ "test" : " npm run format && npm run build && npm run test-coverage"
44
+ },
45
+ "prettier" : {
46
+ "tabWidth" : 2 ,
47
+ "useTabs" : false ,
48
+ "singleQuote" : true ,
49
+ "bracketSpacing" : false ,
50
+ "semi" : false ,
51
+ "trailingComma" : " none"
44
52
},
45
53
"xo" : {
46
- "space " : true ,
54
+ "prettier " : true ,
47
55
"esnext" : false ,
48
56
"ignores" : [
49
57
" hast-util-is-element.js"
Original file line number Diff line number Diff line change @@ -13,24 +13,26 @@ npm install hast-util-sectioning
13
13
## Usage
14
14
15
15
``` javascript
16
- var sectioning = require (' hast-util-sectioning' );
16
+ var sectioning = require (' hast-util-sectioning' )
17
17
18
18
sectioning ({
19
19
type: ' element' ,
20
20
tagName: ' a' ,
21
21
properties: {href: ' #alpha' , title: ' Bravo' },
22
22
children: [{type: ' text' , value: ' Charlie' }]
23
- }); // => false
23
+ }) // => false
24
24
25
25
sectioning ({
26
26
type: ' element' ,
27
27
tagName: ' article' ,
28
- children: [{
29
- type: ' element' ,
30
- tagName: ' p' ,
31
- children: [{type: ' text' , value: ' Delta' }]
32
- }]
33
- }); // => true
28
+ children: [
29
+ {
30
+ type: ' element' ,
31
+ tagName: ' p' ,
32
+ children: [{type: ' text' , value: ' Delta' }]
33
+ }
34
+ ]
35
+ }) // => true
34
36
```
35
37
36
38
## API
Original file line number Diff line number Diff line change 1
- 'use strict' ;
1
+ 'use strict'
2
2
3
- var test = require ( 'tape' ) ;
4
- var sectioning = require ( '.' ) ;
3
+ var test = require ( 'tape' )
4
+ var sectioning = require ( '.' )
5
5
6
- test ( 'sectioning' , function ( t ) {
7
- t . equal (
8
- sectioning ( ) ,
9
- false ,
10
- 'should return `false` without node'
11
- ) ;
6
+ test ( 'sectioning' , function ( t ) {
7
+ t . equal ( sectioning ( ) , false , 'should return `false` without node' )
12
8
13
- t . equal (
14
- sectioning ( null ) ,
15
- false ,
16
- 'should return `false` with `null`'
17
- ) ;
9
+ t . equal ( sectioning ( null ) , false , 'should return `false` with `null`' )
18
10
19
11
t . equal (
20
12
sectioning ( { type : 'text' } ) ,
21
13
false ,
22
14
'should return `false` when without `element`'
23
- ) ;
15
+ )
24
16
25
17
t . equal (
26
18
sectioning ( { type : 'element' } ) ,
27
19
false ,
28
20
'should return `false` when with invalid `element`'
29
- ) ;
21
+ )
30
22
31
23
t . equal (
32
24
sectioning ( {
@@ -37,21 +29,23 @@ test('sectioning', function (t) {
37
29
} ) ,
38
30
false ,
39
31
'should return `false` when without not sectioning'
40
- ) ;
32
+ )
41
33
42
34
t . equal (
43
35
sectioning ( {
44
36
type : 'element' ,
45
37
tagName : 'article' ,
46
- children : [ {
47
- type : 'element' ,
48
- tagName : 'p' ,
49
- children : [ { type : 'text' , value : 'Delta' } ]
50
- } ]
38
+ children : [
39
+ {
40
+ type : 'element' ,
41
+ tagName : 'p' ,
42
+ children : [ { type : 'text' , value : 'Delta' } ]
43
+ }
44
+ ]
51
45
} ) ,
52
46
true ,
53
47
'should return `true` when with sectioning'
54
- ) ;
48
+ )
55
49
56
- t . end ( ) ;
57
- } ) ;
50
+ t . end ( )
51
+ } )
You can’t perform that action at this time.
0 commit comments