Skip to content

Commit 3991a2e

Browse files
committed
Use strict types
1 parent 9acb01b commit 3991a2e

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

build.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import assert from 'node:assert'
12
import fs from 'node:fs'
23
import https from 'node:https'
34
import concatStream from 'concat-stream'
@@ -15,6 +16,7 @@ https.get('https://html.spec.whatwg.org/multipage/syntax.html', (response) => {
1516
.pipe(
1617
concatStream((buf) => {
1718
const dd = select('#elements-2 ~ dl dd', processor.parse(buf))
19+
assert(dd, 'expected a `dd`')
1820
const nodes = selectAll('code', dd)
1921
let index = -1
2022

@@ -28,9 +30,16 @@ https.get('https://html.spec.whatwg.org/multipage/syntax.html', (response) => {
2830

2931
fs.writeFile(
3032
'index.js',
31-
'export const htmlVoidElements = ' +
32-
JSON.stringify(htmlVoidElements.sort(), null, 2) +
33-
'\n',
33+
[
34+
'/**',
35+
' * List of HTML void tag names.',
36+
' *',
37+
' * @type {Array<string>}',
38+
' */',
39+
'export const htmlVoidElements = ' +
40+
JSON.stringify(htmlVoidElements.sort(), null, 2),
41+
''
42+
].join('\n'),
3443
bail
3544
)
3645
})

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* List of HTML void tag names.
3+
*
4+
* @type {Array<string>}
5+
*/
16
export const htmlVoidElements = [
27
'area',
38
'base',

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "html-void-elements",
33
"version": "2.0.0",
4-
"description": "List of known void HTML elements",
4+
"description": "List of HTML void tag names",
55
"license": "MIT",
66
"keywords": [
77
"html",
@@ -52,13 +52,13 @@
5252
"xo": "^0.46.0"
5353
},
5454
"scripts": {
55-
"prepack": "npm run build && npm run format",
56-
"build": "rimraf \"*.d.ts\" && tsc && type-coverage",
5755
"generate": "node build",
56+
"prepublishOnly": "npm run build && npm run format",
57+
"build": "rimraf \"*.d.ts\" && tsc && type-coverage",
5858
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
59-
"test-api": "node test.js",
60-
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
61-
"test": "npm run build && npm run format && npm run test-coverage"
59+
"test-api": "node --conditions development test.js",
60+
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov npm run test-api",
61+
"test": "npm run generate && npm run build && npm run format && npm run test-coverage"
6262
},
6363
"prettier": {
6464
"tabWidth": 2,
@@ -79,6 +79,7 @@
7979
"typeCoverage": {
8080
"atLeast": 100,
8181
"detail": true,
82-
"strict": true
82+
"strict": true,
83+
"ignoreCatch": true
8384
}
8485
}

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Downloads][downloads-badge]][downloads]
66
[![Size][size-badge]][size]
77

8-
List of known void HTML elements.
8+
List of HTML void tag names.
99
Includes ancient (such as `nextid` and `basefont`) and modern (such as `img` and
1010
`meta`) tag names from the HTML living standard.
1111

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"files": ["index.js"],
32
"include": ["*.js"],
43
"compilerOptions": {
54
"target": "ES2020",
@@ -11,6 +10,7 @@
1110
"declaration": true,
1211
"emitDeclarationOnly": true,
1312
"allowSyntheticDefaultImports": true,
14-
"skipLibCheck": true
13+
"skipLibCheck": true,
14+
"strict": true
1515
}
1616
}

0 commit comments

Comments
 (0)