Skip to content

Commit 12e74e4

Browse files
committed
Update code-style
1 parent 242fde0 commit 12e74e4

File tree

5 files changed

+166
-203
lines changed

5 files changed

+166
-203
lines changed

.editorconfig

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@ root = true
22

33
[*]
44
indent_style = space
5-
indent_size = 4
5+
indent_size = 2
66
end_of_line = lf
77
charset = utf-8
88
trim_trailing_whitespace = true
99
insert_final_newline = true
10-
11-
[*.{json,html,svg,css,mdastrc,eslintrc}]
12-
indent_size = 2
13-
14-
[*.md]
15-
trim_trailing_whitespace = false

.gitignore

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
.DS_Store
22
*.log
3-
bower_components/
4-
build/
5-
components/
3+
.nyc_output/
64
coverage/
75
node_modules/
8-
build.js
6+
unist-util-find-after.js
7+
unist-util-find-after.min.js

index.js

Lines changed: 24 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,38 @@
1-
/**
2-
* @author Titus Wormer
3-
* @copyright 2015 Titus Wormer
4-
* @license MIT
5-
* @module unist:util:find-after
6-
* @fileoverview Utility to find a node after another node.
7-
*/
8-
91
'use strict';
102

11-
/* eslint-env commonjs */
12-
13-
/*
14-
* Dependencies.
15-
*/
16-
173
var is = require('unist-util-is');
184

19-
/**
20-
* Find a node after `index` in `parent` which passes
21-
* `test`.
22-
*
23-
* @param {Node} parent - Parent to search in.
24-
* @param {number|Node} index - (Position of) node to
25-
* search after.
26-
* @param {*} test - See `wooorm/unist-util-is`.
27-
* @return {Node?} - A child node of `parent` which passes
28-
* `test`.
29-
*/
5+
module.exports = findAfter;
6+
7+
/* Find a node after `index` in `parent` which passes
8+
* `test`. */
309
function findAfter(parent, index, test) {
31-
var children;
32-
var child;
33-
var length;
10+
var children;
11+
var child;
12+
var length;
3413

35-
if (!parent || !parent.type || !parent.children) {
36-
throw new Error('Expected parent node');
37-
}
14+
if (!parent || !parent.type || !parent.children) {
15+
throw new Error('Expected parent node');
16+
}
3817

39-
children = parent.children;
40-
length = children.length;
18+
children = parent.children;
19+
length = children.length;
4120

42-
if (index && index.type) {
43-
index = children.indexOf(index);
44-
}
21+
if (index && index.type) {
22+
index = children.indexOf(index);
23+
}
4524

46-
if (isNaN(index) || index < 0 || index === Infinity) {
47-
throw new Error('Expected positive finite index or child node');
48-
}
25+
if (isNaN(index) || index < 0 || index === Infinity) {
26+
throw new Error('Expected positive finite index or child node');
27+
}
4928

50-
while (++index < length) {
51-
child = children[index];
29+
while (++index < length) {
30+
child = children[index];
5231

53-
if (is(test, child, index, parent)) {
54-
return child;
55-
}
32+
if (is(test, child, index, parent)) {
33+
return child;
5634
}
35+
}
5736

58-
return null;
37+
return null;
5938
}
60-
61-
/*
62-
* Expose.
63-
*/
64-
65-
module.exports = findAfter;

package.json

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,38 @@
3333
],
3434
"devDependencies": {
3535
"browserify": "^11.0.0",
36-
"eslint": "^1.0.0",
3736
"esmangle": "^1.0.0",
38-
"istanbul": "^0.3.0",
39-
"jscs": "^2.0.0",
40-
"jscs-jsdoc": "^1.0.0",
4137
"mdast": "^1.0.0",
4238
"mdast-comment-config": "^1.0.0",
4339
"mdast-github": "^1.0.0",
4440
"mdast-lint": "^1.0.0",
4541
"mdast-slug": "^1.0.0",
4642
"mdast-validate-links": "^1.0.0",
47-
"mocha": "^2.0.0"
43+
"nyc": "^9.0.1",
44+
"tape": "^4.6.2",
45+
"xo": "^0.17.1"
4846
},
4947
"scripts": {
50-
"test-api": "mocha --check-leaks test.js",
51-
"test-coverage": "istanbul cover _mocha -- test.js",
52-
"test-travis": "npm run test-coverage",
53-
"test": "npm run test-api",
54-
"lint-api": "eslint .",
55-
"lint-style": "jscs --reporter inline .",
56-
"lint": "npm run lint-api && npm run lint-style",
57-
"make": "npm run lint && npm run test-coverage",
48+
"lint": "xo",
5849
"bundle": "browserify index.js --no-builtins -s unistUtilFindAfter > unist-util-find-after.js",
5950
"postbundle": "esmangle unist-util-find-after.js > unist-util-find-after.min.js",
6051
"build-md": "mdast . --quiet",
61-
"build": "npm run bundle && npm run build-md"
52+
"build": "npm run bundle && npm run build-md",
53+
"lint": "xo",
54+
"test-api": "node test",
55+
"test-coverage": "nyc --reporter lcov tape test.js",
56+
"test": "npm run build && npm run lint && npm run test-coverage"
57+
},
58+
"nyc": {
59+
"check-coverage": true,
60+
"lines": 100,
61+
"functions": 100,
62+
"branches": 100
63+
},
64+
"xo": {
65+
"space": true,
66+
"ignore": [
67+
"unist-util-find-after.js"
68+
]
6269
}
6370
}

0 commit comments

Comments
 (0)