Skip to content

Commit d222773

Browse files
committed
Use ESM
1 parent 4745893 commit d222773

File tree

6 files changed

+30
-44
lines changed

6 files changed

+30
-44
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
.DS_Store
22
*.log
3-
.nyc_output/
43
coverage/
54
node_modules/
6-
unist-util-remove-position.js
7-
unist-util-remove-position.min.js
85
yarn.lock

.prettierignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
coverage/
2-
unist-util-remove-position.js
3-
unist-util-remove-position.min.js
4-
*.json
52
*.md

index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
'use strict'
1+
import {visit} from 'unist-util-visit'
22

3-
var visit = require('unist-util-visit')
4-
5-
module.exports = removePosition
6-
7-
function removePosition(node, force) {
3+
export function removePosition(node, force) {
84
visit(node, remove)
95

106
return node

package.json

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,32 @@
2525
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
2626
"Merlijn Vos <merlijn@soverin.net>"
2727
],
28+
"sideEffects": false,
29+
"type": "module",
30+
"main": "index.js",
31+
"types": "types/index.d.ts",
2832
"files": [
29-
"index.js",
30-
"types/index.d.ts"
33+
"types/index.d.ts",
34+
"index.js"
3135
],
32-
"types": "types/index.d.ts",
3336
"dependencies": {
34-
"unist-util-visit": "^2.0.0"
37+
"unist-util-visit": "^3.0.0"
3538
},
3639
"devDependencies": {
37-
"browserify": "^17.0.0",
38-
"dtslint": "^4.0.0",
39-
"nyc": "^15.0.0",
40+
"c8": "^7.0.0",
4041
"prettier": "^2.0.0",
4142
"remark": "^13.0.0",
4243
"remark-cli": "^9.0.0",
4344
"remark-preset-wooorm": "^8.0.0",
4445
"tape": "^5.0.0",
45-
"tinyify": "^3.0.0",
46-
"unist-builder": "^2.0.0",
46+
"unist-builder": "^3.0.0",
4747
"xo": "^0.38.0"
4848
},
4949
"scripts": {
5050
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
51-
"build-bundle": "browserify . -s unistUtilRemovePosition -o unist-util-remove-position.js",
52-
"build-mangle": "browserify . -s unistUtilRemovePosition -o unist-util-remove-position.min.js -p tinyify",
53-
"build": "npm run build-bundle && npm run build-mangle",
54-
"test-types": "dtslint types",
55-
"test-api": "node test",
56-
"test-coverage": "nyc --reporter lcov tape test.js",
57-
"test": "npm run format && npm run build && npm run test-coverage && npm run test-types"
51+
"test-api": "node test.js",
52+
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
53+
"test": "npm run format && npm run test-coverage"
5854
},
5955
"prettier": {
6056
"tabWidth": 2,
@@ -66,18 +62,14 @@
6662
},
6763
"xo": {
6864
"prettier": true,
69-
"esnext": false,
65+
"rules": {
66+
"no-var": "off",
67+
"prefer-arrow-callback": "off"
68+
},
7069
"ignores": [
71-
"unist-util-remove-position.js",
7270
"types/"
7371
]
7472
},
75-
"nyc": {
76-
"check-coverage": true,
77-
"lines": 100,
78-
"functions": 100,
79-
"branches": 100
80-
},
8173
"remarkConfig": {
8274
"plugins": [
8375
"preset-wooorm"

readme.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
## Install
1414

15+
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
16+
Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
17+
1518
[npm][]:
1619

1720
```sh
@@ -21,8 +24,8 @@ npm install unist-util-remove-position
2124
## Use
2225

2326
```js
24-
var remark = require('remark')
25-
var removePosition = require('unist-util-remove-position')
27+
import remark from 'remark'
28+
import {removePosition} from 'unist-util-remove-position'
2629

2730
var tree = remark().parse('Some _emphasis_, **importance**, and `code`.')
2831

@@ -55,6 +58,9 @@ Yields:
5558

5659
## API
5760

61+
This package exports the following identifiers: `removePosition`.
62+
There is no default export.
63+
5864
### `removePosition(node[, force])`
5965

6066
Remove [`position`][position] fields from [`node`][node].

test.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
'use strict'
2-
3-
var test = require('tape')
4-
var u = require('unist-builder')
5-
var remark = require('remark')
6-
var removePosition = require('.')
1+
import test from 'tape'
2+
import remark from 'remark'
3+
import {u} from 'unist-builder'
4+
import {removePosition} from './index.js'
75

86
test('removePosition()', function (t) {
97
var empty = {position: undefined}

0 commit comments

Comments
 (0)