Skip to content

Commit 72cbf43

Browse files
committed
Refactor code-style
1 parent b1f9134 commit 72cbf43

File tree

4 files changed

+18
-22
lines changed

4 files changed

+18
-22
lines changed

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ export const findAllBefore =
2626
* @returns {Array.<Node>}
2727
*/
2828
function (parent, index, test) {
29-
var is = convert(test)
29+
const is = convert(test)
3030
/** @type {Array.<Node>} */
31-
var results = []
32-
var offset = -1
31+
const results = []
32+
let offset = -1
3333

3434
if (!parent || !parent.type || !parent.children) {
3535
throw new Error('Expected parent node')

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@
6464
"trailingComma": "none"
6565
},
6666
"xo": {
67-
"prettier": true,
68-
"rules": {
69-
"no-var": "off",
70-
"prefer-arrow-callback": "off"
71-
}
67+
"prettier": true
7268
},
7369
"remarkConfig": {
7470
"plugins": [

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ npm install unist-util-find-all-before
2727
import {u} from 'unist-builder'
2828
import {findAllBefore} from 'unist-util-find-all-before'
2929

30-
var tree = u('tree', [
30+
const tree = u('tree', [
3131
u('leaf', 'leaf 1'),
3232
u('node', [u('leaf', 'leaf 2'), u('leaf', 'leaf 3')]),
3333
u('leaf', 'leaf 4'),
@@ -37,7 +37,7 @@ var tree = u('tree', [
3737
u('leaf', 'leaf 7')
3838
])
3939

40-
var leaf6 = tree.children[4]
40+
const leaf6 = tree.children[4]
4141

4242
console.log(findAllBefore(tree, leaf6, 'leaf'))
4343
```

test.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import test from 'tape'
22
import remark from 'remark'
33
import {findAllBefore} from './index.js'
44

5-
var tree = remark().parse('Some _emphasis_, **importance**, and `code`.')
5+
const tree = remark().parse('Some _emphasis_, **importance**, and `code`.')
66
// @ts-expect-error hush.
7-
var paragraph = tree.children[0]
8-
var children = paragraph.children
7+
const paragraph = tree.children[0]
8+
const children = paragraph.children
99

10-
test('unist-util-find-all-before', function (t) {
10+
test('unist-util-find-all-before', (t) => {
1111
t.throws(
12-
function () {
12+
() => {
1313
// @ts-expect-error runtime.
1414
findAllBefore()
1515
},
@@ -18,7 +18,7 @@ test('unist-util-find-all-before', function (t) {
1818
)
1919

2020
t.throws(
21-
function () {
21+
() => {
2222
// @ts-expect-error runtime.
2323
findAllBefore({type: 'foo'})
2424
},
@@ -27,7 +27,7 @@ test('unist-util-find-all-before', function (t) {
2727
)
2828

2929
t.throws(
30-
function () {
30+
() => {
3131
// @ts-expect-error runtime.
3232
findAllBefore({type: 'foo', children: []})
3333
},
@@ -36,23 +36,23 @@ test('unist-util-find-all-before', function (t) {
3636
)
3737

3838
t.throws(
39-
function () {
39+
() => {
4040
findAllBefore({type: 'foo', children: []}, -1)
4141
},
4242
/Expected positive finite number as index/,
4343
'should fail without index (#2)'
4444
)
4545

4646
t.throws(
47-
function () {
47+
() => {
4848
findAllBefore({type: 'foo', children: []}, {type: 'bar'})
4949
},
5050
/Expected child node or index/,
5151
'should fail without index (#3)'
5252
)
5353

5454
t.throws(
55-
function () {
55+
() => {
5656
// @ts-expect-error runtime.
5757
findAllBefore({type: 'foo', children: [{type: 'bar'}]}, 1, false)
5858
},
@@ -61,7 +61,7 @@ test('unist-util-find-all-before', function (t) {
6161
)
6262

6363
t.throws(
64-
function () {
64+
() => {
6565
// @ts-expect-error runtime.
6666
findAllBefore({type: 'foo', children: [{type: 'bar'}]}, 1, true)
6767
},
@@ -137,7 +137,7 @@ test('unist-util-find-all-before', function (t) {
137137
'should return children when given a `type` and existing (#4)'
138138
)
139139

140-
var result = children.slice(4)
140+
const result = children.slice(4)
141141

142142
t.deepEqual(
143143
findAllBefore(paragraph, 100, test),

0 commit comments

Comments
 (0)