Skip to content

Commit

Permalink
Fix autogenerated types w/ TS 5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Feb 1, 2024
1 parent 8df41b3 commit b4a6556
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"to-vfile": "^8.0.0",
"type-coverage": "^2.0.0",
"type-fest": "^4.0.0",
"typescript": "^5.0.0",
"typescript": "^5.4.0-beta",
"unified": "^11.0.0",
"unist-builder": "^4.0.0",
"unist-util-remove-position": "^5.0.0",
Expand Down
26 changes: 26 additions & 0 deletions packages/unified-lint-rule/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@
*
* Plugin ([`Plugin` from `unified`][github-unified-plugin]).
*
* ### `Label`
*
* Severity label (TypeScript type);
* `'off'`: `0`, `'on'` and `warn`: `1`, `'error'`: `2`.
*
* ###### Type
*
* ```ts
* type Label = 'error' | 'on' | 'off' | 'warn'
* ```
*
* ### `Meta`
*
* Rule metadata (TypeScript type).
Expand Down Expand Up @@ -74,8 +85,21 @@
*
* Nothing (`Promise<undefined>` or `undefined`).
*
* ### `Severity`
*
* Severity number (TypeScript type);
* `0`: `'off'`, `1`: `'on'` and `warn`, `2`: `'error'`.
*
* ###### Type
*
* ```ts
* type Severity = 0 | 1 | 2
* ```
*
* [api-label]: #label
* [api-meta]: #meta
* [api-rule]: #rule
* [api-severity]: #severity
* [api-lint-rule]: #lintrulemeta-rule
* [github-unist-node]: https://github.com/syntax-tree/unist#node
* [github-unified-plugin]: https://github.com/unifiedjs/unified#plugin
Expand All @@ -87,7 +111,9 @@
*/

/**
* @typedef {import('./lib/index.js').Label} Label
* @typedef {import('./lib/index.js').Meta} Meta
* @typedef {import('./lib/index.js').Severity} Severity
*/

/**
Expand Down
8 changes: 5 additions & 3 deletions packages/unified-lint-rule/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

/**
* @typedef {'error' | 'on' | 'off' | 'warn'} Label
* Severity label (`'off'`: `0`, `'on'`: `1`, `'error'`: `2`).
* Severity label;
* `'off'`: `0`, `'on'` and `warn`: `1`, `'error'`: `2`.
*
* @typedef Meta
* Rule metadata.
Expand All @@ -15,7 +16,8 @@
* Link to documentation (optional).
*
* @typedef {0 | 1 | 2} Severity
* Numeric severity (`0`: `'off'`, `1`: `'on'`, `2`: `'error'`).
* Severity number;
* `0`: `'off'`, `1`: `'on'` and `warn`, `2`: `'error'`.
*
* @typedef {[severity: Severity, ...parameters: Array<unknown>]} SeverityTuple
* Parsed severty and options.
Expand Down Expand Up @@ -65,7 +67,7 @@ export function lintRule(meta, rule) {
return plugin

/**
* @param {Option | [level: Label | Severity, option?: Option]} [config]
* @param {[level: Label | Severity, option?: Option] | Label | Option | Severity} [config]
* Config.
* @returns
* Transform, if on.
Expand Down
34 changes: 32 additions & 2 deletions packages/unified-lint-rule/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
* [Use](#use)
* [API](#api)
* [`lintRule(meta, rule)`](#lintrulemeta-rule)
* [`Label`](#label)
* [`Meta`](#meta)
* [`Rule`](#rule)
* [`Severity`](#severity)
* [Compatibility](#compatibility)
* [Contribute](#contribute)
* [License](#license)
Expand Down Expand Up @@ -82,8 +84,10 @@ export default remarkLintFileExtension

This package exports the identifier
[`lintRule`][api-lint-rule].
It exports the [TypeScript][typescript] type
[`Meta`][api-meta].
It exports the [TypeScript][typescript] types
[`Label`][api-label],
[`Meta`][api-meta], and
[`Severity`][api-severity].
There is no default export.

### `lintRule(meta, rule)`
Expand All @@ -101,6 +105,17 @@ Create a plugin.

Plugin ([`Plugin` from `unified`][github-unified-plugin]).

### `Label`

Severity label (TypeScript type);
`'off'`: `0`, `'on'` and `warn`: `1`, `'error'`: `2`.

###### Type

```ts
type Label = 'error' | 'on' | 'off' | 'warn'
```
### `Meta`
Rule metadata (TypeScript type).
Expand Down Expand Up @@ -129,6 +144,17 @@ Rule (TypeScript type).
Nothing (`Promise<undefined>` or `undefined`).
### `Severity`
Severity number (TypeScript type);
`0`: `'off'`, `1`: `'on'` and `warn`, `2`: `'error'`.
###### Type
```ts
type Severity = 0 | 1 | 2
```
## Compatibility
Projects maintained by the unified collective are compatible with maintained
Expand All @@ -154,12 +180,16 @@ abide by its terms.
[MIT][file-license] © [Titus Wormer][author]
[api-label]: #label
[api-lint-rule]: #lintrulemeta-rule
[api-meta]: #meta
[api-rule]: #rule
[api-severity]: #severity
[author]: https://wooorm.com
[badge-build-image]: https://github.com/remarkjs/remark-lint/workflows/main/badge.svg
Expand Down

0 comments on commit b4a6556

Please sign in to comment.