Skip to content

Commit 5817a3b

Browse files
committed
Refactor code-style
1 parent 7cb41ac commit 5817a3b

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

index.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import stripIndent from 'strip-indent'
22

3-
var eol = /\r?\n|\r/g
3+
const eol = /\r?\n|\r/g
44

55
export const mdxExpressionFromMarkdown = {
66
enter: {
@@ -37,8 +37,8 @@ function enterMdxTextExpression(token) {
3737
}
3838

3939
function exitMdxExpression(token) {
40-
var value = this.resume()
41-
var node = this.exit(token)
40+
const value = this.resume()
41+
const node = this.exit(token)
4242

4343
node.value = token.type === 'mdxFlowExpression' ? dedent(value) : value
4444

@@ -52,9 +52,14 @@ function exitMdxExpressionData(token) {
5252
this.config.exit.data.call(this, token)
5353
}
5454

55+
function handleMdxExpression(node) {
56+
const value = node.value || ''
57+
return '{' + (node.type === 'mdxFlowExpression' ? indent(value) : value) + '}'
58+
}
59+
5560
function dedent(value) {
56-
var firstLineEnding = /\r?\n|\r/.exec(value)
57-
var position = firstLineEnding
61+
const firstLineEnding = /\r?\n|\r/.exec(value)
62+
const position = firstLineEnding
5863
? firstLineEnding.index + firstLineEnding[0].length
5964
: -1
6065

@@ -65,16 +70,11 @@ function dedent(value) {
6570
return value
6671
}
6772

68-
function handleMdxExpression(node) {
69-
var value = node.value || ''
70-
return '{' + (node.type === 'mdxFlowExpression' ? indent(value) : value) + '}'
71-
}
72-
7373
function indent(value) {
74-
var result = []
75-
var start = 0
76-
var line = 0
77-
var match
74+
const result = []
75+
let start = 0
76+
let line = 0
77+
let match
7878

7979
while ((match = eol.exec(value))) {
8080
one(value.slice(start, match.index))

package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@
6363
"trailingComma": "none"
6464
},
6565
"xo": {
66-
"prettier": true,
67-
"prettier": true,
68-
"rules": {
69-
"no-var": "off",
70-
"prefer-arrow-callback": "off"
71-
}
66+
"prettier": true
7267
},
7368
"remarkConfig": {
7469
"plugins": [

test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {removePosition} from 'unist-util-remove-position'
66
import mdxExpression from 'micromark-extension-mdx-expression'
77
import {mdxExpressionFromMarkdown, mdxExpressionToMarkdown} from './index.js'
88

9-
test('markdown -> mdast', function (t) {
9+
test('markdown -> mdast', (t) => {
1010
t.deepEqual(
1111
fromMarkdown('{1 + 1}', {
1212
extensions: [mdxExpression()],
@@ -396,7 +396,7 @@ test('markdown -> mdast', function (t) {
396396
t.end()
397397
})
398398

399-
test('mdast -> markdown', function (t) {
399+
test('mdast -> markdown', (t) => {
400400
t.deepEqual(
401401
toMarkdown(
402402
{

0 commit comments

Comments
 (0)