Skip to content

Commit a1ac52c

Browse files
committed
Refactor code-style
1 parent d32012b commit a1ac52c

File tree

5 files changed

+38
-43
lines changed

5 files changed

+38
-43
lines changed

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
coverage/
2+
hast-util-heading.js
3+
hast-util-heading.min.js

index.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
'use strict';
1+
'use strict'
22

3-
var is = require('hast-util-is-element');
3+
var is = require('hast-util-is-element')
44

5-
module.exports = heading;
5+
module.exports = heading
66

7-
var names = [
8-
'h1',
9-
'h2',
10-
'h3',
11-
'h4',
12-
'h5',
13-
'h6',
14-
'hgroup'
15-
];
7+
var names = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hgroup']
168

179
function heading(node) {
18-
return is(node, names);
10+
return is(node, names)
1911
}

package.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,31 @@
2727
"browserify": "^16.0.0",
2828
"esmangle": "^1.0.1",
2929
"nyc": "^12.0.0",
30+
"prettier": "^1.13.5",
3031
"remark-cli": "^5.0.0",
3132
"remark-preset-wooorm": "^4.0.0",
3233
"tape": "^4.4.0",
3334
"xo": "^0.21.0"
3435
},
3536
"scripts": {
36-
"build-md": "remark . --quiet --frail --output",
37+
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix",
3738
"build-bundle": "browserify index.js --bare -s hastUtilHeading > hast-util-heading.js",
3839
"build-mangle": "esmangle hast-util-heading.js > hast-util-heading.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",
4242
"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"
4452
},
4553
"xo": {
46-
"space": true,
54+
"prettier": true,
4755
"esnext": false,
4856
"ignores": [
4957
"hast-util-heading.js"

readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ npm install hast-util-heading
1313
## Usage
1414

1515
```javascript
16-
var heading = require('hast-util-heading');
16+
var heading = require('hast-util-heading')
1717

1818
// Given a non-heading value:
1919
heading({
2020
type: 'element',
2121
tagName: 'a',
2222
properties: {href: '#alpha', title: 'Bravo'},
2323
children: [{type: 'text', value: 'Charlie'}]
24-
}); //=> false
24+
}) // => false
2525

2626
// Given a heading element:
27-
result = heading({
27+
heading({
2828
type: 'element',
2929
tagName: 'h1',
3030
children: [{type: 'text', value: 'Delta'}]
31-
}); //=> true
31+
}) // => true
3232
```
3333

3434
## API

test.js

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,24 @@
1-
'use strict';
1+
'use strict'
22

3-
var test = require('tape');
4-
var heading = require('.');
3+
var test = require('tape')
4+
var heading = require('.')
55

6-
test('heading', function (t) {
7-
t.equal(
8-
heading(),
9-
false,
10-
'should return `false` without node'
11-
);
6+
test('heading', function(t) {
7+
t.equal(heading(), false, 'should return `false` without node')
128

13-
t.equal(
14-
heading(null),
15-
false,
16-
'should return `false` with `null`'
17-
);
9+
t.equal(heading(null), false, 'should return `false` with `null`')
1810

1911
t.equal(
2012
heading({type: 'text'}),
2113
false,
2214
'should return `false` when without `element`'
23-
);
15+
)
2416

2517
t.equal(
2618
heading({type: 'element'}),
2719
false,
2820
'should return `false` when with invalid `element`'
29-
);
21+
)
3022

3123
t.equal(
3224
heading({
@@ -37,7 +29,7 @@ test('heading', function (t) {
3729
}),
3830
false,
3931
'should return `false` when without not heading'
40-
);
32+
)
4133

4234
t.equal(
4335
heading({
@@ -47,7 +39,7 @@ test('heading', function (t) {
4739
}),
4840
true,
4941
'should return `true` when with heading'
50-
);
42+
)
5143

52-
t.end();
53-
});
44+
t.end()
45+
})

0 commit comments

Comments
 (0)