Skip to content

Commit

Permalink
Use ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jul 6, 2021
1 parent a363173 commit d561be3
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 101 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/
unified-message-control.js
unified-message-control.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/
unified-message-control.js
unified-message-control.min.js
*.json
*.md
12 changes: 4 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
'use strict'
import location from 'vfile-location'
import visit from 'unist-util-visit'

var location = require('vfile-location')
var visit = require('unist-util-visit')

module.exports = messageControl

function messageControl(options) {
export function messageControl(options) {
var settings = options || {}
var enable = settings.enable || []
var disable = settings.disable || []
Expand Down Expand Up @@ -173,7 +169,7 @@ function messageControl(options) {
previousState = getState(ruleId)

if (state !== previousState) {
markers.push({state: state, position: pos})
markers.push({state, position: pos})
}

// Toggle all known rules.
Expand Down
37 changes: 15 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@
"Christian Murphy <christian.murphy.42@gmail.com> (https://github.com/ChristianMurphy)",
"Thomas 'zemnmez' Shadwell (https://github.com/zemnmez)"
],
"sideEffects": false,
"type": "module",
"main": "index.js",
"types": "index.d.ts",
"files": [
"index.js",
"index.d.ts"
"index.d.ts",
"index.js"
],
"dependencies": {
"unist-util-visit": "^2.0.0",
Expand All @@ -35,36 +39,24 @@
"@types/hast": "^2.0.0",
"@types/mdast": "^3.0.0",
"@types/unist": "^2.0.0",
"browserify": "^17.0.0",
"dtslint": "^4.0.0",
"c8": "^7.0.0",
"mdast-comment-marker": "^1.0.0",
"nyc": "^15.0.0",
"prettier": "^2.0.0",
"remark": "^13.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"remark-toc": "^7.0.0",
"tape": "^5.0.0",
"tinyify": "^3.0.0",
"unified": "^9.0.0",
"unist-util-is": "^4.0.0",
"xo": "^0.38.0"
"xo": "^0.39.0"
},
"scripts": {
"format": "remark . -qfo && prettier . --write && xo --fix",
"build-bundle": "browserify index.js -s unifiedMessageControl -o unified-message-control.js",
"build-mangle": "browserify index.js -s unifiedMessageControl -p tinyify -o unified-message-control.min.js",
"build": "npm run build-bundle && npm run build-mangle",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test-types": "dtslint",
"test": "npm run test-types && npm run format && npm run build && npm run test-coverage"
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"test-api": "node --conditions development test.js",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node --conditions development test.js",
"xxx-test-types": "dtslint",
"test": "npm run format && npm run test-coverage"
},
"prettier": {
"tabWidth": 2,
Expand All @@ -76,8 +68,9 @@
},
"xo": {
"prettier": true,
"esnext": false,
"rules": {
"no-var": "off",
"prefer-arrow-callback": "off",
"guard-for-in": "off",
"unicorn/explicit-length-check": "off",
"unicorn/no-array-callback-reference": "off",
Expand Down
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Enable, disable, and ignore messages with [**unified**][unified].

## 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 Down Expand Up @@ -59,6 +62,9 @@ example.md: no issues found

## API

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

### `unified.use(control, options)`

Let comment markers control messages from certain sources.
Expand Down

0 comments on commit d561be3

Please sign in to comment.