Skip to content

Commit

Permalink
Use ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 2, 2021
1 parent 211f0ce commit 7d9f2f7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 29 deletions.
16 changes: 6 additions & 10 deletions index.js
@@ -1,11 +1,7 @@
'use strict'

var extend = require('extend')
var has = require('hast-util-has-property')
var rank = require('hast-util-heading-rank')
var visit = require('unist-util-visit')

module.exports = autolink
import extend from 'extend'
import has from 'hast-util-has-property'
import rank from 'hast-util-heading-rank'
import visit from 'unist-util-visit'

var splice = [].splice

Expand All @@ -16,7 +12,7 @@ var contentDefaults = {
children: []
}

function autolink(options) {
export default function rehypeAutolinkHeadings(options) {
var settings = options || {}
var props = settings.properties
var behavior = settings.behaviour || settings.behavior || 'prepend'
Expand Down Expand Up @@ -92,7 +88,7 @@ function autolink(options) {
type: 'element',
tagName: 'a',
properties: Object.assign({}, props, {href: '#' + node.properties.id}),
children: children
children
}
}
}
14 changes: 7 additions & 7 deletions package.json
Expand Up @@ -22,11 +22,12 @@
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],
"sideEffects": false,
"type": "module",
"main": "index.js",
"files": [
"index.js",
"types/index.d.ts"
"index.js"
],
"types": "types/index.d.ts",
"dependencies": {
"extend": "^3.0.0",
"hast-util-has-property": "^1.0.0",
Expand All @@ -37,7 +38,6 @@
"@types/hast": "^2.0.0",
"bail": "^1.0.0",
"c8": "^7.0.0",
"dtslint": "^4.0.0",
"is-hidden": "^1.0.0",
"negate": "^1.0.0",
"prettier": "^2.0.0",
Expand All @@ -53,8 +53,7 @@
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"test-api": "node --conditions development test/index.js",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov npm run test-api",
"test-types": "dtslint types",
"test": "npm run format && npm run test-coverage && npm run test-types"
"test": "npm run format && npm run test-coverage"
},
"prettier": {
"tabWidth": 2,
Expand All @@ -66,8 +65,9 @@
},
"xo": {
"prettier": true,
"esnext": false,
"rules": {
"no-var": "off",
"prefer-arrow-callback": "off",
"unicorn/no-fn-reference-in-iterator": "off",
"unicorn/prefer-optional-catch-binding": "off"
},
Expand Down
22 changes: 10 additions & 12 deletions test/index.js
@@ -1,17 +1,15 @@
'use strict'

var fs = require('fs')
var path = require('path')
var bail = require('bail')
var test = require('tape')
var rehype = require('rehype')
var vfile = require('to-vfile')
var negate = require('negate')
var hidden = require('is-hidden')
var autolink = require('..')
import fs from 'fs'
import path from 'path'
import bail from 'bail'
import test from 'tape'
import rehype from 'rehype'
import vfile from 'to-vfile'
import negate from 'negate'
import hidden from 'is-hidden'
import autolink from '../index.js'

test('rehype-autolink-headings', function (t) {
var root = path.join(__dirname, 'fixtures')
var root = path.join('test', 'fixtures')

t.test('fixtures', function (t) {
fs.readdir(root, function (error, files) {
Expand Down

0 comments on commit 7d9f2f7

Please sign in to comment.