Skip to content

Commit

Permalink
Use ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Apr 20, 2021
1 parent 4745893 commit d222773
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 44 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
.DS_Store
*.log
.nyc_output/
coverage/
node_modules/
unist-util-remove-position.js
unist-util-remove-position.min.js
yarn.lock
3 changes: 0 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
coverage/
unist-util-remove-position.js
unist-util-remove-position.min.js
*.json
*.md
8 changes: 2 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
'use strict'
import {visit} from 'unist-util-visit'

var visit = require('unist-util-visit')

module.exports = removePosition

function removePosition(node, force) {
export function removePosition(node, force) {
visit(node, remove)

return node
Expand Down
40 changes: 16 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,32 @@
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"Merlijn Vos <merlijn@soverin.net>"
],
"sideEffects": false,
"type": "module",
"main": "index.js",
"types": "types/index.d.ts",
"files": [
"index.js",
"types/index.d.ts"
"types/index.d.ts",
"index.js"
],
"types": "types/index.d.ts",
"dependencies": {
"unist-util-visit": "^2.0.0"
"unist-util-visit": "^3.0.0"
},
"devDependencies": {
"browserify": "^17.0.0",
"dtslint": "^4.0.0",
"nyc": "^15.0.0",
"c8": "^7.0.0",
"prettier": "^2.0.0",
"remark": "^13.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"tape": "^5.0.0",
"tinyify": "^3.0.0",
"unist-builder": "^2.0.0",
"unist-builder": "^3.0.0",
"xo": "^0.38.0"
},
"scripts": {
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"build-bundle": "browserify . -s unistUtilRemovePosition -o unist-util-remove-position.js",
"build-mangle": "browserify . -s unistUtilRemovePosition -o unist-util-remove-position.min.js -p tinyify",
"build": "npm run build-bundle && npm run build-mangle",
"test-types": "dtslint types",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test": "npm run format && npm run build && npm run test-coverage && npm run test-types"
"test-api": "node test.js",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
"test": "npm run format && npm run test-coverage"
},
"prettier": {
"tabWidth": 2,
Expand All @@ -66,18 +62,14 @@
},
"xo": {
"prettier": true,
"esnext": false,
"rules": {
"no-var": "off",
"prefer-arrow-callback": "off"
},
"ignores": [
"unist-util-remove-position.js",
"types/"
]
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
Expand Down
10 changes: 8 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

## Install

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

[npm][]:

```sh
Expand All @@ -21,8 +24,8 @@ npm install unist-util-remove-position
## Use

```js
var remark = require('remark')
var removePosition = require('unist-util-remove-position')
import remark from 'remark'
import {removePosition} from 'unist-util-remove-position'

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

Expand Down Expand Up @@ -55,6 +58,9 @@ Yields:

## API

This package exports the following identifiers: `removePosition`.
There is no default export.

### `removePosition(node[, force])`

Remove [`position`][position] fields from [`node`][node].
Expand Down
10 changes: 4 additions & 6 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict'

var test = require('tape')
var u = require('unist-builder')
var remark = require('remark')
var removePosition = require('.')
import test from 'tape'
import remark from 'remark'
import {u} from 'unist-builder'
import {removePosition} from './index.js'

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

0 comments on commit d222773

Please sign in to comment.