Skip to content

Commit

Permalink
Use ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Apr 26, 2021
1 parent cb10bc0 commit 3462a19
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 36 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/
hast-util-heading.js
hast-util-heading.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/
*.json
*.md
hast-util-heading.js
hast-util-heading.min.js
14 changes: 10 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
"use strict"
import {convertElement} from "hast-util-is-element"

var convert = require('hast-util-is-element/convert')

module.exports = convert(['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hgroup'])
export const heading = convertElement([
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'hgroup'
])
34 changes: 13 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,28 @@
"contributors": [
"Titus Wormer <[email protected]> (https://wooorm.com)"
],
"sideEffects": false,
"type": "module",
"main": "index.js",
"files": [
"index.js"
],
"dependencies": {
"hast-util-is-element": "^1.1.0"
"hast-util-is-element": "^2.0.0"
},
"devDependencies": {
"browserify": "^17.0.0",
"nyc": "^15.0.0",
"c8": "^7.0.0",
"prettier": "^2.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"tape": "^5.0.0",
"tinyify": "^3.0.0",
"xo": "^0.38.0"
"xo": "^0.39.0"
},
"scripts": {
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"build-bundle": "browserify . -s hastUtilHeading -o hast-util-heading.js",
"build-mangle": "browserify . -s hastUtilHeading -o hast-util-heading.min.js -p tinyify",
"build": "npm run build-bundle && npm run build-mangle",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test": "npm run format && npm run build && npm run test-coverage"
"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 @@ -58,16 +56,10 @@
},
"xo": {
"prettier": true,
"esnext": false,
"ignores": [
"hast-util-heading.js"
]
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
"rules": {
"no-var": "off",
"prefer-arrow-callback": "off"
}
},
"remarkConfig": {
"plugins": [
Expand Down
8 changes: 7 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,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 @@ -22,7 +25,7 @@ npm install hast-util-heading
## Use

```js
var heading = require("hast-util-heading")
import {heading} from "hast-util-heading"

// Given a non-heading value:
heading({
Expand All @@ -42,6 +45,9 @@ heading({

## API

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

### `heading(node)`

Check if the given value is a [*heading*][spec] [*element*][element].
Expand Down
6 changes: 2 additions & 4 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict'

var test = require('tape')
var heading = require('.')
import test from 'tape'
import {heading} from './index.js'

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

0 comments on commit 3462a19

Please sign in to comment.