Skip to content

Commit 33f8984

Browse files
committed
Refactor code-style
1 parent 08b8bf3 commit 33f8984

File tree

7 files changed

+27
-31
lines changed

7 files changed

+27
-31
lines changed

index.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ import {visit} from 'unist-util-visit'
2525
*/
2626
export function zone(node, name, callback) {
2727
/** @type {number} */
28-
var level
28+
let level
2929
/** @type {Node} */
30-
var marker
30+
let marker
3131
/** @type {Parent} */
32-
var scope
32+
let scope
3333

3434
visit(node, gather)
3535

@@ -38,14 +38,10 @@ export function zone(node, name, callback) {
3838
* @type {Visitor}
3939
*/
4040
function gather(node, index, parent) {
41-
var info = commentMarker(node)
42-
var match =
41+
const info = commentMarker(node)
42+
const match =
4343
info && info.name === name && info.attributes.match(/(start|end)\b/)
44-
var type = match && match[0]
45-
/** @type {number} */
46-
var start
47-
/** @type {Array.<Node>} */
48-
var result
44+
const type = match && match[0]
4945

5046
if (type) {
5147
if (!scope && type === 'start') {
@@ -62,9 +58,9 @@ export function zone(node, name, callback) {
6258
}
6359

6460
if (type === 'end' && !level) {
65-
start = scope.children.indexOf(marker)
61+
const start = scope.children.indexOf(marker)
6662

67-
result = callback(
63+
const result = callback(
6864
marker,
6965
scope.children.slice(start + 1, index),
7066
node,

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@
7373
"xo": {
7474
"prettier": true,
7575
"rules": {
76-
"capitalized-comments": "off",
77-
"no-var": "off",
78-
"prefer-arrow-callback": "off"
76+
"capitalized-comments": "off"
7977
}
8078
},
8179
"remarkConfig": {

readme.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ Foo
3838
And our script, `example.js`, looks as follows:
3939

4040
```js
41-
import toVFile from 'to-vfile'
42-
import remark from 'remark'
41+
import {readSync} from 'to-vfile'
42+
import {remark} from 'remark'
4343
import {zone} from 'mdast-zone'
4444

45+
const file = readSync('example.md')
46+
4547
remark()
4648
.use(plugin)
47-
.process(toVFile.readSync('example.md'), function(err, file) {
48-
if (err) throw err
49+
.process(file)
50+
.then((file) => {
4951
console.log(String(file))
5052
})
5153

test/fixtures/nodes/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* @param {import('unist').Node} tree
55
*/
66
export default function assertion(t, zone, tree) {
7-
var count = 0
7+
let count = 0
88

9-
t.test('nodes', function (st) {
9+
t.test('nodes', (st) => {
1010
st.plan(6)
1111

1212
zone(tree, 'foo', handle)

test/fixtures/range-children/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* @param {import('unist').Node} tree
55
*/
66
export default function assertion(t, zone, tree) {
7-
var count = 0
7+
let count = 0
88

9-
t.test('range-children', function (st) {
9+
t.test('range-children', (st) => {
1010
st.plan(3)
1111

1212
zone(tree, 'foo', handle)

test/fixtures/simple/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @param {import('unist').Node} tree
55
*/
66
export default function assertion(t, zone, tree) {
7-
t.test('range', function (st) {
7+
t.test('range', (st) => {
88
st.plan(5)
99

1010
zone(tree, 'foo', handle)

test/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ import remark from 'remark'
1111
import {isHidden} from 'is-hidden'
1212
import {zone} from '../index.js'
1313

14-
test('mdast-zone', async function (t) {
15-
var root = path.join('test', 'fixtures')
16-
var fixtures = fs.readdirSync(root)
17-
var index = -1
14+
test('mdast-zone', async (t) => {
15+
const root = path.join('test', 'fixtures')
16+
const fixtures = fs.readdirSync(root)
17+
let index = -1
1818
/** @type {string} */
19-
var output
19+
let output
2020
/** @type {string} */
21-
var name
21+
let name
2222
/** @type {(t: Test, zone: Zone, node: Node) => void} */
23-
var mod
23+
let mod
2424

2525
while (++index < fixtures.length) {
2626
name = fixtures[index]

0 commit comments

Comments
 (0)