Skip to content

Commit d2a255b

Browse files
committed
Refactor code-style
1 parent fb97579 commit d2a255b

File tree

5 files changed

+37
-40
lines changed

5 files changed

+37
-40
lines changed

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
coverage/
2+
hast-util-script-supporting.js
3+
hast-util-script-supporting.min.js

index.js

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
'use strict';
1+
'use strict'
22

3-
/* Expose. */
4-
module.exports = scriptSupporting;
3+
module.exports = scriptSupporting
54

6-
/* Dependencies. */
7-
var is = require('hast-util-is-element');
5+
var is = require('hast-util-is-element')
86

9-
/* Tag-names. */
10-
var names = [
11-
'script',
12-
'template'
13-
];
7+
var names = ['script', 'template']
148

159
/* Check if a node is a script-supporting element */
1610
function scriptSupporting(node) {
17-
return is(node, names);
11+
return is(node, names)
1812
}

package.json

+14-6
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,37 @@
2828
"browserify": "^16.0.0",
2929
"esmangle": "^1.0.1",
3030
"nyc": "^12.0.0",
31+
"prettier": "^1.13.5",
3132
"remark-cli": "^5.0.0",
3233
"remark-preset-wooorm": "^4.0.0",
3334
"tape": "^4.4.0",
3435
"xo": "^0.21.0"
3536
},
3637
"scripts": {
37-
"build-md": "remark . --quiet --frail --output",
38+
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix",
3839
"build-bundle": "browserify index.js --bare -s hastUtilScriptSupporting > hast-util-script-supporting.js",
3940
"build-mangle": "esmangle hast-util-script-supporting.js > hast-util-script-supporting.min.js",
40-
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
41-
"lint": "xo",
42-
"test-api": "node test.js",
41+
"build": "npm run build-bundle && npm run build-mangle",
42+
"test-api": "node test",
4343
"test-coverage": "nyc --reporter lcov tape test.js",
44-
"test": "npm run build && npm run lint && npm run test-coverage"
44+
"test": "npm run format && npm run build && npm run test-coverage"
4545
},
4646
"nyc": {
4747
"check-coverage": true,
4848
"lines": 100,
4949
"functions": 100,
5050
"branches": 100
5151
},
52+
"prettier": {
53+
"tabWidth": 2,
54+
"useTabs": false,
55+
"singleQuote": true,
56+
"bracketSpacing": false,
57+
"semi": false,
58+
"trailingComma": "none"
59+
},
5260
"xo": {
53-
"space": true,
61+
"prettier": true,
5462
"esnext": false,
5563
"ignores": [
5664
"hast-util-is-element.js"

readme.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ npm install hast-util-script-supporting
1313
## Usage
1414

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

1818
scriptSupporting({
1919
type: 'element',
2020
tagName: 'a',
2121
properties: {href: '#alpha', title: 'Bravo'},
2222
children: [{type: 'text', value: 'Charlie'}]
23-
}); //=> false
23+
}) // => false
2424

2525
scriptSupporting({
2626
type: 'element',
2727
tagName: 'template',
2828
children: [{type: 'text', value: 'Delta'}]
29-
}); //=> true
29+
}) // => true
3030
```
3131

3232
## API

test.js

+12-20
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 scriptSupporting = require('.');
3+
var test = require('tape')
4+
var scriptSupporting = require('.')
55

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)