unified-lint-rule
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -34,2 +34,2 @@ import type {Node} from 'unist' | ||
export type {Severity, Label} | ||
export {Severity, Label} from './lib/index.js' |
@@ -21,3 +21,3 @@ /** | ||
export type Label = 'warn' | 'on' | 'off' | 'error' | ||
export type SeverityTuple = [Severity, ...unknown[]] | ||
export type SeverityTuple = [Severity, ...Array<unknown>] | ||
export type RuleMeta = { | ||
@@ -24,0 +24,0 @@ /** |
@@ -7,3 +7,3 @@ /** | ||
* @typedef {'warn'|'on'|'off'|'error'} Label | ||
* @typedef {[Severity, ...unknown[]]} SeverityTuple | ||
* @typedef {[Severity, ...Array<unknown>]} SeverityTuple | ||
* | ||
@@ -42,3 +42,3 @@ * @typedef RuleMeta | ||
/** @type {import('unified').Plugin<[unknown]|void[]>} */ | ||
/** @type {import('unified').Plugin<[unknown]|Array<void>>} */ | ||
function plugin(raw) { | ||
@@ -85,3 +85,3 @@ const [severity, options] = coerce(ruleId, raw) | ||
function coerce(name, value) { | ||
/** @type {unknown[]} */ | ||
/** @type {Array<unknown>} */ | ||
let result | ||
@@ -95,7 +95,7 @@ | ||
Array.isArray(value) && | ||
// `isArray(unknown)` is turned into `any[]`: | ||
// `isArray(unknown)` is turned into `Array<any>`: | ||
// type-coverage:ignore-next-line | ||
primitives.has(typeof value[0]) | ||
) { | ||
// `isArray(unknown)` is turned into `any[]`: | ||
// `isArray(unknown)` is turned into `Array<any>`: | ||
// type-coverage:ignore-next-line | ||
@@ -102,0 +102,0 @@ result = [...value] |
{ | ||
"name": "unified-lint-rule", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "unified plugin to make it a bit easier to create linting rules", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -11,13 +11,36 @@ # unified-lint-rule | ||
[**unified**][unified] plugin to make it a bit easier to create linting rules. | ||
**[unified][]** plugin to help make lint rules. | ||
Each rule in [`remark-lint`][lint] uses this project, so see that for examples! | ||
See the [monorepo readme][mono] for more info on remark lint. | ||
## Contents | ||
* [What is this?](#what-is-this) | ||
* [When should I use this?](#when-should-i-use-this) | ||
* [Install](#install) | ||
* [Use](#use) | ||
* [API](#api) | ||
* [`lintRule(origin|meta, rule)`](#lintruleoriginmeta-rule) | ||
* [Compatibility](#compatibility) | ||
* [Contribute](#contribute) | ||
* [License](#license) | ||
## What is this? | ||
This package is a [unified][] plugin that makes it a bit easier to create | ||
linting rules. | ||
**unified** is a project that transforms content with abstract syntax trees | ||
(ASTs). | ||
This is a plugin that make it easier to inspect trees. | ||
## When should I use this? | ||
You can use this package when you want to make custom lint rules. | ||
## Install | ||
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c): | ||
Node 12+ is needed to use it and it must be `import`ed instead of `require`d. | ||
This package is [ESM only][esm]. | ||
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]: | ||
[npm][]: | ||
```sh | ||
@@ -27,2 +50,16 @@ npm install unified-lint-rule | ||
In Deno with [Skypack][]: | ||
```js | ||
import {lintRule} from 'https://cdn.skypack.dev/unified-lint-rule@2?dts' | ||
``` | ||
In browsers with [Skypack][]: | ||
```html | ||
<script type="module"> | ||
import {lintRule} from 'https://cdn.skypack.dev/unified-lint-rule@2?min' | ||
</script> | ||
``` | ||
## Use | ||
@@ -47,2 +84,38 @@ | ||
## API | ||
This package exports the following identifier: `lintRule`. | ||
There is no default export. | ||
### `lintRule(origin|meta, rule)` | ||
Create a plugin. | ||
###### Parameters | ||
* `origin` (`string`) | ||
— treated as a `meta` of `{origin}` | ||
* `meta` (`Object`) | ||
— rule metadata | ||
* `meta.origin` (`string`) | ||
— message origin, either a rule name (`'file-extension'`) or both | ||
a rule source and name joined with `:` (`'remark-lint:file-extension'`) | ||
* `meta.url` (`string`, optional) | ||
— URL to documentation for messages | ||
* `rule` (`Function`, optional) | ||
— your code, like a transform function, except that an extra `option` is | ||
passed | ||
###### Returns | ||
A unified plugin that handles all kinds of options (see [Configure][configure] | ||
in the monorepo readme for how them). | ||
## Compatibility | ||
Projects maintained by the unified collective are compatible with all maintained | ||
versions of Node.js. | ||
As of now, that is Node.js 12.20+, 14.14+, and 16.0+. | ||
Our projects sometimes work with older versions, but this is not guaranteed. | ||
## Contribute | ||
@@ -88,2 +161,6 @@ | ||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c | ||
[skypack]: https://www.skypack.dev | ||
[npm]: https://docs.npmjs.com/cli/install | ||
@@ -93,7 +170,7 @@ | ||
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md | ||
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md | ||
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md | ||
[support]: https://github.com/remarkjs/.github/blob/main/support.md | ||
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md | ||
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md | ||
@@ -106,2 +183,4 @@ [license]: https://github.com/remarkjs/remark-lint/blob/main/license | ||
[lint]: https://github.com/remarkjs/remark-lint | ||
[mono]: https://github.com/remarkjs/remark-lint | ||
[configure]: https://github.com/remarkjs/remark-lint#configure |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10818
181