Skip to content

Commit e70ba2a

Browse files
committed
Refactor code-style
1 parent dd64740 commit e70ba2a

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

lib/core.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
*
1010
* @typedef {Root|Element} HResult
1111
* @typedef {string|number} HStyleValue
12-
* @typedef {Object.<string, HStyleValue>} HStyle
12+
* @typedef {Record<string, HStyleValue>} HStyle
1313
* @typedef {string|number|boolean|null|undefined} HPrimitiveValue
14-
* @typedef {Array.<string|number>} HArrayValue
14+
* @typedef {Array<string|number>} HArrayValue
1515
* @typedef {HPrimitiveValue|HArrayValue} HPropertyValue
1616
* @typedef {{[property: string]: HPropertyValue|HStyle}} HProperties
1717
*
1818
* @typedef {string|number|null|undefined} HPrimitiveChild
19-
* @typedef {Array.<Node|HPrimitiveChild>} HArrayChild
19+
* @typedef {Array<Node|HPrimitiveChild>} HArrayChild
2020
* @typedef {Node|HPrimitiveChild|HArrayChild} HChild
2121
*/
2222

@@ -32,7 +32,7 @@ const own = {}.hasOwnProperty
3232
/**
3333
* @param {Schema} schema
3434
* @param {string} defaultTagName
35-
* @param {Array.<string>} [caseSensitive]
35+
* @param {Array<string>} [caseSensitive]
3636
*/
3737
export function core(schema, defaultTagName, caseSensitive) {
3838
const adjust = caseSensitive && createAdjustMap(caseSensitive)
@@ -41,9 +41,9 @@ export function core(schema, defaultTagName, caseSensitive) {
4141
/**
4242
* @type {{
4343
* (): Root
44-
* (selector: null|undefined, ...children: HChild[]): Root
45-
* (selector: string, properties?: HProperties, ...children: HChild[]): Element
46-
* (selector: string, ...children: HChild[]): Element
44+
* (selector: null|undefined, ...children: Array<HChild>): Root
45+
* (selector: string, properties?: HProperties, ...children: Array<HChild>): Element
46+
* (selector: string, ...children: Array<HChild>): Element
4747
* }}
4848
*/
4949
(
@@ -52,7 +52,7 @@ export function core(schema, defaultTagName, caseSensitive) {
5252
*
5353
* @param {string|null} [selector]
5454
* @param {HProperties|HChild} [properties]
55-
* @param {HChild[]} children
55+
* @param {Array<HChild>} children
5656
* @returns {HResult}
5757
*/
5858
function (selector, properties, ...children) {
@@ -179,7 +179,7 @@ function addProperty(schema, properties, key, value) {
179179
}
180180

181181
if (Array.isArray(result)) {
182-
/** @type {Array.<string|number>} */
182+
/** @type {Array<string|number>} */
183183
const finalResult = []
184184

185185
while (++index < result.length) {
@@ -200,7 +200,7 @@ function addProperty(schema, properties, key, value) {
200200
}
201201

202202
/**
203-
* @param {Array.<Child>} nodes
203+
* @param {Array<Child>} nodes
204204
* @param {HChild} value
205205
* @returns {void}
206206
*/
@@ -256,7 +256,7 @@ function parsePrimitive(info, name, value) {
256256
* @returns {string}
257257
*/
258258
function style(value) {
259-
/** @type {Array.<string>} */
259+
/** @type {Array<string>} */
260260
const result = []
261261
/** @type {string} */
262262
let key
@@ -271,11 +271,11 @@ function style(value) {
271271
}
272272

273273
/**
274-
* @param {Array.<string>} values
275-
* @returns {Object.<string, string>}
274+
* @param {Array<string>} values
275+
* @returns {Record<string, string>}
276276
*/
277277
function createAdjustMap(values) {
278-
/** @type {Object.<string, string>} */
278+
/** @type {Record<string, string>} */
279279
const result = {}
280280
let index = -1
281281

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@
8888
"build": "rimraf \"{script/**,test/**,}*.d.ts\" \"lib/{core,html,index,runtime-html,runtime-svg,runtime,svg-case-sensitive-tag-names,svg}.d.ts\" && tsc && tsd && type-coverage",
8989
"generate": "node script/generate-jsx && node script/build",
9090
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
91-
"test-api": "node test/index.js",
92-
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test/index.js",
91+
"test-api": "node --conditions development test/index.js",
92+
"test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api",
9393
"test": "npm run build && npm run generate && npm run format && npm run test-coverage"
9494
},
9595
"prettier": {

readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,14 @@ When nullish, builds a [`Root`][root] instead.
171171

172172
###### `properties`
173173

174-
Map of properties (`Object.<*>`, optional).
174+
Map of properties (`Record<string, any>`, optional).
175175
Keys should match either the HTML attribute name, or the DOM property name, but
176176
are case-insensitive.
177177
Cannot be given when building a [`Root`][root].
178178

179179
###### `children`
180180

181-
(Lists of) children (`string`, `number`, `Node`, `Array.<children>`, optional).
181+
(Lists of) children (`string`, `number`, `Node`, `Array<children>`, optional).
182182
When strings or numbers are encountered, they are mapped to [`Text`][text]
183183
nodes.
184184
If [`Root`][root] nodes are given, their children are used instead.

test/core.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ test('hastscript', (t) => {
776776
{type: 'text', value: 'bar'}
777777
]
778778
},
779-
'should support `Array.<string>` for a `Text`s'
779+
'should support `Array<string>` for a `Text`s'
780780
)
781781

782782
t.deepEqual(

0 commit comments

Comments
 (0)