Skip to content

Commit

Permalink
Update dev-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Nov 1, 2021
1 parent b1b4044 commit 380344b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 43 deletions.
46 changes: 19 additions & 27 deletions build.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import fs from 'fs'
import https from 'https'
import concat from 'concat-stream'
import fs from 'node:fs'
import https from 'node:https'
import concatStream from 'concat-stream'
import {bail} from 'bail'
import unified from 'unified'
import html from 'rehype-parse'
// @ts-ignore
import select from 'hast-util-select'
// @ts-ignore
import toString from 'hast-util-to-string'
import {unified} from 'unified'
import rehypeParse from 'rehype-parse'
import {selectAll} from 'hast-util-select'
import {toString} from 'hast-util-to-string'
import {htmlTagNames} from './index.js'

var proc = unified().use(html)
const proc = unified().use(rehypeParse)

var count = 0
let count = 0

// Crawl W3C.
https.get('https://w3c.github.io/elements-of-html/', onw3c)
Expand All @@ -24,19 +22,17 @@ https.get('https://html.spec.whatwg.org/multipage/indices.html', onwhatwg)
* @param {import('http').IncomingMessage} response
*/
function onw3c(response) {
response.pipe(concat(onconcat)).on('error', bail)
response.pipe(concatStream(onconcat)).on('error', bail)

/**
* @param {Buffer} buf
*/
function onconcat(buf) {
var nodes = select.selectAll('[scope="row"] code', proc.parse(buf))
var index = -1
/** @type {string} */
var data
const nodes = selectAll('[scope="row"] code', proc.parse(buf))
let index = -1

while (++index < nodes.length) {
data = toString(nodes[index])
const data = toString(nodes[index])

if (data && !/\s/.test(data) && !htmlTagNames.includes(data)) {
htmlTagNames.push(data)
Expand All @@ -51,22 +47,18 @@ function onw3c(response) {
* @param {import('http').IncomingMessage} response
*/
function onwhatwg(response) {
response.pipe(concat(onconcat)).on('error', bail)
response.pipe(concatStream(onconcat)).on('error', bail)

/**
* @param {Buffer} buf
*/
function onconcat(buf) {
var nodes = select.selectAll('tbody th code', proc.parse(buf))
var index = -1
/** @type {string?} */
var id
/** @type {string} */
var data
const nodes = selectAll('tbody th code', proc.parse(buf))
let index = -1

while (++index < nodes.length) {
id = nodes[index].properties.id
data = toString(nodes[index])
const id = String(nodes[index].properties.id || '')
const data = toString(nodes[index])

if (
id &&
Expand All @@ -87,7 +79,7 @@ function done() {
if (count === 2) {
fs.writeFile(
'index.js',
'export var htmlTagNames = ' +
'export const htmlTagNames = ' +
JSON.stringify(htmlTagNames.sort(), null, 2) +
'\n',
bail
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export var htmlTagNames = [
export const htmlTagNames = [
'a',
'abbr',
'acronym',
Expand Down
23 changes: 9 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@
],
"devDependencies": {
"@types/concat-stream": "^1.0.0",
"@types/node": "^14.0.0",
"@types/node": "^16.0.0",
"@types/tape": "^4.0.0",
"bail": "^2.0.0",
"c8": "^7.0.0",
"concat-stream": "^2.0.0",
"hast-util-select": "^4.0.0",
"hast-util-to-string": "^1.0.0",
"hast-util-select": "^5.0.0",
"hast-util-to-string": "^2.0.0",
"prettier": "^2.0.0",
"rehype-parse": "^7.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"rehype-parse": "^8.0.0",
"remark-cli": "^10.0.0",
"remark-preset-wooorm": "^9.0.0",
"rimraf": "^3.0.0",
"tape": "^5.0.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"unified": "^9.0.0",
"xo": "^0.38.0"
"unified": "^10.0.0",
"xo": "^0.46.0"
},
"scripts": {
"prepack": "npm run build && npm run format",
Expand All @@ -69,12 +69,7 @@
"trailingComma": "none"
},
"xo": {
"prettier": true,
"rules": {
"import/no-mutable-exports": "off",
"no-var": "off",
"prefer-arrow-callback": "off"
}
"prettier": true
},
"remarkConfig": {
"plugins": [
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from 'tape'
import {htmlTagNames} from './index.js'

test('htmlTagNames', function (t) {
var index = -1
let index = -1

t.ok(Array.isArray(htmlTagNames), 'should be an `array`')

Expand Down

0 comments on commit 380344b

Please sign in to comment.