Skip to content

Commit 411f616

Browse files
committed
Refactor types
1 parent 805fe10 commit 411f616

File tree

17 files changed

+35
-35
lines changed

17 files changed

+35
-35
lines changed

packages/remark-lint-fenced-code-flag/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @fileoverview
77
* Check fenced code block flags.
88
*
9-
* Options: `Array.<string>` or `Object`, optional.
9+
* Options: `Array<string>` or `Object`, optional.
1010
*
1111
* Providing an array is as passing `{flags: Array}`.
1212
*
@@ -83,7 +83,7 @@
8383
/**
8484
* @typedef {import('mdast').Root} Root
8585
*
86-
* @typedef {string[]} Flags
86+
* @typedef {Array<string>} Flags
8787
*
8888
* @typedef FlagMap
8989
* @property {Flags} [flags]
@@ -108,7 +108,7 @@ const remarkLintFencedCodeFlag = lintRule(
108108
(tree, file, option) => {
109109
const value = String(file)
110110
let allowEmpty = false
111-
/** @type {string[]} */
111+
/** @type {Array<string>} */
112112
let allowed = []
113113

114114
if (typeof option === 'object') {

packages/remark-lint-fenced-code-flag/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
Check fenced code block flags.
1414

15-
Options: `Array.<string>` or `Object`, optional.
15+
Options: `Array<string>` or `Object`, optional.
1616

1717
Providing an array is as passing `{flags: Array}`.
1818

packages/remark-lint-no-duplicate-headings-in-section/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const remarkLintNoDuplicateHeadingsInSection = lintRule(
7878
},
7979
/** @type {import('unified-lint-rule').Rule<Root, void>} */
8080
(tree, file) => {
81-
/** @type {Array.<Record<string, Heading>>} */
81+
/** @type {Array<Record<string, Heading>>} */
8282
let stack = []
8383

8484
visit(tree, 'heading', (node) => {

packages/remark-lint-no-reference-like-url/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const remarkLintNoReferenceLikeUrl = lintRule(
4141
},
4242
/** @type {import('unified-lint-rule').Rule<Root, void>} */
4343
(tree, file) => {
44-
/** @type {string[]} */
44+
/** @type {Array<string>} */
4545
const identifiers = []
4646

4747
visit(tree, 'definition', (node) => {

packages/remark-lint-no-undefined-references/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@
7272
* @typedef {import('mdast').Paragraph} Paragraph
7373
*
7474
* @typedef Options
75-
* @property {string[]} [allow]
75+
* @property {Array<string>} [allow]
7676
*
77-
* @typedef {number[]} Range
77+
* @typedef {Array<number>} Range
7878
*/
7979

8080
import {normalizeIdentifier} from 'micromark-util-normalize-identifier'
@@ -133,7 +133,7 @@ const remarkLintNoUndefinedReferences = lintRule(
133133
* @param {Heading|Paragraph} node
134134
*/
135135
function findInPhrasing(node) {
136-
/** @type {Range[]} */
136+
/** @type {Array<Range>} */
137137
let ranges = []
138138

139139
visit(node, (child) => {
@@ -158,7 +158,7 @@ const remarkLintNoUndefinedReferences = lintRule(
158158
}
159159

160160
const source = contents.slice(start, end)
161-
/** @type {Array.<[number, string]>} */
161+
/** @type {Array<[number, string]>} */
162162
const lines = [[start, '']]
163163
let last = 0
164164

packages/remark-lint-table-cell-padding/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ const remarkLintTableCellPadding = lintRule(
212212
// To do: fix types to always have `align` defined.
213213
/* c8 ignore next */
214214
const align = node.align || []
215-
/** @type {number[]} */
215+
/** @type {Array<number>} */
216216
const sizes = []
217-
/** @type {Entry[]} */
217+
/** @type {Array<Entry>} */
218218
const entries = []
219219
let index = -1
220220

@@ -294,7 +294,7 @@ const remarkLintTableCellPadding = lintRule(
294294
* @param {'start'|'end'} side
295295
* @param {Entry} entry
296296
* @param {0|1} style
297-
* @param {number[]} sizes
297+
* @param {Array<number>} sizes
298298
*/
299299
function checkSide(side, entry, style, sizes) {
300300
const cell = entry.node

packages/remark-lint-table-pipe-alignment/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const remarkLintTablePipeAlignment = lintRule(
6666
const value = String(file)
6767

6868
visit(tree, 'table', (node) => {
69-
/** @type {number[]} */
69+
/** @type {Array<number>} */
7070
const indices = []
7171
let index = -1
7272

packages/remark-lint/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import remarkMessageControl from 'remark-message-control'
99
* This adds support for ignoring stuff from messages (`<!--lint ignore-->`).
1010
* All rules are in their own packages and presets.
1111
*
12-
* @type {import('unified').Plugin<void[], Root>}
12+
* @type {import('unified').Plugin<Array<void>, Root>}
1313
*/
1414
export default function remarkLint() {
1515
this.use(lintMessageControl)
1616
}
1717

18-
/** @type {import('unified').Plugin<void[], Root>} */
18+
/** @type {import('unified').Plugin<Array<void>, Root>} */
1919
function lintMessageControl() {
2020
return remarkMessageControl({name: 'lint', source: 'remark-lint'})
2121
}

packages/unified-lint-rule/lib/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @typedef {0|1|2} Severity
66
* @typedef {'warn'|'on'|'off'|'error'} Label
7-
* @typedef {[Severity, ...unknown[]]} SeverityTuple
7+
* @typedef {[Severity, ...Array<unknown>]} SeverityTuple
88
*
99
* @typedef RuleMeta
1010
* @property {string} origin name of the lint rule
@@ -38,7 +38,7 @@ export function lintRule(meta, rule) {
3838

3939
return plugin
4040

41-
/** @type {import('unified').Plugin<[unknown]|void[]>} */
41+
/** @type {import('unified').Plugin<[unknown]|Array<void>>} */
4242
function plugin(raw) {
4343
const [severity, options] = coerce(ruleId, raw)
4444

@@ -80,7 +80,7 @@ export function lintRule(meta, rule) {
8080
* @returns {SeverityTuple}
8181
*/
8282
function coerce(name, value) {
83-
/** @type {unknown[]} */
83+
/** @type {Array<unknown>} */
8484
let result
8585

8686
if (typeof value === 'boolean') {
@@ -89,11 +89,11 @@ function coerce(name, value) {
8989
result = [1]
9090
} else if (
9191
Array.isArray(value) &&
92-
// `isArray(unknown)` is turned into `any[]`:
92+
// `isArray(unknown)` is turned into `Array<any>`:
9393
// type-coverage:ignore-next-line
9494
primitives.has(typeof value[0])
9595
) {
96-
// `isArray(unknown)` is turned into `any[]`:
96+
// `isArray(unknown)` is turned into `Array<any>`:
9797
// type-coverage:ignore-next-line
9898
result = [...value]
9999
} else {

script/build-presets.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ presets(root).then((presetObjects) => {
6464
)
6565
}
6666

67-
/** @type {TableContent[]} */
67+
/** @type {Array<TableContent>} */
6868
const rows = []
6969

7070
rows.push({
@@ -110,11 +110,11 @@ presets(root).then((presetObjects) => {
110110
}
111111
}
112112

113-
/** @type {BlockContent[]} */
113+
/** @type {Array<BlockContent>} */
114114
// @ts-expect-error: fine.
115115
const descriptionContent = remark().parse(description).children
116116

117-
/** @type {BlockContent[]} */
117+
/** @type {Array<BlockContent>} */
118118
const children = [
119119
{type: 'html', value: '<!--This file is generated-->'},
120120
{

0 commit comments

Comments
 (0)