开源软件名称(OpenSource Name):remarkjs/remark-lint开源软件地址(OpenSource Url):https://github.com/remarkjs/remark-lint开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):remark plugins to check (lint) markdown code style. Contents
What is this?You can use this to check markdown.
Say we have a markdown file 1) Hello, _Jupiter_ and *Neptune*! Then assuming we installed dependencies and run: npx remark doc/ --use remark-preset-lint-consistent --use remark-preset-lint-recommended We would get a report like this:
This GitHub repository is a monorepo that contains ±70 plugins (each a rule that checks one specific thing) and 3 presets (combinations of rules configured to check for certain styles). These packages are build on unified (remark). unified is a project that inspects and transforms content with abstract syntax trees (ASTs). remark adds support for markdown to unified. mdast is the markdown AST that remark uses. These lint rules inspect mdast. When should I use this?This project is useful when developers or technical writers are authoring documentation in markdown and you want to ensure that the markdown is consistent, free of bugs, and works well across different markdown parsers. These packages are quite good at checking markdown. They especially shine when combined with other remark plugins and at letting you make your own rules. PresetsPresets are combinations of rules configured to check for certain styles. The following presets only contain lint rules but you can make your own that include any remark plugins or other presets. The presets that are maintained here:
RulesThe rules that are maintained here:
You can make and share your own rules, which can be used just like the rules maintained here. The following rules are maintained by the community:
For help creating your own rule, it’s suggested to look at existing rules and to follow this tutorial. ConfigureAll rules can be configured in one standard way: import {remark} from 'remark'
import remarkLintFinalNewline from 'remark-lint-final-newline'
import remarkLintMaximumLineLength from 'remark-lint-maximum-line-length'
import remarkLintUnorderedListMarkerStyle from 'remark-lint-unordered-list-marker-style'
remark()
// Pass `false` to turn a rule off — the code no longer runs:
.use(remarkLintFinalNewline, false)
// Pass `true` to turn a rule on again:
.use(remarkLintFinalNewline, true)
// You can also configure whether messages by the rule should be ignored,
// are seen as code style warnings (default), or are seen as exceptions.
// Ignore messages with `'off'` or `0` as the first value of an array:
.use(remarkLintFinalNewline, ['off'])
.use(remarkLintFinalNewline, [0])
// Use `'warn'`, `'on'`, or `1` to treat messages as code style warnings:
.use(remarkLintFinalNewline, ['warn'])
.use(remarkLintFinalNewline, ['on'])
.use(remarkLintFinalNewline, [1])
// Use `'error'` or `2` to treat messages as exceptions:
.use(remarkLintFinalNewline, ['error'])
.use(remarkLintFinalNewline, [2])
// Some rules accept options, and what they exactly accept is different for
// each rule (sometimes a string, a number, or an object).
// The following rule accepts a string:
.use(remarkLintUnorderedListMarkerStyle, '*')
.use(remarkLintUnorderedListMarkerStyle, ['on', '*'])
.use(remarkLintUnorderedListMarkerStyle, [1, '*'])
// The following rule accepts a number:
.use(remarkLintMaximumLineLength, 72)
.use(remarkLintMaximumLineLength, ['on', 72])
.use(remarkLintMaximumLineLength, [1, 72]) See |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论