Skip to content

Commit 3462a19

Browse files
committed
Use ESM
1 parent cb10bc0 commit 3462a19

File tree

6 files changed

+32
-36
lines changed

6 files changed

+32
-36
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-heading.js
7-
hast-util-heading.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-
*.json
32
*.md
4-
hast-util-heading.js
5-
hast-util-heading.min.js

index.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
'use strict'
1+
import {convertElement} from 'hast-util-is-element'
22

3-
var convert = require('hast-util-is-element/convert')
4-
5-
module.exports = convert(['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hgroup'])
3+
export const heading = convertElement([
4+
'h1',
5+
'h2',
6+
'h3',
7+
'h4',
8+
'h5',
9+
'h6',
10+
'hgroup'
11+
])

package.json

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,28 @@
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-is-element": "^1.1.0"
33+
"hast-util-is-element": "^2.0.0"
3134
},
3235
"devDependencies": {
33-
"browserify": "^17.0.0",
34-
"nyc": "^15.0.0",
36+
"c8": "^7.0.0",
3537
"prettier": "^2.0.0",
3638
"remark-cli": "^9.0.0",
3739
"remark-preset-wooorm": "^8.0.0",
3840
"tape": "^5.0.0",
39-
"tinyify": "^3.0.0",
40-
"xo": "^0.38.0"
41+
"xo": "^0.39.0"
4142
},
4243
"scripts": {
4344
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
44-
"build-bundle": "browserify . -s hastUtilHeading -o hast-util-heading.js",
45-
"build-mangle": "browserify . -s hastUtilHeading -o hast-util-heading.min.js -p tinyify",
46-
"build": "npm run build-bundle && npm run build-mangle",
47-
"test-api": "node test",
48-
"test-coverage": "nyc --reporter lcov tape test.js",
49-
"test": "npm run format && npm run build && npm run test-coverage"
45+
"test-api": "node test.js",
46+
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
47+
"test": "npm run format && npm run test-coverage"
5048
},
5149
"prettier": {
5250
"tabWidth": 2,
@@ -58,16 +56,10 @@
5856
},
5957
"xo": {
6058
"prettier": true,
61-
"esnext": false,
62-
"ignores": [
63-
"hast-util-heading.js"
64-
]
65-
},
66-
"nyc": {
67-
"check-coverage": true,
68-
"lines": 100,
69-
"functions": 100,
70-
"branches": 100
59+
"rules": {
60+
"no-var": "off",
61+
"prefer-arrow-callback": "off"
62+
}
7163
},
7264
"remarkConfig": {
7365
"plugins": [

readme.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
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-heading
2225
## Use
2326

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

2730
// Given a non-heading value:
2831
heading({
@@ -42,6 +45,9 @@ heading({
4245

4346
## API
4447

48+
This package exports the following identifiers: `heading`.
49+
There is no default export.
50+
4551
### `heading(node)`
4652

4753
Check if the given value is a [*heading*][spec] [*element*][element].

test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
'use strict'
2-
3-
var test = require('tape')
4-
var heading = require('.')
1+
import test from 'tape'
2+
import {heading} from './index.js'
53

64
test('heading', function (t) {
75
t.equal(heading(), false, 'should return `false` without node')

0 commit comments

Comments
 (0)