Skip to content

Commit cac3780

Browse files
committed
Refactor code-style
1 parent 3ec3eca commit cac3780

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
import {visit} from 'unist-util-visit'
88

9-
var own = {}.hasOwnProperty
9+
const own = {}.hasOwnProperty
1010

1111
/**
1212
*
1313
* @param {Node} node
1414
*/
1515
export function definitions(node) {
1616
/** @type {Object.<string, Definition>} */
17-
var cache = Object.create(null)
17+
const cache = Object.create(null)
1818

1919
if (!node || !node.type) {
2020
throw new Error('mdast-util-definitions expected node')
@@ -26,7 +26,7 @@ export function definitions(node) {
2626

2727
/** @type {DefinitionVisitor} */
2828
function ondefinition(definition) {
29-
var id = clean(definition.identifier)
29+
const id = clean(definition.identifier)
3030
if (id && !own.call(cache, id)) {
3131
cache[id] = definition
3232
}
@@ -39,7 +39,7 @@ export function definitions(node) {
3939
* @returns {Definition|null}
4040
*/
4141
function getDefinition(identifier) {
42-
var id = clean(identifier)
42+
const id = clean(identifier)
4343
return id && own.call(cache, id) ? cache[id] : null
4444
}
4545
}

package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,7 @@
7171
"xo": {
7272
"prettier": true,
7373
"rules": {
74-
"capitalized-comments": "off",
75-
"no-var": "off",
76-
"prefer-arrow-callback": "off"
74+
"capitalized-comments": "off"
7775
}
7876
},
7977
"remarkConfig": {

readme.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ npm install mdast-util-definitions
2626
## Use
2727

2828
```js
29-
import remark from 'remark'
29+
import {remark} from 'remark'
3030
import {definitions} from 'mdast-util-definitions'
3131

32-
var tree = remark().parse('[example]: https://example.com "Example"')
32+
const tree = remark().parse('[example]: https://example.com "Example"')
3333

34-
var definition = definitions(tree)
34+
const definition = definitions(tree)
3535

3636
definition('example')
3737
// => {type: 'definition', 'title': 'Example', …}

test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import test from 'tape'
66
import remark from 'remark'
77
import {definitions} from './index.js'
88

9-
test('mdast-util-definitions', function (t) {
9+
test('mdast-util-definitions', (t) => {
1010
/** @type {Node} */
11-
var tree
11+
let tree
1212

1313
t.throws(
14-
function () {
14+
() => {
1515
// @ts-ignore runtime
1616
definitions()
1717
},

0 commit comments

Comments
 (0)