From ab51cd415f3cc9528a870f6b1211525f0522b318 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Fri, 6 Aug 2021 12:40:31 +0200 Subject: [PATCH] Use ESM --- index.js | 8 ++------ package.json | 11 ++++++++--- test.js | 14 ++++++-------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/index.js b/index.js index c709679..7f676bf 100644 --- a/index.js +++ b/index.js @@ -1,15 +1,11 @@ -'use strict' - -var mdast2hast = require('mdast-util-to-hast') - -module.exports = remark2rehype +import mdast2hast from 'mdast-util-to-hast' // Attacher. // If a destination is given, runs the destination with the new hast tree // (bridge mode). // Without destination, returns the tree: further plugins run on that tree // (mutate mode). -function remark2rehype(destination, options) { +export default function remarkRehype(destination, options) { if (destination && !destination.process) { options = destination destination = null diff --git a/package.json b/package.json index 75320be..16ac672 100644 --- a/package.json +++ b/package.json @@ -26,11 +26,12 @@ "Titus Wormer (https://wooorm.com)", "John Otander (https://johno.com)" ], + "sideEffects": false, + "type": "module", + "main": "index.js", "files": [ - "index.js", - "types/index.d.ts" + "index.js" ], - "types": "types/index.d.ts", "dependencies": { "mdast-util-to-hast": "^10.2.0" }, @@ -65,6 +66,10 @@ "xo": { "prettier": true, "esnext": false, + "rules": { + "no-var": "off", + "prefer-arrow-callback": "off" + }, "ignores": [ "types/" ] diff --git a/test.js b/test.js index 0deb360..b16c384 100644 --- a/test.js +++ b/test.js @@ -1,11 +1,9 @@ -'use strict' - -var test = require('tape') -var unified = require('unified') -var parse = require('remark-parse') -var markdown = require('remark-stringify') -var html = require('rehype-stringify') -var remark2rehype = require('.') +import test from 'tape' +import unified from 'unified' +import parse from 'remark-parse' +import markdown from 'remark-stringify' +import html from 'rehype-stringify' +import remark2rehype from './index.js' test('remark2rehype()', function (t) { t.equal(