Skip to content

Commit 67aaaae

Browse files
committed
Use ESM
1 parent 238a563 commit 67aaaae

File tree

6 files changed

+22
-37
lines changed

6 files changed

+22
-37
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-labelable.js
7-
hast-util-labelable.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-labelable.js
3-
hast-util-labelable.min.js
4-
*.json
52
*.md

index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
'use strict'
2-
3-
module.exports = labelable
4-
51
// Check whether a `node` is labelable:
62
// See: <https://html.spec.whatwg.org/#category-label>.
7-
function labelable(node) {
3+
export function labelable(node) {
84
var name = node && node.type === 'element' && node.tagName
95

106
return Boolean(

package.json

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,25 @@
2222
"contributors": [
2323
"Titus Wormer <[email protected]> (https://wooorm.com)"
2424
],
25+
"sideEffects": false,
26+
"type": "module",
27+
"main": "index.js",
2528
"files": [
2629
"index.js"
2730
],
2831
"devDependencies": {
29-
"browserify": "^17.0.0",
30-
"nyc": "^15.0.0",
32+
"c8": "^7.0.0",
3133
"prettier": "^2.0.0",
3234
"remark-cli": "^9.0.0",
3335
"remark-preset-wooorm": "^8.0.0",
3436
"tape": "^5.0.0",
35-
"tinyify": "^3.0.0",
36-
"xo": "^0.38.0"
37+
"xo": "^0.39.0"
3738
},
3839
"scripts": {
3940
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
40-
"build-bundle": "browserify . -s hastUtilLabelable -o hast-util-labelable.js",
41-
"build-mangle": "browserify . -s hastUtilLabelable -o hast-util-labelable.min.js -p tinyify",
42-
"build": "npm run build-bundle && npm run build-mangle",
43-
"lint": "xo",
44-
"test-api": "node test",
45-
"test-coverage": "nyc --reporter lcov tape test.js",
46-
"test": "npm run format && npm run build && npm run test-coverage"
41+
"test-api": "node test.js",
42+
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
43+
"test": "npm run format && npm run test-coverage"
4744
},
4845
"prettier": {
4946
"tabWidth": 2,
@@ -55,16 +52,10 @@
5552
},
5653
"xo": {
5754
"prettier": true,
58-
"esnext": false,
59-
"ignores": [
60-
"hast-util-labelable.js"
61-
]
62-
},
63-
"nyc": {
64-
"check-coverage": true,
65-
"lines": 100,
66-
"functions": 100,
67-
"branches": 100
55+
"rules": {
56+
"no-var": "off",
57+
"prefer-arrow-callback": "off"
58+
}
6859
},
6960
"remarkConfig": {
7061
"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-labelable
2225
## Use
2326

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

2730
labelable({type: 'element', tagName: 'div'}) // => false
2831

@@ -37,6 +40,9 @@ labelable({
3740

3841
## API
3942

43+
This package exports the following identifiers: `labelable`.
44+
There is no default export.
45+
4046
### `labelable(node)`
4147

4248
Check if the given value is a [*labelable*][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 labelable = require('.')
1+
import test from 'tape'
2+
import {labelable} from './index.js'
53

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

0 commit comments

Comments
 (0)