Skip to content

Commit 4f25469

Browse files
committed
Use ESM
1 parent c2366d5 commit 4f25469

File tree

6 files changed

+24
-42
lines changed

6 files changed

+24
-42
lines changed

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
.DS_Store
22
*.log
33
coverage/
4-
.nyc_output/
54
node_modules/
6-
hast-util-script-supporting.js
7-
hast-util-script-supporting.min.js
85
yarn.lock

.prettierignore

-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
coverage/
2-
hast-util-script-supporting.js
3-
hast-util-script-supporting.min.js
4-
*.json
52
*.md

index.js

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
'use strict'
2-
3-
module.exports = scriptSupporting
4-
5-
var is = require('hast-util-is-element')
6-
7-
var names = ['script', 'template']
1+
import {convertElement} from 'hast-util-is-element'
82

93
/* Check if a node is a script-supporting element */
10-
function scriptSupporting(node) {
11-
return is(node, names)
12-
}
4+
export const scriptSupporting = convertElement(['script', 'template'])

package.json

+13-21
Original file line numberDiff line numberDiff line change
@@ -24,36 +24,28 @@
2424
"contributors": [
2525
"Titus Wormer <[email protected]> (https://wooorm.com)"
2626
],
27+
"sideEffects": false,
28+
"type": "module",
29+
"main": "index.js",
2730
"files": [
2831
"index.js"
2932
],
3033
"dependencies": {
31-
"hast-util-is-element": "^1.0.0"
34+
"hast-util-is-element": "^2.0.0"
3235
},
3336
"devDependencies": {
34-
"browserify": "^17.0.0",
35-
"nyc": "^15.0.0",
37+
"c8": "^7.0.0",
3638
"prettier": "^2.0.0",
3739
"remark-cli": "^9.0.0",
3840
"remark-preset-wooorm": "^8.0.0",
3941
"tape": "^5.0.0",
40-
"tinyify": "^3.0.0",
41-
"xo": "^0.38.0"
42+
"xo": "^0.39.0"
4243
},
4344
"scripts": {
4445
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
45-
"build-bundle": "browserify . -s hastUtilScriptSupporting > hast-util-script-supporting.js",
46-
"build-mangle": "browserify . -s hastUtilScriptSupporting -p tinyify > hast-util-script-supporting.min.js",
47-
"build": "npm run build-bundle && npm run build-mangle",
48-
"test-api": "node test",
49-
"test-coverage": "nyc --reporter lcov tape test.js",
50-
"test": "npm run format && npm run build && npm run test-coverage"
51-
},
52-
"nyc": {
53-
"check-coverage": true,
54-
"lines": 100,
55-
"functions": 100,
56-
"branches": 100
46+
"test-api": "node test.js",
47+
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
48+
"test": "npm run format && npm run test-coverage"
5749
},
5850
"prettier": {
5951
"tabWidth": 2,
@@ -65,10 +57,10 @@
6557
},
6658
"xo": {
6759
"prettier": true,
68-
"esnext": false,
69-
"ignores": [
70-
"hast-util-script-supporting.js"
71-
]
60+
"rules": {
61+
"no-var": "off",
62+
"prefer-arrow-callback": "off"
63+
}
7264
},
7365
"remarkConfig": {
7466
"plugins": [

readme.md

+7-1
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-script-supporting
2225
## Use
2326

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

2730
scriptSupporting({
2831
type: 'element',
@@ -40,6 +43,9 @@ scriptSupporting({
4043

4144
## API
4245

46+
This package exports the following identifiers: `scriptSupporting`.
47+
There is no default export.
48+
4349
### `scriptSupporting(node)`
4450

4551
Check if the given value is a [*script-supporting*][spec] [*element*][element].

test.js

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

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

0 commit comments

Comments
 (0)