Skip to content

Commit 3b95bd2

Browse files
committed
Use ESM
1 parent 5f7e130 commit 3b95bd2

File tree

6 files changed

+34
-46
lines changed

6 files changed

+34
-46
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-
hast-util-phrasing.js
7-
hast-util-phrasing.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-
hast-util-phrasing.js
3-
hast-util-phrasing.min.js
4-
*.json
52
*.md

index.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
var is = require('hast-util-is-element')
2-
var has = require('hast-util-has-property')
3-
var embedded = require('hast-util-embedded')
4-
var bodyOkLink = require('hast-util-is-body-ok-link')
5-
6-
module.exports = phrasing
1+
import {isElement} from 'hast-util-is-element'
2+
import {hasProperty} from 'hast-util-has-property'
3+
import {embedded} from 'hast-util-embedded'
4+
import bodyOkLink from 'hast-util-is-body-ok-link'
75

86
var list = [
97
'a',
@@ -55,12 +53,12 @@ var list = [
5553
'wbr'
5654
]
5755

58-
function phrasing(node) {
56+
export function phrasing(node) {
5957
return (
6058
node.type === 'text' ||
61-
is(node, list) ||
59+
isElement(node, list) ||
6260
embedded(node) ||
6361
bodyOkLink(node) ||
64-
(is(node, 'meta') && has(node, 'itemProp'))
62+
(isElement(node, 'meta') && hasProperty(node, 'itemProp'))
6563
)
6664
}

package.json

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,33 @@
2323
"contributors": [
2424
"Titus Wormer <[email protected]> (https://wooorm.com)"
2525
],
26+
"sideEffects": false,
27+
"type": "module",
28+
"main": "index.js",
2629
"files": [
2730
"index.js"
2831
],
2932
"dependencies": {
30-
"hast-util-embedded": "^1.0.0",
31-
"hast-util-has-property": "^1.0.0",
33+
"hast-util-embedded": "^2.0.0",
34+
"hast-util-has-property": "^2.0.0",
3235
"hast-util-is-body-ok-link": "^1.0.0",
33-
"hast-util-is-element": "^1.0.0"
36+
"hast-util-is-element": "^2.0.0"
3437
},
3538
"devDependencies": {
36-
"browserify": "^17.0.0",
39+
"c8": "^7.0.0",
3740
"hastscript": "^6.0.0",
38-
"nyc": "^15.0.0",
3941
"prettier": "^2.0.0",
4042
"remark-cli": "^9.0.0",
4143
"remark-preset-wooorm": "^8.0.0",
4244
"tape": "^5.0.0",
43-
"tinyify": "^3.0.0",
44-
"unist-builder": "^2.0.0",
45-
"xo": "^0.38.0"
45+
"unist-builder": "^3.0.0",
46+
"xo": "^0.39.0"
4647
},
4748
"scripts": {
4849
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
49-
"build-bundle": "browserify index.js -s hastUtilPhrasing -o hast-util-phrasing.js",
50-
"build-mangle": "browserify index.js -s hastUtilPhrasing -o hast-util-phrasing.min.js -p tinyify",
51-
"build": "npm run build-bundle && npm run build-mangle",
52-
"test-api": "node test",
53-
"test-coverage": "nyc --reporter lcov tape test.js",
54-
"test": "npm run format && npm run build && npm run test-coverage"
55-
},
56-
"nyc": {
57-
"check-coverage": true,
58-
"lines": 100,
59-
"functions": 100,
60-
"branches": 100
50+
"test-api": "node test.js",
51+
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
52+
"test": "npm run format && npm run test-coverage"
6153
},
6254
"prettier": {
6355
"tabWidth": 2,
@@ -69,10 +61,10 @@
6961
},
7062
"xo": {
7163
"prettier": true,
72-
"esnext": false,
73-
"ignores": [
74-
"hast-util-phrasing.js"
75-
]
64+
"rules": {
65+
"no-var": "off",
66+
"prefer-arrow-callback": "off"
67+
}
7668
},
7769
"remarkConfig": {
7870
"plugins": [

readme.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ content.
1313

1414
## Install
1515

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

1821
```sh
@@ -22,7 +25,7 @@ npm install hast-util-phrasing
2225
## Use
2326

2427
```js
25-
var phrasing = require('.')
28+
import {phrasing} from 'hast-util-phrasing'
2629

2730
// Given flow content:
2831
phrasing({
@@ -57,6 +60,9 @@ phrasing({type: 'text', value: 'Delta'})
5760

5861
## API
5962

63+
This package exports the following identifiers: `phrasing`.
64+
There is no default export.
65+
6066
### `phrasing(node)`
6167

6268
Check if the given value is [*phrasing*][spec] content.

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 h = require('hastscript')
6-
var phrasing = require('.')
1+
import test from 'tape'
2+
import {u} from 'unist-builder'
3+
import h from 'hastscript'
4+
import {phrasing} from './index.js'
75

86
test('phrasing()', function (t) {
97
t.notOk(phrasing(h('div', 'Alpha')), 'flow')

0 commit comments

Comments
 (0)