From 0b9dc4284ef505077d622fbc9f74b3e18c42b441 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 5 Aug 2021 15:39:16 +0200 Subject: [PATCH] Use ESM --- index.js | 12 ++++-------- package.json | 7 +++++-- test/index.js | 22 ++++++++++------------ 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/index.js b/index.js index 16f98de..32806c0 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,10 @@ -'use strict' - -var syntax = require('micromark-extension-directive') -var fromMarkdown = require('mdast-util-directive/from-markdown') -var toMarkdown = require('mdast-util-directive/to-markdown') +import syntax from 'micromark-extension-directive' +import fromMarkdown from 'mdast-util-directive/from-markdown.js' +import toMarkdown from 'mdast-util-directive/to-markdown.js' var warningIssued -module.exports = directive - -function directive() { +export default function remarkDirective() { var data = this.data() // Old remark. diff --git a/package.json b/package.json index 02b74fa..270a784 100644 --- a/package.json +++ b/package.json @@ -24,9 +24,10 @@ "contributors": [ "Titus Wormer (https://wooorm.com)" ], - "types": "types/index.d.ts", + "sideEffects": false, + "type": "module", + "main": "index.js", "files": [ - "types/index.d.ts", "index.js" ], "dependencies": { @@ -66,6 +67,8 @@ "prettier": true, "esnext": false, "rules": { + "no-var": "off", + "prefer-arrow-callback": "off", "unicorn/no-array-callback-reference": "off", "unicorn/prefer-optional-catch-binding": "off" }, diff --git a/test/index.js b/test/index.js index e83826f..4fd0915 100644 --- a/test/index.js +++ b/test/index.js @@ -1,14 +1,12 @@ -'use strict' - -var fs = require('fs') -var path = require('path') -var test = require('tape') -var vfile = require('to-vfile') -var unified = require('unified') -var remark = require('remark') -var not = require('not') -var hidden = require('is-hidden') -var directive = require('..') +import fs from 'fs' +import path from 'path' +import test from 'tape' +import vfile from 'to-vfile' +import unified from 'unified' +import remark from 'remark' +import not from 'not' +import hidden from 'is-hidden' +import directive from '../index.js' test('directive()', function (t) { t.doesNotThrow(function () { @@ -23,7 +21,7 @@ test('directive()', function (t) { }) test('fixtures', function (t) { - var base = path.join(__dirname, 'fixtures') + var base = path.join('test', 'fixtures') var entries = fs.readdirSync(base).filter(not(hidden)) t.plan(entries.length)