3.0.0 • Published 18 days ago

unified-lint-rule v3.0.0

Weekly downloads
75,135
License
MIT
Repository
github
Last release
18 days ago

unified-lint-rule

Build Coverage Downloads Size Sponsors Backers Chat

unified helper to help make lint rules.

Contents

What is this?

This package is a helper that makes it a bit easier to create linting rules.

When should I use this?

You can use this package when you want to make custom lint rules.

Install

This package is ESM only. In Node.js (version 16+), install with npm:

npm install unified-lint-rule

In Deno with esm.sh:

import {lintRule} from 'https://esm.sh/unified-lint-rule@3'

In browsers with esm.sh:

<script type="module">
  import {lintRule} from 'https://esm.sh/unified-lint-rule@3?bundle'
</script>

Use

import {lintRule} from 'unified-lint-rule'

const remarkLintFileExtension = lintRule(
  'remark-lint:file-extension',
  function (tree, file, options) {
    const ext = file.extname
    const option = options || 'md'

    if (ext && ext.slice(1) !== option) {
      file.message('Incorrect extension: use `' + option + '`')
    }
  }
)

export default remarkLintFileExtension

API

This package exports the identifier lintRule. It exports the TypeScript types Label, Meta, and Severity. There is no default export.

lintRule(meta, rule)

Create a plugin.

Parameters
  • meta (Meta or string) — info or origin
  • rule (Rule) — rule
Returns

Plugin (Plugin from unified).

Label

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

Type
type Label = 'error' | 'on' | 'off' | 'warn'

Meta

Rule metadata (TypeScript type).

Fields
  • origin (string) — name of the lint rule
  • url (string, optional) — link to documentation

Rule

Rule (TypeScript type).

Parameters
Returns

Nothing (Promise<undefined> or undefined).

Severity

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

Type
type Severity = 0 | 1 | 2

Compatibility

Projects maintained by the unified collective are compatible with maintained versions of Node.js.

When we cut a new major release, we drop support for unmaintained versions of Node. This means we try to keep the current release line, unified-lint-rule@3, compatible with Node.js 16.

Contribute

See contributing.md in remarkjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer

@mapbox/remark-lint-mapbox@everything-registry/sub-chunk-3012@freeletics/remark-lint-blank-linesunified-latexunist-util-to-string-with-nodes@heroku/remark-heroku-bash-dollar@heroku/remark-heroku-command-headings-inline-code@hashicorp/platform-content-conformanceremark-frontmatter-validatorremark-lint-emphasis-markerremark-lint-fenced-code-flagremark-lint-fenced-code-flag-caseremark-lint-fenced-code-markerremark-lint-file-extensionremark-lint-final-definitionremark-lint-final-newlineremark-lint-first-heading-levelremark-lint-frontmatter-schemaremark-lint-haikuremark-lint-hard-break-spacesremark-lint-heading-capitalizationremark-lint-heading-caseremark-lint-write-goodremark-lint-no-mixed-case-url-hashremark-lint-no-multiple-toplevel-headingsremark-lint-no-paragraph-content-indentremark-lint-no-reference-like-urlremark-lint-no-repeat-punctuationremark-lint-no-shell-dollarsremark-lint-no-shortcut-reference-imageremark-lint-no-shortcut-reference-linkremark-lint-no-table-indentationremark-lint-no-tabsremark-lint-no-trailing-spacesremark-lint-no-undefined-referencesremark-lint-no-unneeded-full-reference-imageremark-lint-no-unneeded-full-reference-linkremark-lint-no-heading-content-indentremark-lint-no-heading-indentremark-lint-no-heading-like-paragraphremark-lint-no-heading-punctuationremark-lint-no-hr-after-headingremark-lint-no-htmlremark-lint-no-inline-paddingremark-lint-no-literal-urlsremark-lint-no-long-coderemark-lint-no-missing-blank-linesremark-lint-heading-incrementremark-lint-heading-lengthremark-lint-heading-styleremark-lint-heading-whitespaceremark-lint-heading-word-lengthremark-lint-hiring-without-whiteboards-linksremark-lint-linebreak-styleremark-lint-link-title-styleremark-lint-list-item-bullet-indentremark-lint-list-item-content-indentremark-lint-list-item-indentremark-lint-list-item-spacingremark-lint-list-item-styleremark-lint-match-punctuationremark-lint-maximum-heading-lengthremark-lint-maximum-line-lengthremark-lint-mdash-styleremark-lint-no-unused-definitionsremark-lint-no-url-trailing-slashremark-lint-ordered-list-marker-styleremark-lint-ordered-list-marker-valueremark-lint-prohibited-stringsremark-lint-relative-markdown-file-path-linksremark-lint-rule-styleremark-lint-smarty-pants-typographyremark-lint-spaces-around-numberremark-lint-spaces-around-wordremark-lint-strikethrough-markerremark-lint-strong-markerremark-lint-table-cell-paddingremark-lint-table-pipe-alignmentremark-lint-table-pipesremark-lint-unordered-list-marker-styleremark-preset-lint-noderemark-preset-lint-origami-componentremark-lint-are-links-valid-coreremark-lint-blank-lines-1-0-2remark-lint-blockquote-indentationremark-lint-books-linksremark-lint-check-tocremark-lint-checkbox-character-styleremark-lint-checkbox-content-indentremark-lint-coderemark-lint-code-block-styleremark-lint-code-block-syntaxremark-lint-definition-caseremark-lint-definition-spacingremark-lint-docusaurus-empty-lines-around-admonition-contentremark-lint-double-linkremark-lint-emoji-limitremark-lint-alphabetize-listsremark-lint-appropriate-headingremark-lint-no-auto-link-without-protocol
3.0.0

18 days ago

2.1.2

12 months ago

2.1.1

2 years ago

2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

5 years ago

1.0.3

6 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago