Skip to content

Commit

Permalink
Refactor code-style
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 3, 2021
1 parent 234bc9b commit 273a9b9
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 131 deletions.
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
},
"xo": {
"prettier": true,
"rules": {
"no-var": "off",
"prefer-arrow-callback": "off"
},
"ignores": [
"**/types"
]
Expand Down
20 changes: 10 additions & 10 deletions packages/remark-cli/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import url from 'url'
import execa from 'execa'
import test from 'tape'

test('remark-cli', function (t) {
test('remark-cli', (t) => {
t.plan(2)

t.test('should show help on `--help`', function (st) {
t.test('should show help on `--help`', (t) => {
const bin = url.fileURLToPath(new URL('./cli.js', import.meta.url))

st.plan(1)
t.plan(1)

execa(bin, ['--help']).then(function (result) {
st.equal(
execa(bin, ['--help']).then((result) => {
t.equal(
result.stdout,
[
'Usage: remark [options] [path | glob ...]',
Expand Down Expand Up @@ -62,18 +62,18 @@ test('remark-cli', function (t) {
})
})

t.test('should show version on `--version`', function (st) {
t.test('should show version on `--version`', (t) => {
const bin = url.fileURLToPath(new URL('./cli.js', import.meta.url))

st.plan(2)
t.plan(2)

execa(bin, ['--version']).then(function (result) {
st.ok(
execa(bin, ['--version']).then((result) => {
t.ok(
/remark: \d+\.\d+\.\d+/.test(result.stdout),
'should include remark version'
)

st.ok(
t.ok(
/remark-cli: \d+\.\d+\.\d+/.test(result.stdout),
'should include remark-cli version'
)
Expand Down
12 changes: 4 additions & 8 deletions packages/remark-parse/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import {fromMarkdown} from 'mdast-util-from-markdown'

export default function remarkParse(options) {
var self = this

this.Parser = parse

function parse(doc) {
this.Parser = (doc) => {
return fromMarkdown(
doc,
Object.assign({}, self.data('settings'), options, {
Object.assign({}, this.data('settings'), options, {
// Note: these options are not in the readme.
// The goal is for them to be set by plugins on `data` instead of being
// passed by users.
extensions: self.data('micromarkExtensions') || [],
mdastExtensions: self.data('fromMarkdownExtensions') || []
extensions: this.data('micromarkExtensions') || [],
mdastExtensions: this.data('fromMarkdownExtensions') || []
})
)
}
Expand Down
10 changes: 5 additions & 5 deletions packages/remark-parse/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ import {gfmFromMarkdown} from 'mdast-util-gfm'
import {removePosition} from 'unist-util-remove-position'
import remarkParse from './index.js'

test('remarkParse', function (t) {
test('remarkParse', (t) => {
t.equal(
unified().use(remarkParse).parse('Alfred').children.length,
1,
'should accept a `string`'
)

t.test('extensions', function (st) {
var tree = unified()
t.test('extensions', (t) => {
const tree = unified()
.data('micromarkExtensions', [gfm()])
.data('fromMarkdownExtensions', [gfmFromMarkdown])
.use(remarkParse)
.parse('* [x] contact@example.com ~~strikethrough~~')

removePosition(tree, true)

st.deepEqual(
t.deepEqual(
tree,
{
type: 'root',
Expand Down Expand Up @@ -62,7 +62,7 @@ test('remarkParse', function (t) {
'should work'
)

st.end()
t.end()
})

t.end()
Expand Down
10 changes: 3 additions & 7 deletions packages/remark-stringify/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import {toMarkdown} from 'mdast-util-to-markdown'

export default function remarkStringify(options) {
var self = this

this.Compiler = compile

function compile(tree) {
this.Compiler = (tree) => {
return toMarkdown(
tree,
Object.assign({}, self.data('settings'), options, {
Object.assign({}, this.data('settings'), options, {
// Note: this option is not in the readme.
// The goal is for it to be set by plugins on `data` instead of being
// passed by users.
extensions: self.data('toMarkdownExtensions') || []
extensions: this.data('toMarkdownExtensions') || []
})
)
}
Expand Down
Loading

0 comments on commit 273a9b9

Please sign in to comment.