Skip to content

Commit d2ad50c

Browse files
committed
Refactor code-style
1 parent f7f0ba4 commit d2ad50c

File tree

5 files changed

+38
-27
lines changed

5 files changed

+38
-27
lines changed

.prettierignore

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

index.js

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

3-
var visit = require('unist-util-visit');
3+
var visit = require('unist-util-visit')
44

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

77
/* Remove `position`s from `tree`. */
88
function removePosition(node, force) {
9-
visit(node, force ? hard : soft);
10-
return node;
9+
visit(node, force ? hard : soft)
10+
return node
1111
}
1212

1313
function hard(node) {
14-
delete node.position;
14+
delete node.position
1515
}
1616

1717
function soft(node) {
18-
node.position = undefined;
18+
node.position = undefined
1919
}

package.json

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"browserify": "^16.0.0",
2727
"esmangle": "^1.0.1",
2828
"nyc": "^11.0.0",
29+
"prettier": "^1.12.1",
2930
"remark": "^9.0.0",
3031
"remark-cli": "^5.0.0",
3132
"remark-preset-wooorm": "^4.0.0",
@@ -34,17 +35,24 @@
3435
"xo": "^0.20.0"
3536
},
3637
"scripts": {
37-
"build-md": "remark . -qfo",
38+
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix",
3839
"build-bundle": "browserify index.js --bare -s unistUtilRemovePosition > unist-util-remove-position.js",
3940
"build-mangle": "esmangle < unist-util-remove-position.js > unist-util-remove-position.min.js",
40-
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
41-
"lint": "xo",
41+
"build": "npm run build-bundle && npm run build-mangle",
4242
"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"
45+
},
46+
"prettier": {
47+
"tabWidth": 2,
48+
"useTabs": false,
49+
"singleQuote": true,
50+
"bracketSpacing": false,
51+
"semi": false,
52+
"trailingComma": "none"
4553
},
4654
"xo": {
47-
"space": true,
55+
"prettier": true,
4856
"esnext": false,
4957
"rules": {
5058
"guard-for-in": "off",

readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ npm install unist-util-remove-position
1313
## Usage
1414

1515
```javascript
16-
var remark = require('remark');
17-
var removePosition = require('unist-util-remove-position');
16+
var remark = require('remark')
17+
var removePosition = require('unist-util-remove-position')
1818

19-
var tree = remark().parse('Some _emphasis_, **importance**, and `code`.');
19+
var tree = remark().parse('Some _emphasis_, **importance**, and `code`.')
2020

21-
console.dir(removePosition(tree, true), {depth: null});
21+
console.dir(removePosition(tree, true), {depth: null})
2222
```
2323

2424
Yields:

test.js

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

3-
var test = require('tape');
4-
var u = require('unist-builder');
5-
var remark = require('remark');
6-
var removePosition = require('.');
3+
var test = require('tape')
4+
var u = require('unist-builder')
5+
var remark = require('remark')
6+
var removePosition = require('.')
77

8-
test('removePosition()', function (t) {
9-
var empty = {position: undefined};
8+
test('removePosition()', function(t) {
9+
var empty = {position: undefined}
1010

1111
t.same(
1212
removePosition(remark().parse('Some **strong**, _emphasis_, and `code`.')),
@@ -22,7 +22,7 @@ test('removePosition()', function (t) {
2222
])
2323
]),
2424
'should work softly'
25-
);
25+
)
2626

2727
t.same(
2828
removePosition(
@@ -41,7 +41,7 @@ test('removePosition()', function (t) {
4141
])
4242
]),
4343
'should work by force'
44-
);
44+
)
4545

46-
t.end();
47-
});
46+
t.end()
47+
})

0 commit comments

Comments
 (0)