Skip to content

Commit 411883d

Browse files
committed
Refactor code-style
1 parent 9f64e83 commit 411883d

File tree

5 files changed

+53
-55
lines changed

5 files changed

+53
-55
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-position.js
3+
unist-util-position.min.js

index.js

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

33
/* Expose. */
4-
var position = exports;
4+
var position = exports
55

6-
position.start = factory('start');
7-
position.end = factory('end');
6+
position.start = factory('start')
7+
position.end = factory('end')
88

99
/* Factory to get a `type` point in the positional info of a node. */
1010
function factory(type) {
11-
point.displayName = type;
11+
point.displayName = type
1212

13-
return point;
13+
return point
1414

1515
/* Get a point in `node.position` at a bound `type`. */
1616
function point(node) {
17-
var point = (node && node.position && node.position[type]) || {};
17+
var point = (node && node.position && node.position[type]) || {}
1818

1919
return {
2020
line: point.line || null,
2121
column: point.column || null,
2222
offset: isNaN(point.offset) ? null : point.offset
23-
};
23+
}
2424
}
2525
}

package.json

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,37 @@
2525
"browserify": "^16.0.0",
2626
"esmangle": "^1.0.0",
2727
"nyc": "^11.0.0",
28+
"prettier": "^1.12.1",
2829
"remark-cli": "^5.0.0",
2930
"remark-preset-wooorm": "^4.0.0",
3031
"tape": "^4.4.0",
3132
"xo": "^0.20.0"
3233
},
3334
"scripts": {
34-
"build-md": "remark . -qfo",
35+
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix",
3536
"build-bundle": "browserify index.js --no-builtins -s unistUtilPosition > unist-util-position.js",
3637
"build-mangle": "esmangle unist-util-position.js > unist-util-position.min.js",
37-
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
38-
"lint": "xo",
38+
"build": "npm run build-bundle && npm run build-mangle",
3939
"test-api": "node test",
4040
"test-coverage": "nyc --reporter lcov tape test.js",
41-
"test": "npm run build && npm run lint && npm run test-coverage"
41+
"test": "npm run format && npm run build && npm run test-coverage"
4242
},
4343
"nyc": {
4444
"check-coverage": true,
4545
"lines": 100,
4646
"functions": 100,
4747
"branches": 100
4848
},
49+
"prettier": {
50+
"tabWidth": 2,
51+
"useTabs": false,
52+
"singleQuote": true,
53+
"bracketSpacing": false,
54+
"semi": false,
55+
"trailingComma": "none"
56+
},
4957
"xo": {
50-
"space": true,
58+
"prettier": true,
5159
"esnext": false,
5260
"rules": {
5361
"guard-for-in": "off",

readme.md

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

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

19-
var tree = remark().parse([
20-
'# foo',
21-
'',
22-
'* bar',
23-
''
24-
].join('\n'));
19+
var tree = remark().parse(['# foo', '', '* bar', ''].join('\n'))
2520

26-
position.start(tree); //=> {line: 1, column: 1}
27-
position.end(tree); //=> {line: 4, column: 1}
21+
position.start(tree) // => {line: 1, column: 1}
22+
position.end(tree) // => {line: 4, column: 1}
2823

29-
position.start(); //=> {line: null, column: null}
30-
position.end(); //=> {line: null, column: null}
24+
position.start() // => {line: null, column: null}
25+
position.end() // => {line: null, column: null}
3126
```
3227

3328
## API

test.js

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

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

66
var properties = {
77
position: {
88
start: {line: 1, column: 1, offset: 0},
99
end: {line: 1, column: 2, offset: 1}
1010
}
11-
};
11+
}
1212

1313
var objects = {
1414
position: {start: {}, end: {}}
15-
};
15+
}
1616

17-
var values = {position: {}};
17+
var values = {position: {}}
1818

19-
var none = {};
19+
var none = {}
2020

21-
var generated = {line: null, column: null, offset: null};
21+
var generated = {line: null, column: null, offset: null}
2222

23-
test('unist-util-position', function (t) {
24-
['start', 'end'].forEach(function (type) {
25-
t.test(type, function (st) {
26-
var fn = position[type];
23+
test('unist-util-position', function(t) {
24+
;['start', 'end'].forEach(function(type) {
25+
t.test(type, function(st) {
26+
var fn = position[type]
2727

28-
st.same(
29-
fn(),
30-
generated,
31-
'should not throw without node'
32-
);
28+
st.same(fn(), generated, 'should not throw without node')
3329

34-
st.same(
35-
fn(properties),
36-
properties.position[type],
37-
'should get type'
38-
);
30+
st.same(fn(properties), properties.position[type], 'should get type')
3931

4032
st.same(
4133
fn(objects),
4234
generated,
4335
'should return an empty object without objects'
44-
);
36+
)
4537

4638
st.same(
4739
fn(values),
4840
generated,
4941
'should return an empty object without values'
50-
);
42+
)
5143

5244
st.same(
5345
fn(none),
5446
generated,
5547
'should return an empty object without position'
56-
);
48+
)
5749

58-
st.end();
59-
});
60-
});
50+
st.end()
51+
})
52+
})
6153

62-
t.end();
63-
});
54+
t.end()
55+
})

0 commit comments

Comments
 (0)