Skip to content

Commit 3db2115

Browse files
committed
Refactor code-style
1 parent 570709b commit 3db2115

File tree

5 files changed

+37
-34
lines changed

5 files changed

+37
-34
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-transparent.js
3+
hast-util-transparent.min.js

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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 = transparent;
5+
module.exports = transparent
66

77
var names = [
88
'ol',
@@ -26,9 +26,9 @@ var names = [
2626
'map',
2727
'noscript',
2828
'canvas'
29-
];
29+
]
3030

3131
/* Check if a node is a transparent element */
3232
function transparent(node) {
33-
return is(node, names);
33+
return is(node, names)
3434
}

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 hastUtilTransparent > hast-util-transparent.js",
3839
"build-mangle": "esmangle hast-util-transparent.js > hast-util-transparent.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-transparent.js"

readme.md

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

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

1818
transparent({
1919
type: 'element',
2020
tagName: 'div',
2121
children: [{type: 'text', value: 'Alpha'}]
22-
}); //=> false
22+
}) // => false
2323

2424
transparent({
2525
type: 'element',
2626
tagName: 'a',
2727
properties: {href: '#bravo', title: 'Charlie'},
2828
children: [{type: 'text', value: 'Delta'}]
29-
}); //=> true
29+
}) // => true
3030
```
3131

3232
## 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 transparent = require('.');
3+
var test = require('tape')
4+
var transparent = require('.')
55

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

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

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

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

3123
t.equal(
3224
transparent({
@@ -36,7 +28,7 @@ test('transparent', function (t) {
3628
}),
3729
false,
3830
'should return `false` when without not transparent'
39-
);
31+
)
4032

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

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

0 commit comments

Comments
 (0)