mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Compare commits
210 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
224987d727 | ||
![]() |
8cb8f6c695 | ||
![]() |
a1506e71f3 | ||
![]() |
b3935080e9 | ||
![]() |
738f4aa59a | ||
![]() |
979419c7a0 | ||
![]() |
4d8e79d33e | ||
![]() |
6adfaf68b5 | ||
![]() |
a4b7ffa8ce | ||
![]() |
f34f4dde69 | ||
![]() |
2775534144 | ||
![]() |
006b6af736 | ||
![]() |
328506e6c8 | ||
![]() |
c413ac9a88 | ||
![]() |
9849e2871f | ||
![]() |
2a85b3c3f1 | ||
![]() |
b611eba684 | ||
![]() |
faf96d513b | ||
![]() |
318b9ff6b4 | ||
![]() |
e93b9854dc | ||
![]() |
f6087f0e6a | ||
![]() |
1dc4974191 | ||
![]() |
647dac621f | ||
![]() |
fb8b562c94 | ||
![]() |
91eba5470a | ||
![]() |
4c6672d24d | ||
![]() |
92cd6d51cb | ||
![]() |
759c31760e | ||
![]() |
00fef38119 | ||
![]() |
e40ed300d0 | ||
![]() |
2ab8b49b48 | ||
![]() |
75003eb741 | ||
![]() |
c17bfc5c17 | ||
![]() |
40a252d028 | ||
![]() |
02478d24cf | ||
![]() |
45932c7837 | ||
![]() |
3145b68bed | ||
![]() |
a84f7c5b18 | ||
![]() |
a9417fdf67 | ||
![]() |
b4204f197e | ||
![]() |
465fc448eb | ||
![]() |
918f15945b | ||
![]() |
c4a6ef42a6 | ||
![]() |
32d660c34b | ||
![]() |
61fab7ba24 | ||
![]() |
41357b551f | ||
![]() |
62dc79864d | ||
![]() |
c061888937 | ||
![]() |
031c7be4db | ||
![]() |
0916d178e7 | ||
![]() |
9b46692b8d | ||
![]() |
95f82760ce | ||
![]() |
8baa843ce3 | ||
![]() |
5fc91f6977 | ||
![]() |
cb39972d9b | ||
![]() |
50300fa7af | ||
![]() |
5749c8dcf7 | ||
![]() |
06b60b7372 | ||
![]() |
a3db3dba2d | ||
![]() |
917c5a5f1d | ||
![]() |
61febde9c1 | ||
![]() |
d4a8a3bdfa | ||
![]() |
5cc88a7759 | ||
![]() |
d4a638101a | ||
![]() |
087df4480e | ||
![]() |
7b4c958e48 | ||
![]() |
d5cb5c8546 | ||
![]() |
d36a57d680 | ||
![]() |
f0b1afe884 | ||
![]() |
435c55f72a | ||
![]() |
d02090db2c | ||
![]() |
dbf828c493 | ||
![]() |
965b642109 | ||
![]() |
14cf2454ae | ||
![]() |
a5e2134147 | ||
![]() |
63147ee1eb | ||
![]() |
1f237e6c54 | ||
![]() |
c4d15e0d2a | ||
![]() |
27d70632cd | ||
![]() |
55941a5627 | ||
![]() |
1c4f69a7fc | ||
![]() |
5d3d07d345 | ||
![]() |
909b9a75ae | ||
![]() |
eaa1c74a11 | ||
![]() |
d918f61c77 | ||
![]() |
14524283cc | ||
![]() |
6645868510 | ||
![]() |
a2d569b012 | ||
![]() |
d53e3ff46c | ||
![]() |
264946920a | ||
![]() |
c30b59ae81 | ||
![]() |
a36f2dcf41 | ||
![]() |
4b3626b5f2 | ||
![]() |
715020de46 | ||
![]() |
241fe5b51c | ||
![]() |
31e480ad05 | ||
![]() |
41654fbb60 | ||
![]() |
c39a2dd516 | ||
![]() |
571c2353ea | ||
![]() |
b8374ec5d2 | ||
![]() |
4117394250 | ||
![]() |
6f7307ae7b | ||
![]() |
737ea4ec6d | ||
![]() |
bae6f9c63e | ||
![]() |
aa4f080b3f | ||
![]() |
f950936baa | ||
![]() |
44c302fe0b | ||
![]() |
d4b981bcb3 | ||
![]() |
3cbe1cb6c5 | ||
![]() |
b23fc96ab2 | ||
![]() |
656254e64f | ||
![]() |
c71e298d4b | ||
![]() |
90cf515ff0 | ||
![]() |
2d2fafc58d | ||
![]() |
f2a0bfe651 | ||
![]() |
37f96413dd | ||
![]() |
b0a267bf47 | ||
![]() |
9d2b4cb1cc | ||
![]() |
cb00a41ff3 | ||
![]() |
079aba9012 | ||
![]() |
feca49e4f8 | ||
![]() |
eb8a0a2b7c | ||
![]() |
8dbfe965e9 | ||
![]() |
4d4aab6bd4 | ||
![]() |
a4c553a45a | ||
![]() |
53ff5c43f1 | ||
![]() |
a1da464618 | ||
![]() |
e6ee4cc0b1 | ||
![]() |
e272b10a90 | ||
![]() |
48336b7ed3 | ||
![]() |
a6cc4cc860 | ||
![]() |
4ad6628dcb | ||
![]() |
637975f517 | ||
![]() |
d4352c7a44 | ||
![]() |
74b1c195e3 | ||
![]() |
ef70472df7 | ||
![]() |
795eac22de | ||
![]() |
df33933fe5 | ||
![]() |
8e5f699bb2 | ||
![]() |
92eb4254fc | ||
![]() |
1587927660 | ||
![]() |
a1081ec450 | ||
![]() |
5fad452106 | ||
![]() |
baf4944f5f | ||
![]() |
8ad4698536 | ||
![]() |
599b687849 | ||
![]() |
e959c1e522 | ||
![]() |
af086995ed | ||
![]() |
dc26c50688 | ||
![]() |
5056da0f93 | ||
![]() |
a46b587900 | ||
![]() |
faa9c6cbb4 | ||
![]() |
c9d32c33b0 | ||
![]() |
a009407088 | ||
![]() |
65eeb4c8d9 | ||
![]() |
8b26129d55 | ||
![]() |
6737ace933 | ||
![]() |
259f19a558 | ||
![]() |
14d8db70f6 | ||
![]() |
ed3cd80bab | ||
![]() |
898c573f29 | ||
![]() |
015b34ff09 | ||
![]() |
62073a8fde | ||
![]() |
6e52643f8c | ||
![]() |
2449163ffb | ||
![]() |
fd7fb925a9 | ||
![]() |
ce7efbd9e1 | ||
![]() |
b404c8bf16 | ||
![]() |
8da43dd246 | ||
![]() |
e41f034bef | ||
![]() |
853c142291 | ||
![]() |
69242b3aa6 | ||
![]() |
4965ee84e4 | ||
![]() |
8f66aafe28 | ||
![]() |
789190962c | ||
![]() |
3599f694ba | ||
![]() |
1e71f6f44e | ||
![]() |
191226f070 | ||
![]() |
41dda9e041 | ||
![]() |
07ef2bf804 | ||
![]() |
e815e1a458 | ||
![]() |
9fe9f801dc | ||
![]() |
770bbce5d4 | ||
![]() |
587b830cb2 | ||
![]() |
3812cba029 | ||
![]() |
6f76cd105d | ||
![]() |
d536543344 | ||
![]() |
4853cf4c31 | ||
![]() |
a25af76bbb | ||
![]() |
a22b432d8a | ||
![]() |
fe45e0110a | ||
![]() |
1ace77f0b0 | ||
![]() |
0092c5f189 | ||
![]() |
e07c66ae68 | ||
![]() |
f29ca16c38 | ||
![]() |
1737a6c672 | ||
![]() |
132ccbea03 | ||
![]() |
3850a6dc60 | ||
![]() |
b91dfb539f | ||
![]() |
a418847399 | ||
![]() |
975e25fcf0 | ||
![]() |
2beebd6fc5 | ||
![]() |
7ba8160e8c | ||
![]() |
db409190ed | ||
![]() |
727518d1cf | ||
![]() |
589ecbf720 | ||
![]() |
04b597ab90 | ||
![]() |
b6dda50e58 | ||
![]() |
886e00a8d5 | ||
![]() |
0eedda0a6c |
266 changed files with 8818 additions and 12938 deletions
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
blank_issues_enabled: false
|
6
.github/dependabot.yml
vendored
6
.github/dependabot.yml
vendored
|
@ -11,9 +11,3 @@ updates:
|
|||
interval: "daily"
|
||||
target-branch: "next"
|
||||
versioning-strategy: "increase"
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/micromark"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
target-branch: "next"
|
||||
versioning-strategy: "increase"
|
||||
|
|
4
.github/dictionary.txt
vendored
4
.github/dictionary.txt
vendored
|
@ -16,6 +16,7 @@ blockquotes
|
|||
Boostnote
|
||||
br
|
||||
br_spaces
|
||||
bundler
|
||||
changelog
|
||||
Changelog
|
||||
changelogs
|
||||
|
@ -30,11 +31,13 @@ Config
|
|||
config.
|
||||
CVE-\d+-\d+
|
||||
docs-util
|
||||
ECMAScript
|
||||
ES2015
|
||||
ES6
|
||||
ESLint
|
||||
eslint-plugin-markdownlint
|
||||
first-line-h1
|
||||
flymake-markdownlint-cli2
|
||||
formatter
|
||||
fs
|
||||
GFM
|
||||
|
@ -94,6 +97,7 @@ setext_with_atx_closed
|
|||
setext-style
|
||||
single-h1
|
||||
sublist
|
||||
subpath
|
||||
Super-Linter
|
||||
TestCafe
|
||||
TOML
|
||||
|
|
2
.github/workflows/checkers.yml
vendored
2
.github/workflows/checkers.yml
vendored
|
@ -15,7 +15,7 @@ jobs:
|
|||
- uses: actions/checkout@v4
|
||||
- uses: JustinBeckwith/linkinator-action@v1.11.0
|
||||
with:
|
||||
linksToSkip: '^https://github.com/.*/search\?q= ^https://opensource.org/ ^https://unix.stackexchange.com/'
|
||||
linksToSkip: '^https://github.com/ ^https://opensource.org/ ^https://unix.stackexchange.com/'
|
||||
paths: '*.md doc/*.md helpers/*.md'
|
||||
timeout: 60000
|
||||
|
||||
|
|
27
.github/workflows/ci.yml
vendored
27
.github/workflows/ci.yml
vendored
|
@ -11,14 +11,13 @@ on:
|
|||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
node-version: [ 18, 20, 22 ]
|
||||
node-version: [ 20, 22, 23 ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
@ -30,11 +29,21 @@ jobs:
|
|||
run: npm install --no-package-lock
|
||||
- name: Run CI Tests
|
||||
run: npm run ci
|
||||
- name: Install markdownlint-micromark Dependencies
|
||||
run: npm run install-micromark
|
||||
- name: Build markdownlint-micromark
|
||||
run: npm run build-micromark
|
||||
- name: Install local markdownlint-micromark
|
||||
run: npm install --no-package-lock ./micromark
|
||||
- name: Test with local markdownlint-micromark
|
||||
|
||||
pnpm:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Use pnpm latest
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: latest
|
||||
- name: Use Node.js latest
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: latest
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
- name: Run CI Tests
|
||||
run: npm test
|
||||
|
|
10
.gitignore
vendored
10
.gitignore
vendored
|
@ -1,16 +1,10 @@
|
|||
coverage
|
||||
demo/markdown-it.min.js
|
||||
demo/markdownlint-browser.js
|
||||
demo/markdownlint-browser.min.js
|
||||
demo/micromark-browser.js
|
||||
demo/micromark-html-browser.js
|
||||
micromark/micromark.cjs
|
||||
micromark/micromark.dev.cjs
|
||||
micromark/micromark-browser.js
|
||||
micromark/micromark-browser.dev.js
|
||||
micromark/micromark-html-browser.js
|
||||
micromark/micromark-html-browser.dev.js
|
||||
node_modules
|
||||
!test/node_modules
|
||||
!test/rules/node_modules
|
||||
npm-debug.log
|
||||
test-repos
|
||||
.DS_Store
|
||||
|
|
|
@ -5,13 +5,11 @@
|
|||
.vscode
|
||||
coverage
|
||||
demo/*
|
||||
!demo/markdownlint-browser.js
|
||||
doc-build
|
||||
eslint.config.mjs
|
||||
example
|
||||
micromark
|
||||
npm-debug.log
|
||||
schema/*.js
|
||||
schema/*.mjs
|
||||
scripts
|
||||
test
|
||||
test-repos
|
||||
|
|
1
.npmrc
1
.npmrc
|
@ -1,2 +1,3 @@
|
|||
engine-strict=true
|
||||
ignore-scripts=true
|
||||
package-lock=false
|
||||
|
|
34
CHANGELOG.md
34
CHANGELOG.md
|
@ -1,5 +1,39 @@
|
|||
# Changelog
|
||||
|
||||
## 0.38.0
|
||||
|
||||
- Add MD059/descriptive-link-text
|
||||
- Improve MD025/MD027/MD036/MD038/MD041/MD043/MD045/MD051/MD052
|
||||
- `markdown-it` parser no longer a production dependency (breaking change)
|
||||
- Add `markdownItFactory` option, remove `markdownItPlugins` option
|
||||
- Remove support for end-of-life Node version 18
|
||||
- Improve performance
|
||||
- Update dependencies
|
||||
|
||||
## 0.37.4
|
||||
|
||||
- Stop using `module.createRequire`, export `resolveModule`
|
||||
|
||||
## 0.37.3
|
||||
|
||||
- Tweak `package.json` dependencies to work with `pnpm`
|
||||
|
||||
## 0.37.2
|
||||
|
||||
- Add subpath imports for overriding default bundler behavior
|
||||
- Improve MD032
|
||||
|
||||
## 0.37.1
|
||||
|
||||
- Add support for "browser" condition (as used by webpack)
|
||||
|
||||
## 0.37.0
|
||||
|
||||
- Convert module to ECMAScript (breaking change)
|
||||
- <https://nodejs.org/docs/latest/api/esm.html>
|
||||
- <https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c>
|
||||
- Convert module to named exports (breaking change)
|
||||
|
||||
## 0.36.1
|
||||
|
||||
- Fix behavior of MD054
|
||||
|
|
|
@ -14,8 +14,8 @@ Match the coding style of the files you edit. Although everyone has their own
|
|||
preferences and opinions, a pull request is not the right forum to debate them.
|
||||
|
||||
Do not add new [`dependencies` to `package.json`][dependencies]. The Markdown
|
||||
parsers [`markdown-it`][markdown-it] and [`micromark`][micromark] are the
|
||||
project's only dependencies.
|
||||
parser [`micromark`][micromark] (and its extensions) is this project's only
|
||||
dependency.
|
||||
|
||||
Package versions for `dependencies` and `devDependencies` should be specified
|
||||
exactly (also known as "pinning"). The short explanation is that doing otherwise
|
||||
|
@ -85,7 +85,6 @@ Thank you!
|
|||
[custom-rules]: doc/CustomRules.md
|
||||
[dependencies]: https://docs.npmjs.com/files/package.json#dependencies
|
||||
[example-com]: https://en.wikipedia.org/wiki/Example.com
|
||||
[markdown-it]: https://www.npmjs.com/package/markdown-it
|
||||
[micromark]: https://www.npmjs.com/package/micromark
|
||||
[new-rule]: https://github.com/DavidAnson/markdownlint/labels/new%20rule
|
||||
[npm-scripts]: https://docs.npmjs.com/misc/scripts
|
||||
|
|
263
README.md
263
README.md
|
@ -24,7 +24,7 @@ for Markdown files. It was inspired by - and heavily influenced by - Mark
|
|||
Harrison's [markdownlint][markdownlint-ruby] for Ruby. The initial rules, rule
|
||||
documentation, and test cases came from that project.
|
||||
|
||||
`markdownlint` uses the [`micromark`][micromark] parser and honors the
|
||||
`markdownlint` uses the [`micromark` parser][micromark] and honors the
|
||||
[CommonMark][commonmark] specification for Markdown. It additionally supports
|
||||
popular [GitHub Flavored Markdown (GFM)][gfm] syntax like autolinks and tables
|
||||
as well as directives, footnotes, and math syntax - all implemented by
|
||||
|
@ -55,6 +55,7 @@ as well as directives, footnotes, and math syntax - all implemented by
|
|||
- [vscode-markdownlint extension for VS Code][vscode-markdownlint]
|
||||
- [Sublime Text markdownlint for Sublime Text][sublimelinter]
|
||||
- [coc-markdownlint extension for Vim/Neovim][coc]
|
||||
- [flymake-markdownlint-cli2 extension for Emacs][emacs-flymake]
|
||||
- Tooling
|
||||
- [eslint-plugin-markdownlint for the ESLint analyzer][eslint-plugin]
|
||||
- [grunt-markdownlint for the Grunt task runner][grunt-markdownlint]
|
||||
|
@ -65,6 +66,7 @@ as well as directives, footnotes, and math syntax - all implemented by
|
|||
|
||||
[cake]: https://github.com/cake-contrib/Cake.Markdownlint
|
||||
[coc]: https://github.com/fannheyward/coc-markdownlint
|
||||
[emacs-flymake]: https://github.com/ewilderj/flymake-markdownlint-cli2
|
||||
[eslint-plugin]: https://github.com/paweldrozd/eslint-plugin-markdownlint
|
||||
[grunt-markdownlint]: https://github.com/sagiegurari/grunt-markdownlint
|
||||
[markdownlint-cli]: https://github.com/igorshubovych/markdownlint-cli
|
||||
|
@ -75,7 +77,7 @@ as well as directives, footnotes, and math syntax - all implemented by
|
|||
[markdownlint-problem-matcher]: https://github.com/xt0rted/markdownlint-problem-matcher
|
||||
[nodejs-extensions]: https://github.com/Lombiq/NodeJs-Extensions
|
||||
[rubygems-mdl]: https://rubygems.org/gems/mdl
|
||||
[sublimelinter]: https://packagecontrol.io/packages/SublimeLinter-contrib-markdownlint
|
||||
[sublimelinter]: https://github.com/jonlabelle/SublimeLinter-contrib-markdownlint
|
||||
[super-linter]: https://github.com/super-linter/super-linter
|
||||
[vscode-markdownlint]: https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint
|
||||
|
||||
|
@ -146,6 +148,7 @@ playground for learning and exploring.
|
|||
- **[MD055](doc/md055.md)** *table-pipe-style* - Table pipe style
|
||||
- **[MD056](doc/md056.md)** *table-column-count* - Table column count
|
||||
- **[MD058](doc/md058.md)** *blanks-around-tables* - Tables should be surrounded by blank lines
|
||||
- **[MD059](doc/md059.md)** *descriptive-link-text* - Link text should be descriptive
|
||||
|
||||
<!-- markdownlint-restore -->
|
||||
|
||||
|
@ -165,7 +168,7 @@ To implement your own rules, refer to [CustomRules.md](doc/CustomRules.md).
|
|||
Tags group related rules and can be used to enable/disable multiple
|
||||
rules at once.
|
||||
|
||||
- **`accessibility`** - `MD045`
|
||||
- **`accessibility`** - `MD045`, `MD059`
|
||||
- **`atx`** - `MD018`, `MD019`
|
||||
- **`atx_closed`** - `MD020`, `MD021`
|
||||
- **`blank_lines`** - `MD012`, `MD022`, `MD031`, `MD032`, `MD047`
|
||||
|
@ -183,7 +186,7 @@ rules at once.
|
|||
- **`language`** - `MD040`
|
||||
- **`line_length`** - `MD013`
|
||||
- **`links`** - `MD011`, `MD034`, `MD039`, `MD042`, `MD051`, `MD052`, `MD053`,
|
||||
`MD054`
|
||||
`MD054`, `MD059`
|
||||
- **`ol`** - `MD029`, `MD030`, `MD032`
|
||||
- **`spaces`** - `MD018`, `MD019`, `MD020`, `MD021`, `MD023`
|
||||
- **`spelling`** - `MD044`
|
||||
|
@ -312,42 +315,41 @@ alternate formats.
|
|||
|
||||
### Linting
|
||||
|
||||
Standard asynchronous API:
|
||||
Asynchronous API via `import { lint } from "markdownlint/async"`:
|
||||
|
||||
```javascript
|
||||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options} options Configuration options.
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @param {LintCallback} callback Callback (err, result) function.
|
||||
* @returns {void}
|
||||
*/
|
||||
function markdownlint(options, callback) { ... }
|
||||
function lint(options, callback) { ... }
|
||||
```
|
||||
|
||||
Synchronous API (for build scripts, etc.):
|
||||
|
||||
```javascript
|
||||
/**
|
||||
* Lint specified Markdown files synchronously.
|
||||
*
|
||||
* @param {Options} options Configuration options.
|
||||
* @returns {LintResults} Results object.
|
||||
*/
|
||||
function markdownlint.sync(options) { ... }
|
||||
```
|
||||
|
||||
Promise API (in the `promises` namespace like Node.js's
|
||||
[`fs` Promises API](https://nodejs.org/api/fs.html#fs_fs_promises_api)):
|
||||
Synchronous API via `import { lint } from "markdownlint/sync"`:
|
||||
|
||||
```javascript
|
||||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options} options Configuration options.
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @returns {LintResults} Results object.
|
||||
*/
|
||||
function lint(options) { ... }
|
||||
```
|
||||
|
||||
Promise API via `import { lint } from "markdownlint/promise"`:
|
||||
|
||||
```javascript
|
||||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @returns {Promise<LintResults>} Results object.
|
||||
*/
|
||||
function markdownlint(options) { ... }
|
||||
function lint(options) { ... }
|
||||
```
|
||||
|
||||
#### options
|
||||
|
@ -419,9 +421,9 @@ object.
|
|||
See [ValidatingConfiguration.md](schema/ValidatingConfiguration.md) for ways to
|
||||
use the JSON Schema to validate configuration.
|
||||
|
||||
For more advanced scenarios, styles can reference and extend other styles.
|
||||
The `readConfig` and `readConfigSync` functions can be used to read such
|
||||
styles.
|
||||
For more advanced scenarios, styles can reference and build upon other styles
|
||||
via the `extends` keyword and a file path or (installed) package name. The
|
||||
`readConfig` function can be used to read such aggregate styles from code.
|
||||
|
||||
For example, assuming a `base.json` configuration file:
|
||||
|
||||
|
@ -547,7 +549,7 @@ Type: `Object` implementing the [file system API][node-fs-api]
|
|||
|
||||
In advanced scenarios, it may be desirable to bypass the default file system
|
||||
API. If a custom file system implementation is provided, `markdownlint` will use
|
||||
that instead of invoking `require("fs")`.
|
||||
that instead of using `node:fs`.
|
||||
|
||||
Note: The only methods called are `readFile` and `readFileSync`.
|
||||
|
||||
|
@ -568,28 +570,43 @@ This setting can be useful in the presence of (custom) rules that encounter
|
|||
unexpected syntax and fail. By enabling this option, the linting process
|
||||
is allowed to continue and report any violations that were found.
|
||||
|
||||
##### options.markdownItPlugins
|
||||
##### options.markdownItFactory
|
||||
|
||||
Type: `Array` of `Array` of `Function` and plugin parameters
|
||||
Type: `Function` returning an instance of a [`markdown-it` parser][markdown-it]
|
||||
|
||||
Specifies additional [`markdown-it` plugins][markdown-it-plugin] to use when
|
||||
parsing input. Plugins can be used to support additional syntax and features for
|
||||
advanced scenarios. *Deprecated.*
|
||||
Provides a factory function for creating instances of the `markdown-it` parser.
|
||||
|
||||
[markdown-it-plugin]: https://www.npmjs.com/search?q=keywords:markdown-it-plugin
|
||||
Previous versions of the `markdownlint` library declared `markdown-it` as a
|
||||
direct dependency. This function makes it possible to avoid that dependency
|
||||
entirely. In cases where `markdown-it` is needed, the caller is responsible for
|
||||
declaring the dependency and returning an instance from this factory. If any
|
||||
[`markdown-it` plugins][markdown-it-plugin] are needed, they should be `use`d by
|
||||
the caller before returning the `markdown-it` instance.
|
||||
|
||||
Each item in the top-level `Array` should be of the form:
|
||||
For compatibility with previous versions of `markdownlint`, this function should
|
||||
be similar to:
|
||||
|
||||
```javascript
|
||||
[ require("markdown-it-plugin"), plugin_param_0, plugin_param_1, ... ]
|
||||
import markdownIt from "markdown-it";
|
||||
const markdownItFactory = () => markdownIt({ "html": true });
|
||||
```
|
||||
|
||||
> Note that `markdown-it` plugins are only called when the `markdown-it` parser
|
||||
> is invoked. None of the built-in rules use the `markdown-it` parser, so
|
||||
> `markdown-it` plugins will only be invoked when one or more
|
||||
> [custom rules][custom-rules] that use the `markdown-it` parser are present.
|
||||
When an asynchronous implementation of `lint` is being invoked (e.g., via
|
||||
`markdownlint/async` or `markdownlint/promise`), this function can return a
|
||||
`Promise` in order to defer the import of `markdown-it`:
|
||||
|
||||
```javascript
|
||||
const markdownItFactory = () => import("markdown-it").then((module) => module.default({ "html": true }));
|
||||
```
|
||||
|
||||
> Note that this function is only invoked when a `markdown-it` parser is
|
||||
> needed. None of the built-in rules use the `markdown-it` parser, so it is only
|
||||
> invoked when one or more [custom rules][custom-rules] are present that use the
|
||||
> `markdown-it` parser.
|
||||
|
||||
[custom-rules]: #custom-rules
|
||||
[markdown-it]: https://github.com/markdown-it/markdown-it
|
||||
[markdown-it-plugin]: https://www.npmjs.com/search?q=keywords:markdown-it-plugin
|
||||
|
||||
##### options.noInlineConfig
|
||||
|
||||
|
@ -661,22 +678,22 @@ uses rule aliases (ex: `no-hard-tabs`) instead of names (ex: `MD010`).
|
|||
### Config
|
||||
|
||||
The `options.config` configuration object is simple and can be stored in a file
|
||||
for readability and easy reuse. The `readConfig` and `readConfigSync` functions
|
||||
load configuration settings and support the `extends` keyword for referencing
|
||||
other files (see above).
|
||||
for readability and easy reuse. The `readConfig` function loads configuration
|
||||
settings and supports the `extends` keyword for referencing files or packages
|
||||
(see above).
|
||||
|
||||
By default, configuration files are parsed as JSON (and named
|
||||
`.markdownlint.json`). Custom parsers can be provided to handle other formats
|
||||
like JSONC, YAML, and TOML.
|
||||
|
||||
Asynchronous API:
|
||||
Asynchronous API via `import { readConfig } from "markdownlint/async"`:
|
||||
|
||||
```javascript
|
||||
/**
|
||||
* Read specified configuration file.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[] | ReadConfigCallback} parsers Parsing function.
|
||||
* @param {ConfigurationParser[] | ReadConfigCallback} [parsers] Parsing function(s).
|
||||
* @param {Object} [fs] File system implementation.
|
||||
* @param {ReadConfigCallback} [callback] Callback (err, result) function.
|
||||
* @returns {void}
|
||||
|
@ -684,22 +701,21 @@ Asynchronous API:
|
|||
function readConfig(file, parsers, fs, callback) { ... }
|
||||
```
|
||||
|
||||
Synchronous API:
|
||||
Synchronous API via `import { readConfig } from "markdownlint/sync"`:
|
||||
|
||||
```javascript
|
||||
/**
|
||||
* Read specified configuration file synchronously.
|
||||
* Read specified configuration file.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
||||
* @param {Object} [fs] File system implementation.
|
||||
* @returns {Configuration} Configuration object.
|
||||
*/
|
||||
function readConfigSync(file, parsers, fs) { ... }
|
||||
function readConfig(file, parsers, fs) { ... }
|
||||
```
|
||||
|
||||
Promise API (in the `promises` namespace like Node.js's
|
||||
[`fs` Promises API](https://nodejs.org/api/fs.html#fs_promises_api)):
|
||||
Promise API via `import { readConfig } from "markdownlint/promise"`:
|
||||
|
||||
```javascript
|
||||
/**
|
||||
|
@ -751,7 +767,7 @@ Type: *Optional* `Object` implementing the [file system API][file-system-api]
|
|||
|
||||
In advanced scenarios, it may be desirable to bypass the default file system
|
||||
API. If a custom file system implementation is provided, `markdownlint` will use
|
||||
that instead of invoking `require("fs")`.
|
||||
that instead of invoking `node:fs`.
|
||||
|
||||
Note: The only methods called are `readFile`, `readFileSync`, `access`, and
|
||||
`accessSync`.
|
||||
|
@ -772,7 +788,8 @@ Configuration object.
|
|||
|
||||
Rules that can be fixed automatically include a `fixInfo` property which is
|
||||
outlined in the [documentation for custom rules](doc/CustomRules.md#authoring).
|
||||
To apply fixes consistently, the `applyFix`/`applyFixes` methods may be used:
|
||||
To apply fixes consistently, the `applyFix`/`applyFixes` methods may be used via
|
||||
`import { applyFix, applyFixes } from "markdownlint"`:
|
||||
|
||||
```javascript
|
||||
/**
|
||||
|
@ -798,20 +815,44 @@ function applyFixes(input, errors) { ... }
|
|||
Invoking `applyFixes` with the results of a call to lint can be done like so:
|
||||
|
||||
```javascript
|
||||
const { "sync": markdownlintSync, applyFixes } = require("markdownlint");
|
||||
import { applyFixes } from "markdownlint";
|
||||
import { lint as lintSync } from "markdownlint/sync";
|
||||
|
||||
function fixMarkdownlintViolations(content) {
|
||||
const fixResults = markdownlintSync({ strings: { content } });
|
||||
return applyFixes(content, fixResults.content);
|
||||
}
|
||||
const results = lintSync({ "strings": { "content": original } });
|
||||
const fixed = applyFixes(original, results.content);
|
||||
```
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
To get the [semantic version][semver] of the library, the `getVersion` method
|
||||
can be used:
|
||||
|
||||
```javascript
|
||||
/**
|
||||
* Gets the (semantic) version of the library.
|
||||
*
|
||||
* @returns {string} SemVer string.
|
||||
*/
|
||||
function getVersion() { ... }
|
||||
```
|
||||
|
||||
Invoking `getVersion` is simple:
|
||||
|
||||
```javascript
|
||||
import { getVersion } from "markdownlint";
|
||||
|
||||
// Displays the library version
|
||||
console.log(getVersion());
|
||||
```
|
||||
|
||||
[semver]: https://semver.org
|
||||
|
||||
## Usage
|
||||
|
||||
Invoke `markdownlint` and use the `result` object's `toString` method:
|
||||
Invoke `lint` and use the `result` object's `toString` method:
|
||||
|
||||
```javascript
|
||||
const markdownlint = require("markdownlint");
|
||||
import { lint as lintAsync } from "markdownlint/async";
|
||||
|
||||
const options = {
|
||||
"files": [ "good.md", "bad.md" ],
|
||||
|
@ -821,9 +862,9 @@ const options = {
|
|||
}
|
||||
};
|
||||
|
||||
markdownlint(options, function callback(err, result) {
|
||||
if (!err) {
|
||||
console.log(result.toString());
|
||||
lintAsync(options, function callback(error, results) {
|
||||
if (!error && results) {
|
||||
console.log(results.toString());
|
||||
}
|
||||
});
|
||||
```
|
||||
|
@ -841,21 +882,22 @@ bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style heading [
|
|||
bad.md: 1: MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "#bad.md"]
|
||||
```
|
||||
|
||||
Or invoke `markdownlint.sync` for a synchronous call:
|
||||
Or as a synchronous call:
|
||||
|
||||
```javascript
|
||||
const result = markdownlint.sync(options);
|
||||
console.log(result.toString());
|
||||
import { lint as lintSync } from "markdownlint/sync";
|
||||
|
||||
const results = lintSync(options);
|
||||
console.log(results.toString());
|
||||
```
|
||||
|
||||
To examine the `result` object directly:
|
||||
To examine the `result` object directly via a `Promise`-based call:
|
||||
|
||||
```javascript
|
||||
markdownlint(options, function callback(err, result) {
|
||||
if (!err) {
|
||||
console.dir(result, { "colors": true, "depth": null });
|
||||
}
|
||||
});
|
||||
import { lint as lintPromise } from "markdownlint/promise";
|
||||
|
||||
const results = await lintPromise(options);
|
||||
console.dir(results, { "colors": true, "depth": null });
|
||||
```
|
||||
|
||||
Output:
|
||||
|
@ -897,80 +939,10 @@ Output:
|
|||
```
|
||||
|
||||
Integration with the [gulp](https://gulpjs.com/) build system is
|
||||
straightforward:
|
||||
|
||||
```javascript
|
||||
const gulp = require("gulp");
|
||||
const through2 = require("through2");
|
||||
const markdownlint = require("markdownlint");
|
||||
|
||||
gulp.task("markdownlint", function task() {
|
||||
return gulp.src("*.md", { "read": false })
|
||||
.pipe(through2.obj(function obj(file, enc, next) {
|
||||
markdownlint(
|
||||
{ "files": [ file.relative ] },
|
||||
function callback(err, result) {
|
||||
const resultString = (result || "").toString();
|
||||
if (resultString) {
|
||||
console.log(resultString);
|
||||
}
|
||||
next(err, file);
|
||||
});
|
||||
}));
|
||||
});
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```text
|
||||
[00:00:00] Starting 'markdownlint'...
|
||||
bad.md: 3: MD010/no-hard-tabs Hard tabs [Column: 17]
|
||||
bad.md: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.md"]
|
||||
bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This file fails some rules."]
|
||||
bad.md: 1: MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "#bad.md"]
|
||||
[00:00:00] Finished 'markdownlint' after 10 ms
|
||||
```
|
||||
straightforward: [`gulpfile.cjs`](example/gulpfile.cjs).
|
||||
|
||||
Integration with the [Grunt](https://gruntjs.com/) build system is similar:
|
||||
|
||||
```javascript
|
||||
const markdownlint = require("markdownlint");
|
||||
|
||||
module.exports = function wrapper(grunt) {
|
||||
grunt.initConfig({
|
||||
"markdownlint": {
|
||||
"example": {
|
||||
"src": [ "*.md" ]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.registerMultiTask("markdownlint", function task() {
|
||||
const done = this.async();
|
||||
markdownlint(
|
||||
{ "files": this.filesSrc },
|
||||
function callback(err, result) {
|
||||
const resultString = err || ((result || "").toString());
|
||||
if (resultString) {
|
||||
grunt.fail.warn("\n" + resultString + "\n");
|
||||
}
|
||||
done(!err || !resultString);
|
||||
});
|
||||
});
|
||||
};
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```text
|
||||
Running "markdownlint:example" (markdownlint) task
|
||||
Warning:
|
||||
bad.md: 3: MD010/no-hard-tabs Hard tabs [Column: 17]
|
||||
bad.md: 1: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#bad.md"]
|
||||
bad.md: 3: MD018/no-missing-space-atx No space after hash on atx style heading [Context: "#This file fails some rules."]
|
||||
bad.md: 1: MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "#bad.md"]
|
||||
Use --force to continue.
|
||||
```
|
||||
[`Gruntfile.cjs`](example/Gruntfile.cjs).
|
||||
|
||||
## Browser
|
||||
|
||||
|
@ -982,11 +954,9 @@ Generate normal and minified scripts with:
|
|||
npm run build-demo
|
||||
```
|
||||
|
||||
Then reference `markdownlint` and `micromark` scripts:
|
||||
Then reference the `markdownlint-browser` script:
|
||||
|
||||
```html
|
||||
<script src="demo/micromark-browser.js"></script>
|
||||
<script src="demo/micromark-html-browser.js"></script>
|
||||
<script src="demo/markdownlint-browser.min.js"></script>
|
||||
```
|
||||
|
||||
|
@ -998,7 +968,8 @@ const options = {
|
|||
"content": "Some Markdown to lint."
|
||||
}
|
||||
};
|
||||
const results = window.markdownlint.sync(options).toString();
|
||||
|
||||
const results = globalThis.markdownlint.lintSync(options).toString();
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
|
10
demo/browser-exports.mjs
Normal file
10
demo/browser-exports.mjs
Normal file
|
@ -0,0 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
export { applyFixes, getVersion } from "markdownlint";
|
||||
export { lint as lintSync } from "markdownlint/sync";
|
||||
export { compile, parse, postprocess, preprocess } from "micromark";
|
||||
export { directive, directiveHtml } from "micromark-extension-directive";
|
||||
export { gfmAutolinkLiteral, gfmAutolinkLiteralHtml } from "micromark-extension-gfm-autolink-literal";
|
||||
export { gfmFootnote, gfmFootnoteHtml } from "micromark-extension-gfm-footnote";
|
||||
export { gfmTable, gfmTableHtml } from "micromark-extension-gfm-table";
|
||||
export { math, mathHtml } from "micromark-extension-math";
|
|
@ -34,8 +34,6 @@
|
|||
</div>
|
||||
</div>
|
||||
<script src="markdown-it.min.js"></script>
|
||||
<script src="micromark-browser.js"></script>
|
||||
<script src="micromark-html-browser.js"></script>
|
||||
<script src="markdownlint-browser.min.js"></script>
|
||||
<script src="default.js"></script>
|
||||
</body>
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
(function main() {
|
||||
// Dependencies
|
||||
var markdownit = globalThis.markdownit;
|
||||
var markdownlint = globalThis.markdownlint.library;
|
||||
var micromark = globalThis.micromarkBrowser;
|
||||
var micromarkHtml = globalThis.micromarkHtmlBrowser;
|
||||
var markdownlint = globalThis.markdownlint;
|
||||
var micromark = markdownlint;
|
||||
|
||||
// DOM elements
|
||||
var markdown = document.getElementById("markdown");
|
||||
|
@ -70,15 +69,15 @@
|
|||
const compileOptions = {
|
||||
"allowDangerousHtml": true,
|
||||
"htmlExtensions": [
|
||||
micromarkHtml.directiveHtml({ "*": handleDirective }),
|
||||
micromarkHtml.gfmAutolinkLiteralHtml(),
|
||||
micromarkHtml.gfmFootnoteHtml(),
|
||||
micromarkHtml.gfmTableHtml(),
|
||||
micromarkHtml.mathHtml()
|
||||
micromark.directiveHtml({ "*": handleDirective }),
|
||||
micromark.gfmAutolinkLiteralHtml(),
|
||||
micromark.gfmFootnoteHtml(),
|
||||
micromark.gfmTableHtml(),
|
||||
micromark.mathHtml()
|
||||
]
|
||||
};
|
||||
try {
|
||||
return micromarkHtml.compile(compileOptions)(events);
|
||||
return micromark.compile(compileOptions)(events);
|
||||
} catch (error) {
|
||||
return `[Exception: "${error}"]`;
|
||||
}
|
||||
|
@ -113,7 +112,7 @@
|
|||
},
|
||||
"handleRuleFailures": true
|
||||
};
|
||||
allLintErrors = markdownlint.sync(options).content;
|
||||
allLintErrors = markdownlint.lintSync(options).content;
|
||||
violations.innerHTML = allLintErrors.map(function mapResult(result) {
|
||||
var ruleName = result.ruleNames.slice(0, 2).join(" / ");
|
||||
return "<em><a href='#line' target='" + result.lineNumber + "'>" +
|
||||
|
@ -131,9 +130,9 @@
|
|||
"\"</span>]" :
|
||||
"") +
|
||||
(result.fixInfo ?
|
||||
" [<a href='#fix' target='" +
|
||||
" [<a href='#fix' target=\"" +
|
||||
encodeURIComponent(JSON.stringify(result)) +
|
||||
"' class='detail'>Fix</a>]" :
|
||||
"\" class='detail'>Fix</a>]" :
|
||||
"");
|
||||
}).join("<br/>");
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,8 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
"library": require(".."),
|
||||
"helpers": require("../helpers")
|
||||
};
|
|
@ -1,108 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const webpack = require("webpack");
|
||||
const TerserPlugin = require("terser-webpack-plugin");
|
||||
const nodeModulePrefixRe = /^node:/u;
|
||||
|
||||
function config(options) {
|
||||
const { entry, filename, mode, optimization, packageJson } = options;
|
||||
const { name, version, homepage, license } = packageJson;
|
||||
return {
|
||||
"devtool": false,
|
||||
"entry": entry,
|
||||
"externals": {
|
||||
"markdown-it": "markdownit",
|
||||
"markdownlint-micromark": "micromarkBrowser"
|
||||
},
|
||||
"mode": mode,
|
||||
"module": {
|
||||
"rules": [
|
||||
{
|
||||
"test": /\.[cm]?js$/,
|
||||
"exclude": /node_modules/
|
||||
}
|
||||
]
|
||||
},
|
||||
"name": name,
|
||||
"optimization": optimization,
|
||||
"output": {
|
||||
"filename": filename,
|
||||
"library": {
|
||||
"name": name.replace(/(-\w)/g, (m) => m.slice(1).toUpperCase()),
|
||||
"type": "var"
|
||||
},
|
||||
"path": __dirname
|
||||
},
|
||||
"plugins": [
|
||||
new webpack.NormalModuleReplacementPlugin(
|
||||
nodeModulePrefixRe,
|
||||
(resource) => {
|
||||
const module = resource.request.replace(nodeModulePrefixRe, "");
|
||||
resource.request = module;
|
||||
}
|
||||
),
|
||||
new webpack.BannerPlugin({
|
||||
"banner": `${name} ${version} ${homepage} @license ${license}`
|
||||
})
|
||||
],
|
||||
"resolve": {
|
||||
"fallback": {
|
||||
"fs": false,
|
||||
"os": false,
|
||||
"path": false,
|
||||
"util": false
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const modeDevelopment = {
|
||||
"mode": "development"
|
||||
};
|
||||
const modeProduction = {
|
||||
"mode": "production",
|
||||
"optimization": {
|
||||
"minimizer": [
|
||||
new TerserPlugin({
|
||||
"extractComments": false,
|
||||
"terserOptions": {
|
||||
"compress": {
|
||||
"passes": 2
|
||||
}
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
};
|
||||
const entryLibrary = {
|
||||
"entry": "./markdownlint-exports.js",
|
||||
"packageJson": require("../package.json")
|
||||
};
|
||||
// const entryHelpers = {
|
||||
// "entry": "../helpers/helpers.js",
|
||||
// "packageJson": require("../helpers/package.json")
|
||||
// };
|
||||
module.exports = [
|
||||
config({
|
||||
...entryLibrary,
|
||||
...modeDevelopment,
|
||||
"filename": "markdownlint-browser.js"
|
||||
}),
|
||||
config({
|
||||
...entryLibrary,
|
||||
...modeProduction,
|
||||
"filename": "markdownlint-browser.min.js"
|
||||
})
|
||||
// config({
|
||||
// ...entryHelpers,
|
||||
// ...modeDevelopment,
|
||||
// "filename": "markdownlint-rule-helpers-browser.js"
|
||||
// }),
|
||||
// config({
|
||||
// ...entryHelpers,
|
||||
// ...modeProduction,
|
||||
// "filename": "markdownlint-rule-helpers-browser.min.js"
|
||||
// })
|
||||
];
|
81
demo/webpack.config.mjs
Normal file
81
demo/webpack.config.mjs
Normal file
|
@ -0,0 +1,81 @@
|
|||
// @ts-check
|
||||
|
||||
import webpack from "webpack";
|
||||
import TerserPlugin from "terser-webpack-plugin";
|
||||
import { __dirname, importWithTypeJson } from "../test/esm-helpers.mjs";
|
||||
const libraryPackageJson = await importWithTypeJson(import.meta, "../package.json");
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-jsdoc
|
||||
function config(options) {
|
||||
const { entry, filename, mode, optimization, packageJson } = options;
|
||||
const { name, version, homepage, license } = packageJson;
|
||||
return {
|
||||
"devtool": false,
|
||||
"entry": entry,
|
||||
"externals": {
|
||||
"markdown-it": "markdownit"
|
||||
},
|
||||
"mode": mode,
|
||||
"name": name,
|
||||
"optimization": optimization,
|
||||
"output": {
|
||||
"filename": filename,
|
||||
"library": {
|
||||
"name": name.replace(/(-\w)/g, (m) => m.slice(1).toUpperCase()),
|
||||
"type": "var"
|
||||
},
|
||||
"path": __dirname(import.meta)
|
||||
},
|
||||
"plugins": [
|
||||
new webpack.BannerPlugin({
|
||||
"banner": `${name} ${version} ${homepage} @license ${license}`
|
||||
})
|
||||
],
|
||||
"ignoreWarnings": [
|
||||
{
|
||||
"message": /(asset|entrypoint) size limit/
|
||||
},
|
||||
{
|
||||
"message": /dependencies cannot be statically extracted/
|
||||
},
|
||||
{
|
||||
"message": /lazy load some parts of your application/
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
|
||||
const modeDevelopment = {
|
||||
"mode": "development"
|
||||
};
|
||||
const modeProduction = {
|
||||
"mode": "production",
|
||||
"optimization": {
|
||||
"minimizer": [
|
||||
new TerserPlugin({
|
||||
"extractComments": false,
|
||||
"terserOptions": {
|
||||
"compress": {
|
||||
"passes": 2
|
||||
}
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
};
|
||||
const entryLibrary = {
|
||||
"entry": "./browser-exports.mjs",
|
||||
"packageJson": libraryPackageJson
|
||||
};
|
||||
export default [
|
||||
config({
|
||||
...entryLibrary,
|
||||
...modeDevelopment,
|
||||
"filename": "markdownlint-browser.js"
|
||||
}),
|
||||
config({
|
||||
...entryLibrary,
|
||||
...modeProduction,
|
||||
"filename": "markdownlint-browser.min.js"
|
||||
})
|
||||
];
|
|
@ -1,8 +1,8 @@
|
|||
import { readFile, writeFile } from "node:fs/promises";
|
||||
import { EOL } from "node:os";
|
||||
import { default as rules } from "../lib/rules.js";
|
||||
import { newLineRe } from "../helpers/helpers.js";
|
||||
import { deprecatedRuleNames, fixableRuleNames } from "../lib/constants.js";
|
||||
import rules from "../lib/rules.mjs";
|
||||
import { newLineRe } from "../helpers/helpers.cjs";
|
||||
import { deprecatedRuleNames, fixableRuleNames } from "../lib/constants.mjs";
|
||||
|
||||
const maxLineLength = 80;
|
||||
|
||||
|
|
|
@ -13,4 +13,8 @@ To fix, remove any extraneous space:
|
|||
> indentation.
|
||||
```
|
||||
|
||||
Inferring intended list indentation within a blockquote can be challenging;
|
||||
setting the `list_items` parameter to `false` disables this rule for ordered
|
||||
and unordered list items.
|
||||
|
||||
Rationale: Consistent formatting makes it easier to understand a document.
|
||||
|
|
|
@ -1,32 +1,44 @@
|
|||
This rule is triggered for code span elements that have spaces adjacent to the
|
||||
backticks:
|
||||
This rule is triggered for code spans containing content with unnecessary space
|
||||
next to the beginning or ending backticks:
|
||||
|
||||
```markdown
|
||||
`some text `
|
||||
|
||||
` some text`
|
||||
|
||||
` some text `
|
||||
```
|
||||
|
||||
To fix this, remove any spaces adjacent to the backticks:
|
||||
To fix this, remove the extra space characters from the beginning and ending:
|
||||
|
||||
```markdown
|
||||
`some text`
|
||||
```
|
||||
|
||||
Note: A single leading and trailing space is allowed by the specification and
|
||||
automatically trimmed (in order to allow for code spans that embed backticks):
|
||||
Note: A single leading *and* trailing space is allowed by the specification and
|
||||
trimmed by the parser to support code spans that begin or end with a backtick:
|
||||
|
||||
```markdown
|
||||
`` `backticks` ``
|
||||
|
||||
`` backtick` ``
|
||||
```
|
||||
|
||||
Note: A single leading or trailing space is allowed if used to separate code
|
||||
span markers from an embedded backtick (though the space is not trimmed):
|
||||
Note: When single-space padding is present in the input, it will be preserved
|
||||
(even if unnecessary):
|
||||
|
||||
```markdown
|
||||
`` ` embedded backtick``
|
||||
` code `
|
||||
```
|
||||
|
||||
Rationale: Violations of this rule are usually unintentional and may lead to
|
||||
improperly-rendered content. If spaces beside backticks are intentional, this
|
||||
rule can be disabled for that line or file.
|
||||
Note: Code spans containing only spaces are allowed by the specification and are
|
||||
also preserved:
|
||||
|
||||
```markdown
|
||||
` `
|
||||
|
||||
` `
|
||||
```
|
||||
|
||||
Rationale: Violations of this rule are usually unintentional and can lead to
|
||||
improperly-rendered content.
|
||||
|
|
|
@ -1,37 +1,50 @@
|
|||
This rule is intended to ensure documents have a title and is triggered when
|
||||
the first line in the file isn't a top-level (h1) heading:
|
||||
the first line in a document is not a top-level ([HTML][HTML] `h1`) heading:
|
||||
|
||||
```markdown
|
||||
This is a file without a heading
|
||||
This is a document without a heading
|
||||
```
|
||||
|
||||
To fix this, add a top-level heading to the beginning of the file:
|
||||
To fix this, add a top-level heading to the beginning of the document:
|
||||
|
||||
```markdown
|
||||
# File with heading
|
||||
# Document Heading
|
||||
|
||||
This is a file with a top-level heading
|
||||
This is a document with a top-level heading
|
||||
```
|
||||
|
||||
Because it is common for projects on GitHub to use an image for the heading of
|
||||
`README.md` and that is not well-supported by Markdown, HTML headings are also
|
||||
permitted by this rule. For example:
|
||||
`README.md` and that pattern is not well-supported by Markdown, HTML headings
|
||||
are also permitted by this rule. For example:
|
||||
|
||||
```markdown
|
||||
<h1 align="center"><img src="https://placekitten.com/300/150"/></h1>
|
||||
|
||||
This is a file with a top-level HTML heading
|
||||
This is a document with a top-level HTML heading
|
||||
```
|
||||
|
||||
Note: The `level` parameter can be used to change the top-level (ex: to h2) in
|
||||
cases where an h1 is added externally.
|
||||
In some cases, a document's title heading may be preceded by text like a table
|
||||
of contents. This is not ideal for accessibility, but can be allowed by setting
|
||||
the `allow_preamble` parameter to `true`.
|
||||
|
||||
If [YAML](https://en.wikipedia.org/wiki/YAML) front matter is present and
|
||||
contains a `title` property (commonly used with blog posts), this rule will not
|
||||
report a violation. To use a different property name in the front matter,
|
||||
specify the text of a regular expression via the `front_matter_title` parameter.
|
||||
To disable the use of front matter by this rule, specify `""` for
|
||||
`front_matter_title`.
|
||||
```markdown
|
||||
This is a document with preamble text
|
||||
|
||||
# Document Heading
|
||||
```
|
||||
|
||||
If [YAML][YAML] front matter is present and contains a `title` property
|
||||
(commonly used with blog posts), this rule will not report a violation. To use a
|
||||
different property name in the front matter, specify the text of a [regular
|
||||
expression][RegExp] via the `front_matter_title` parameter. To disable the use
|
||||
of front matter by this rule, specify `""` for `front_matter_title`.
|
||||
|
||||
The `level` parameter can be used to change the top-level heading (ex: to `h2`)
|
||||
in cases where an `h1` is added externally.
|
||||
|
||||
Rationale: The top-level heading often acts as the title of a document. More
|
||||
information: <https://cirosantilli.com/markdown-style-guide#top-level-header>.
|
||||
|
||||
[HTML]: https://en.wikipedia.org/wiki/HTML
|
||||
[RegExp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions
|
||||
[YAML]: https://en.wikipedia.org/wiki/YAML
|
||||
|
|
|
@ -5,7 +5,7 @@ structure for a set of files.
|
|||
To require exactly the following structure:
|
||||
|
||||
```markdown
|
||||
# Head
|
||||
# Heading
|
||||
## Item
|
||||
### Detail
|
||||
```
|
||||
|
@ -14,7 +14,7 @@ Set the `headings` parameter to:
|
|||
|
||||
```json
|
||||
[
|
||||
"# Head",
|
||||
"# Heading",
|
||||
"## Item",
|
||||
"### Detail"
|
||||
]
|
||||
|
@ -23,7 +23,7 @@ Set the `headings` parameter to:
|
|||
To allow optional headings as with the following structure:
|
||||
|
||||
```markdown
|
||||
# Head
|
||||
# Heading
|
||||
## Item
|
||||
### Detail (optional)
|
||||
## Foot
|
||||
|
@ -36,7 +36,7 @@ special value `"+"` meaning "one or more unspecified headings" and set the
|
|||
|
||||
```json
|
||||
[
|
||||
"# Head",
|
||||
"# Heading",
|
||||
"## Item",
|
||||
"*",
|
||||
"## Foot",
|
||||
|
@ -44,6 +44,24 @@ special value `"+"` meaning "one or more unspecified headings" and set the
|
|||
]
|
||||
```
|
||||
|
||||
To allow a single required heading to vary as with a project name:
|
||||
|
||||
```markdown
|
||||
# Project Name
|
||||
## Description
|
||||
## Examples
|
||||
```
|
||||
|
||||
Use the special value `"?"` meaning "exactly one unspecified heading":
|
||||
|
||||
```json
|
||||
[
|
||||
"?",
|
||||
"## Description",
|
||||
"## Examples"
|
||||
]
|
||||
```
|
||||
|
||||
When an error is detected, this rule outputs the line number of the first
|
||||
problematic heading (otherwise, it outputs the last line number of the file).
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
This rule is triggered when an image is missing alternate text (alt text)
|
||||
This rule reports a violation when an image is missing alternate text (alt text)
|
||||
information.
|
||||
|
||||
Alternate text is commonly specified inline as:
|
||||
|
@ -23,12 +23,20 @@ Or with HTML as:
|
|||
<img src="image.jpg" alt="Alternate text" />
|
||||
```
|
||||
|
||||
Note: If the [HTML `aria-hidden` attribute][aria-hidden] is used to hide the
|
||||
image from assistive technology, this rule does not report a violation:
|
||||
|
||||
```html
|
||||
<img src="image.jpg" aria-hidden="true" />
|
||||
```
|
||||
|
||||
Guidance for writing alternate text is available from the [W3C][w3c],
|
||||
[Wikipedia][wikipedia], and [other locations][phase2technology].
|
||||
|
||||
Rationale: Alternate text is important for accessibility and describes the
|
||||
content of an image for people who may not be able to see it.
|
||||
|
||||
[aria-hidden]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-hidden
|
||||
[phase2technology]: https://www.phase2technology.com/blog/no-more-excuses
|
||||
[w3c]: https://www.w3.org/WAI/alt/
|
||||
[wikipedia]: https://en.wikipedia.org/wiki/Alt_attribute
|
||||
|
|
|
@ -52,6 +52,13 @@ attribute can be used to define a fragment:
|
|||
An `a` tag can be useful in scenarios where a heading is not appropriate or for
|
||||
control over the text of the fragment identifier.
|
||||
|
||||
[HTML links to `#top` scroll to the top of a document][html-top-fragment]. This
|
||||
rule allows that syntax (using lower-case for consistency):
|
||||
|
||||
```markdown
|
||||
[Link](#top)
|
||||
```
|
||||
|
||||
This rule also recognizes the custom fragment syntax used by GitHub to highlight
|
||||
[specific content in a document][github-linking-to-content].
|
||||
|
||||
|
@ -67,6 +74,12 @@ And this link to content starting within line 19 running into line 21:
|
|||
[Link](#L19C5-L21C11)
|
||||
```
|
||||
|
||||
Some Markdown generators dynamically create and insert headings when building
|
||||
documents, for example by combining a fixed prefix like `figure-` and an
|
||||
incrementing numeric counter. To ignore such generated fragments, set the
|
||||
`ignored_pattern` [regular expression][RegEx] parameter to a pattern that
|
||||
matches (e.g., `^figure-`).
|
||||
|
||||
Rationale: [GitHub section links][github-section-links] are created
|
||||
automatically for every heading when Markdown content is displayed on GitHub.
|
||||
This makes it easy to link directly to different sections within a document.
|
||||
|
@ -81,3 +94,5 @@ append an incrementing integer as needed for uniqueness.
|
|||
[github-section-links]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links
|
||||
[github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
|
||||
[github-linking-to-content]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet#linking-to-markdown#linking-to-markdown
|
||||
[html-top-fragment]: https://html.spec.whatwg.org/multipage/browsing-the-web.html#scrolling-to-a-fragment
|
||||
[RegEx]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions
|
||||
|
|
|
@ -28,3 +28,14 @@ so "shortcut" syntax is ignored by default. To include "shortcut" syntax, set
|
|||
the `include_shortcut` parameter to `true`. Note that doing so produces warnings
|
||||
for *all* text in the document that *could* be a shortcut. If bracketed text is
|
||||
intentional, brackets can be escaped with the `\` character: `\[example\]`.
|
||||
|
||||
If there are link labels that are deliberately unreferenced, they can be ignored
|
||||
by setting the `ignored_labels` parameter to the list of strings to ignore. The
|
||||
default value of this parameter ignores the checkbox syntax used by
|
||||
[GitHub Flavored Markdown task list items][gfm-tasklist]:
|
||||
|
||||
```markdown
|
||||
- [x] Checked task list item
|
||||
```
|
||||
|
||||
[gfm-tasklist]: https://github.github.com/gfm/#task-list-items-extension-
|
||||
|
|
|
@ -17,9 +17,9 @@ reference has the corresponding label. The "full", "collapsed", and "shortcut"
|
|||
formats are all supported.
|
||||
|
||||
If there are reference definitions that are deliberately unreferenced, they can
|
||||
be ignored by setting the `ignored_definitions` parameter. The default value of
|
||||
this parameter ignores the following convention for adding non-HTML comments to
|
||||
Markdown:
|
||||
be ignored by setting the `ignored_definitions` parameter to the list of strings
|
||||
to ignore. The default value of this parameter ignores the following convention
|
||||
for adding non-HTML comments to Markdown:
|
||||
|
||||
```markdown
|
||||
[//]: # (This behaves like a comment)
|
||||
|
|
19
doc-build/md059.md
Normal file
19
doc-build/md059.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
This rule is triggered when a link has generic text like `[click here](...)` or
|
||||
`[link](...)`.
|
||||
|
||||
Link text should be descriptive and communicate the purpose of the link (e.g.,
|
||||
`[Download the budget document](...)` or `[CommonMark Specification](...)`).
|
||||
This is especially important for screen readers which sometimes present links
|
||||
without context.
|
||||
|
||||
By default, this rule prohibits a small number of common English words/phrases.
|
||||
To customize that list of words/phrases, set the `prohibited_texts` parameter to
|
||||
an `Array` of `string`s.
|
||||
|
||||
Note: For languages other than English, use the `prohibited_texts` parameter to
|
||||
customize the list for that language. It is *not* a goal for this rule to have
|
||||
translations for every language.
|
||||
|
||||
Note: This rule checks Markdown links; HTML links are ignored.
|
||||
|
||||
More information: <https://webaim.org/techniques/hypertext/>
|
|
@ -36,7 +36,7 @@ A simple rule implementation using the `micromark` parser to report a violation
|
|||
for any use of blockquotes might look like:
|
||||
|
||||
```javascript
|
||||
/** @type import("markdownlint").Rule */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
module.exports = {
|
||||
"names": [ "any-blockquote-micromark" ],
|
||||
"description": "Rule that reports an error for any blockquote",
|
||||
|
@ -61,7 +61,7 @@ module.exports = {
|
|||
That same rule implemented using the `markdown-it` parser might look like:
|
||||
|
||||
```javascript
|
||||
/** @type import("markdownlint").Rule */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
module.exports = {
|
||||
"names": [ "any-blockquote-markdown-it" ],
|
||||
"description": "Rule that reports an error for any blockquote",
|
||||
|
@ -160,8 +160,8 @@ implementation that is resolved when the rule completes. (The value passed to
|
|||
reported via the `onError` function just like for synchronous rules.
|
||||
|
||||
**Note**: Asynchronous rules cannot be referenced in a synchronous calling
|
||||
context (i.e., `markdownlint.sync(...)`). Attempting to do so throws an
|
||||
exception.
|
||||
context (i.e., `import { lint } from "markdownlint/sync"`). Attempting to do so
|
||||
throws an exception.
|
||||
|
||||
## Examples
|
||||
|
||||
|
@ -187,8 +187,8 @@ exception.
|
|||
[markdown-it-token]: https://markdown-it.github.io/markdown-it/#Token
|
||||
[markdownlint-rule]: https://www.npmjs.com/search?q=keywords:markdownlint-rule
|
||||
[micromark]: https://github.com/micromark/micromark
|
||||
[micromark-token]: ../lib/markdownlint.d.ts
|
||||
[micromark-token]: ../lib/markdownlint.d.mts
|
||||
[rule-helpers]: https://www.npmjs.com/package/markdownlint-rule-helpers
|
||||
[options-custom-rules]: ../README.md#optionscustomrules
|
||||
[test-rules]: ../test/rules
|
||||
[tokens]: ../test/snapshots/markdownlint-test-custom-rules.js.md
|
||||
[tokens]: ../test/snapshots/markdownlint-test-custom-rules.mjs.md
|
||||
|
|
193
doc/Rules.md
193
doc/Rules.md
|
@ -943,6 +943,10 @@ Tags: `blockquote`, `indentation`, `whitespace`
|
|||
|
||||
Aliases: `no-multiple-space-blockquote`
|
||||
|
||||
Parameters:
|
||||
|
||||
- `list_items`: Include list items (`boolean`, default `true`)
|
||||
|
||||
Fixable: Some violations can be fixed by tooling
|
||||
|
||||
This rule is triggered when blockquotes have more than one space after the
|
||||
|
@ -960,6 +964,10 @@ To fix, remove any extraneous space:
|
|||
> indentation.
|
||||
```
|
||||
|
||||
Inferring intended list indentation within a blockquote can be challenging;
|
||||
setting the `list_items` parameter to `false` disables this rule for ordered
|
||||
and unordered list items.
|
||||
|
||||
Rationale: Consistent formatting makes it easier to understand a document.
|
||||
|
||||
<a name="md028"></a>
|
||||
|
@ -1528,38 +1536,50 @@ Aliases: `no-space-in-code`
|
|||
|
||||
Fixable: Some violations can be fixed by tooling
|
||||
|
||||
This rule is triggered for code span elements that have spaces adjacent to the
|
||||
backticks:
|
||||
This rule is triggered for code spans containing content with unnecessary space
|
||||
next to the beginning or ending backticks:
|
||||
|
||||
```markdown
|
||||
`some text `
|
||||
|
||||
` some text`
|
||||
|
||||
` some text `
|
||||
```
|
||||
|
||||
To fix this, remove any spaces adjacent to the backticks:
|
||||
To fix this, remove the extra space characters from the beginning and ending:
|
||||
|
||||
```markdown
|
||||
`some text`
|
||||
```
|
||||
|
||||
Note: A single leading and trailing space is allowed by the specification and
|
||||
automatically trimmed (in order to allow for code spans that embed backticks):
|
||||
Note: A single leading *and* trailing space is allowed by the specification and
|
||||
trimmed by the parser to support code spans that begin or end with a backtick:
|
||||
|
||||
```markdown
|
||||
`` `backticks` ``
|
||||
|
||||
`` backtick` ``
|
||||
```
|
||||
|
||||
Note: A single leading or trailing space is allowed if used to separate code
|
||||
span markers from an embedded backtick (though the space is not trimmed):
|
||||
Note: When single-space padding is present in the input, it will be preserved
|
||||
(even if unnecessary):
|
||||
|
||||
```markdown
|
||||
`` ` embedded backtick``
|
||||
` code `
|
||||
```
|
||||
|
||||
Rationale: Violations of this rule are usually unintentional and may lead to
|
||||
improperly-rendered content. If spaces beside backticks are intentional, this
|
||||
rule can be disabled for that line or file.
|
||||
Note: Code spans containing only spaces are allowed by the specification and are
|
||||
also preserved:
|
||||
|
||||
```markdown
|
||||
` `
|
||||
|
||||
` `
|
||||
```
|
||||
|
||||
Rationale: Violations of this rule are usually unintentional and can lead to
|
||||
improperly-rendered content.
|
||||
|
||||
<a name="md039"></a>
|
||||
|
||||
|
@ -1650,48 +1670,63 @@ Aliases: `first-line-h1`, `first-line-heading`
|
|||
|
||||
Parameters:
|
||||
|
||||
- `allow_preamble`: Allow content before first heading (`boolean`, default
|
||||
`false`)
|
||||
- `front_matter_title`: RegExp for matching title in front matter (`string`,
|
||||
default `^\s*title\s*[:=]`)
|
||||
- `level`: Heading level (`integer`, default `1`)
|
||||
|
||||
This rule is intended to ensure documents have a title and is triggered when
|
||||
the first line in the file isn't a top-level (h1) heading:
|
||||
the first line in a document is not a top-level ([HTML][HTML] `h1`) heading:
|
||||
|
||||
```markdown
|
||||
This is a file without a heading
|
||||
This is a document without a heading
|
||||
```
|
||||
|
||||
To fix this, add a top-level heading to the beginning of the file:
|
||||
To fix this, add a top-level heading to the beginning of the document:
|
||||
|
||||
```markdown
|
||||
# File with heading
|
||||
# Document Heading
|
||||
|
||||
This is a file with a top-level heading
|
||||
This is a document with a top-level heading
|
||||
```
|
||||
|
||||
Because it is common for projects on GitHub to use an image for the heading of
|
||||
`README.md` and that is not well-supported by Markdown, HTML headings are also
|
||||
permitted by this rule. For example:
|
||||
`README.md` and that pattern is not well-supported by Markdown, HTML headings
|
||||
are also permitted by this rule. For example:
|
||||
|
||||
```markdown
|
||||
<h1 align="center"><img src="https://placekitten.com/300/150"/></h1>
|
||||
|
||||
This is a file with a top-level HTML heading
|
||||
This is a document with a top-level HTML heading
|
||||
```
|
||||
|
||||
Note: The `level` parameter can be used to change the top-level (ex: to h2) in
|
||||
cases where an h1 is added externally.
|
||||
In some cases, a document's title heading may be preceded by text like a table
|
||||
of contents. This is not ideal for accessibility, but can be allowed by setting
|
||||
the `allow_preamble` parameter to `true`.
|
||||
|
||||
If [YAML](https://en.wikipedia.org/wiki/YAML) front matter is present and
|
||||
contains a `title` property (commonly used with blog posts), this rule will not
|
||||
report a violation. To use a different property name in the front matter,
|
||||
specify the text of a regular expression via the `front_matter_title` parameter.
|
||||
To disable the use of front matter by this rule, specify `""` for
|
||||
`front_matter_title`.
|
||||
```markdown
|
||||
This is a document with preamble text
|
||||
|
||||
# Document Heading
|
||||
```
|
||||
|
||||
If [YAML][YAML] front matter is present and contains a `title` property
|
||||
(commonly used with blog posts), this rule will not report a violation. To use a
|
||||
different property name in the front matter, specify the text of a [regular
|
||||
expression][RegExp] via the `front_matter_title` parameter. To disable the use
|
||||
of front matter by this rule, specify `""` for `front_matter_title`.
|
||||
|
||||
The `level` parameter can be used to change the top-level heading (ex: to `h2`)
|
||||
in cases where an `h1` is added externally.
|
||||
|
||||
Rationale: The top-level heading often acts as the title of a document. More
|
||||
information: <https://cirosantilli.com/markdown-style-guide#top-level-header>.
|
||||
|
||||
[HTML]: https://en.wikipedia.org/wiki/HTML
|
||||
[RegExp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions
|
||||
[YAML]: https://en.wikipedia.org/wiki/YAML
|
||||
|
||||
<a name="md042"></a>
|
||||
|
||||
## `MD042` - No empty links
|
||||
|
@ -1747,7 +1782,7 @@ structure for a set of files.
|
|||
To require exactly the following structure:
|
||||
|
||||
```markdown
|
||||
# Head
|
||||
# Heading
|
||||
## Item
|
||||
### Detail
|
||||
```
|
||||
|
@ -1756,7 +1791,7 @@ Set the `headings` parameter to:
|
|||
|
||||
```json
|
||||
[
|
||||
"# Head",
|
||||
"# Heading",
|
||||
"## Item",
|
||||
"### Detail"
|
||||
]
|
||||
|
@ -1765,7 +1800,7 @@ Set the `headings` parameter to:
|
|||
To allow optional headings as with the following structure:
|
||||
|
||||
```markdown
|
||||
# Head
|
||||
# Heading
|
||||
## Item
|
||||
### Detail (optional)
|
||||
## Foot
|
||||
|
@ -1778,7 +1813,7 @@ special value `"+"` meaning "one or more unspecified headings" and set the
|
|||
|
||||
```json
|
||||
[
|
||||
"# Head",
|
||||
"# Heading",
|
||||
"## Item",
|
||||
"*",
|
||||
"## Foot",
|
||||
|
@ -1786,6 +1821,24 @@ special value `"+"` meaning "one or more unspecified headings" and set the
|
|||
]
|
||||
```
|
||||
|
||||
To allow a single required heading to vary as with a project name:
|
||||
|
||||
```markdown
|
||||
# Project Name
|
||||
## Description
|
||||
## Examples
|
||||
```
|
||||
|
||||
Use the special value `"?"` meaning "exactly one unspecified heading":
|
||||
|
||||
```json
|
||||
[
|
||||
"?",
|
||||
"## Description",
|
||||
"## Examples"
|
||||
]
|
||||
```
|
||||
|
||||
When an error is detected, this rule outputs the line number of the first
|
||||
problematic heading (otherwise, it outputs the last line number of the file).
|
||||
|
||||
|
@ -1855,7 +1908,7 @@ Tags: `accessibility`, `images`
|
|||
|
||||
Aliases: `no-alt-text`
|
||||
|
||||
This rule is triggered when an image is missing alternate text (alt text)
|
||||
This rule reports a violation when an image is missing alternate text (alt text)
|
||||
information.
|
||||
|
||||
Alternate text is commonly specified inline as:
|
||||
|
@ -1880,12 +1933,20 @@ Or with HTML as:
|
|||
<img src="image.jpg" alt="Alternate text" />
|
||||
```
|
||||
|
||||
Note: If the [HTML `aria-hidden` attribute][aria-hidden] is used to hide the
|
||||
image from assistive technology, this rule does not report a violation:
|
||||
|
||||
```html
|
||||
<img src="image.jpg" aria-hidden="true" />
|
||||
```
|
||||
|
||||
Guidance for writing alternate text is available from the [W3C][w3c],
|
||||
[Wikipedia][wikipedia], and [other locations][phase2technology].
|
||||
|
||||
Rationale: Alternate text is important for accessibility and describes the
|
||||
content of an image for people who may not be able to see it.
|
||||
|
||||
[aria-hidden]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-hidden
|
||||
[phase2technology]: https://www.phase2technology.com/blog/no-more-excuses
|
||||
[w3c]: https://www.w3.org/WAI/alt/
|
||||
[wikipedia]: https://en.wikipedia.org/wiki/Alt_attribute
|
||||
|
@ -2103,6 +2164,8 @@ Aliases: `link-fragments`
|
|||
Parameters:
|
||||
|
||||
- `ignore_case`: Ignore case of fragments (`boolean`, default `false`)
|
||||
- `ignored_pattern`: Pattern for ignoring additional fragments (`string`,
|
||||
default ``)
|
||||
|
||||
Fixable: Some violations can be fixed by tooling
|
||||
|
||||
|
@ -2160,6 +2223,13 @@ attribute can be used to define a fragment:
|
|||
An `a` tag can be useful in scenarios where a heading is not appropriate or for
|
||||
control over the text of the fragment identifier.
|
||||
|
||||
[HTML links to `#top` scroll to the top of a document][html-top-fragment]. This
|
||||
rule allows that syntax (using lower-case for consistency):
|
||||
|
||||
```markdown
|
||||
[Link](#top)
|
||||
```
|
||||
|
||||
This rule also recognizes the custom fragment syntax used by GitHub to highlight
|
||||
[specific content in a document][github-linking-to-content].
|
||||
|
||||
|
@ -2175,6 +2245,12 @@ And this link to content starting within line 19 running into line 21:
|
|||
[Link](#L19C5-L21C11)
|
||||
```
|
||||
|
||||
Some Markdown generators dynamically create and insert headings when building
|
||||
documents, for example by combining a fixed prefix like `figure-` and an
|
||||
incrementing numeric counter. To ignore such generated fragments, set the
|
||||
`ignored_pattern` [regular expression][RegEx] parameter to a pattern that
|
||||
matches (e.g., `^figure-`).
|
||||
|
||||
Rationale: [GitHub section links][github-section-links] are created
|
||||
automatically for every heading when Markdown content is displayed on GitHub.
|
||||
This makes it easy to link directly to different sections within a document.
|
||||
|
@ -2189,6 +2265,8 @@ append an incrementing integer as needed for uniqueness.
|
|||
[github-section-links]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links
|
||||
[github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
|
||||
[github-linking-to-content]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet#linking-to-markdown#linking-to-markdown
|
||||
[html-top-fragment]: https://html.spec.whatwg.org/multipage/browsing-the-web.html#scrolling-to-a-fragment
|
||||
[RegEx]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions
|
||||
|
||||
<a name="md052"></a>
|
||||
|
||||
|
@ -2200,6 +2278,7 @@ Aliases: `reference-links-images`
|
|||
|
||||
Parameters:
|
||||
|
||||
- `ignored_labels`: Ignored link labels (`string[]`, default `["x"]`)
|
||||
- `shortcut_syntax`: Include shortcut syntax (`boolean`, default `false`)
|
||||
|
||||
Links and images in Markdown can provide the link destination or image source
|
||||
|
@ -2233,6 +2312,17 @@ the `include_shortcut` parameter to `true`. Note that doing so produces warnings
|
|||
for *all* text in the document that *could* be a shortcut. If bracketed text is
|
||||
intentional, brackets can be escaped with the `\` character: `\[example\]`.
|
||||
|
||||
If there are link labels that are deliberately unreferenced, they can be ignored
|
||||
by setting the `ignored_labels` parameter to the list of strings to ignore. The
|
||||
default value of this parameter ignores the checkbox syntax used by
|
||||
[GitHub Flavored Markdown task list items][gfm-tasklist]:
|
||||
|
||||
```markdown
|
||||
- [x] Checked task list item
|
||||
```
|
||||
|
||||
[gfm-tasklist]: https://github.github.com/gfm/#task-list-items-extension-
|
||||
|
||||
<a name="md053"></a>
|
||||
|
||||
## `MD053` - Link and image reference definitions should be needed
|
||||
|
@ -2266,9 +2356,9 @@ reference has the corresponding label. The "full", "collapsed", and "shortcut"
|
|||
formats are all supported.
|
||||
|
||||
If there are reference definitions that are deliberately unreferenced, they can
|
||||
be ignored by setting the `ignored_definitions` parameter. The default value of
|
||||
this parameter ignores the following convention for adding non-HTML comments to
|
||||
Markdown:
|
||||
be ignored by setting the `ignored_definitions` parameter to the list of strings
|
||||
to ignore. The default value of this parameter ignores the following convention
|
||||
for adding non-HTML comments to Markdown:
|
||||
|
||||
```markdown
|
||||
[//]: # (This behaves like a comment)
|
||||
|
@ -2526,6 +2616,39 @@ Some text
|
|||
Rationale: In addition to aesthetic reasons, some parsers will incorrectly parse
|
||||
tables that don't have blank lines before and after them.
|
||||
|
||||
<a name="md059"></a>
|
||||
|
||||
## `MD059` - Link text should be descriptive
|
||||
|
||||
Tags: `accessibility`, `links`
|
||||
|
||||
Aliases: `descriptive-link-text`
|
||||
|
||||
Parameters:
|
||||
|
||||
- `prohibited_texts`: Prohibited link texts (`string[]`, default `["click
|
||||
here","here","link","more"]`)
|
||||
|
||||
This rule is triggered when a link has generic text like `[click here](...)` or
|
||||
`[link](...)`.
|
||||
|
||||
Link text should be descriptive and communicate the purpose of the link (e.g.,
|
||||
`[Download the budget document](...)` or `[CommonMark Specification](...)`).
|
||||
This is especially important for screen readers which sometimes present links
|
||||
without context.
|
||||
|
||||
By default, this rule prohibits a small number of common English words/phrases.
|
||||
To customize that list of words/phrases, set the `prohibited_texts` parameter to
|
||||
an `Array` of `string`s.
|
||||
|
||||
Note: For languages other than English, use the `prohibited_texts` parameter to
|
||||
customize the list for that language. It is *not* a goal for this rule to have
|
||||
translations for every language.
|
||||
|
||||
Note: This rule checks Markdown links; HTML links are ignored.
|
||||
|
||||
More information: <https://webaim.org/techniques/hypertext/>
|
||||
|
||||
<!-- markdownlint-configure-file {
|
||||
"no-inline-html": {
|
||||
"allowed_elements": [
|
||||
|
|
|
@ -4,6 +4,10 @@ Tags: `blockquote`, `indentation`, `whitespace`
|
|||
|
||||
Aliases: `no-multiple-space-blockquote`
|
||||
|
||||
Parameters:
|
||||
|
||||
- `list_items`: Include list items (`boolean`, default `true`)
|
||||
|
||||
Fixable: Some violations can be fixed by tooling
|
||||
|
||||
This rule is triggered when blockquotes have more than one space after the
|
||||
|
@ -21,4 +25,8 @@ To fix, remove any extraneous space:
|
|||
> indentation.
|
||||
```
|
||||
|
||||
Inferring intended list indentation within a blockquote can be challenging;
|
||||
setting the `list_items` parameter to `false` disables this rule for ordered
|
||||
and unordered list items.
|
||||
|
||||
Rationale: Consistent formatting makes it easier to understand a document.
|
||||
|
|
34
doc/md038.md
34
doc/md038.md
|
@ -6,35 +6,47 @@ Aliases: `no-space-in-code`
|
|||
|
||||
Fixable: Some violations can be fixed by tooling
|
||||
|
||||
This rule is triggered for code span elements that have spaces adjacent to the
|
||||
backticks:
|
||||
This rule is triggered for code spans containing content with unnecessary space
|
||||
next to the beginning or ending backticks:
|
||||
|
||||
```markdown
|
||||
`some text `
|
||||
|
||||
` some text`
|
||||
|
||||
` some text `
|
||||
```
|
||||
|
||||
To fix this, remove any spaces adjacent to the backticks:
|
||||
To fix this, remove the extra space characters from the beginning and ending:
|
||||
|
||||
```markdown
|
||||
`some text`
|
||||
```
|
||||
|
||||
Note: A single leading and trailing space is allowed by the specification and
|
||||
automatically trimmed (in order to allow for code spans that embed backticks):
|
||||
Note: A single leading *and* trailing space is allowed by the specification and
|
||||
trimmed by the parser to support code spans that begin or end with a backtick:
|
||||
|
||||
```markdown
|
||||
`` `backticks` ``
|
||||
|
||||
`` backtick` ``
|
||||
```
|
||||
|
||||
Note: A single leading or trailing space is allowed if used to separate code
|
||||
span markers from an embedded backtick (though the space is not trimmed):
|
||||
Note: When single-space padding is present in the input, it will be preserved
|
||||
(even if unnecessary):
|
||||
|
||||
```markdown
|
||||
`` ` embedded backtick``
|
||||
` code `
|
||||
```
|
||||
|
||||
Rationale: Violations of this rule are usually unintentional and may lead to
|
||||
improperly-rendered content. If spaces beside backticks are intentional, this
|
||||
rule can be disabled for that line or file.
|
||||
Note: Code spans containing only spaces are allowed by the specification and are
|
||||
also preserved:
|
||||
|
||||
```markdown
|
||||
` `
|
||||
|
||||
` `
|
||||
```
|
||||
|
||||
Rationale: Violations of this rule are usually unintentional and can lead to
|
||||
improperly-rendered content.
|
||||
|
|
47
doc/md041.md
47
doc/md041.md
|
@ -6,44 +6,59 @@ Aliases: `first-line-h1`, `first-line-heading`
|
|||
|
||||
Parameters:
|
||||
|
||||
- `allow_preamble`: Allow content before first heading (`boolean`, default
|
||||
`false`)
|
||||
- `front_matter_title`: RegExp for matching title in front matter (`string`,
|
||||
default `^\s*title\s*[:=]`)
|
||||
- `level`: Heading level (`integer`, default `1`)
|
||||
|
||||
This rule is intended to ensure documents have a title and is triggered when
|
||||
the first line in the file isn't a top-level (h1) heading:
|
||||
the first line in a document is not a top-level ([HTML][HTML] `h1`) heading:
|
||||
|
||||
```markdown
|
||||
This is a file without a heading
|
||||
This is a document without a heading
|
||||
```
|
||||
|
||||
To fix this, add a top-level heading to the beginning of the file:
|
||||
To fix this, add a top-level heading to the beginning of the document:
|
||||
|
||||
```markdown
|
||||
# File with heading
|
||||
# Document Heading
|
||||
|
||||
This is a file with a top-level heading
|
||||
This is a document with a top-level heading
|
||||
```
|
||||
|
||||
Because it is common for projects on GitHub to use an image for the heading of
|
||||
`README.md` and that is not well-supported by Markdown, HTML headings are also
|
||||
permitted by this rule. For example:
|
||||
`README.md` and that pattern is not well-supported by Markdown, HTML headings
|
||||
are also permitted by this rule. For example:
|
||||
|
||||
```markdown
|
||||
<h1 align="center"><img src="https://placekitten.com/300/150"/></h1>
|
||||
|
||||
This is a file with a top-level HTML heading
|
||||
This is a document with a top-level HTML heading
|
||||
```
|
||||
|
||||
Note: The `level` parameter can be used to change the top-level (ex: to h2) in
|
||||
cases where an h1 is added externally.
|
||||
In some cases, a document's title heading may be preceded by text like a table
|
||||
of contents. This is not ideal for accessibility, but can be allowed by setting
|
||||
the `allow_preamble` parameter to `true`.
|
||||
|
||||
If [YAML](https://en.wikipedia.org/wiki/YAML) front matter is present and
|
||||
contains a `title` property (commonly used with blog posts), this rule will not
|
||||
report a violation. To use a different property name in the front matter,
|
||||
specify the text of a regular expression via the `front_matter_title` parameter.
|
||||
To disable the use of front matter by this rule, specify `""` for
|
||||
`front_matter_title`.
|
||||
```markdown
|
||||
This is a document with preamble text
|
||||
|
||||
# Document Heading
|
||||
```
|
||||
|
||||
If [YAML][YAML] front matter is present and contains a `title` property
|
||||
(commonly used with blog posts), this rule will not report a violation. To use a
|
||||
different property name in the front matter, specify the text of a [regular
|
||||
expression][RegExp] via the `front_matter_title` parameter. To disable the use
|
||||
of front matter by this rule, specify `""` for `front_matter_title`.
|
||||
|
||||
The `level` parameter can be used to change the top-level heading (ex: to `h2`)
|
||||
in cases where an `h1` is added externally.
|
||||
|
||||
Rationale: The top-level heading often acts as the title of a document. More
|
||||
information: <https://cirosantilli.com/markdown-style-guide#top-level-header>.
|
||||
|
||||
[HTML]: https://en.wikipedia.org/wiki/HTML
|
||||
[RegExp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions
|
||||
[YAML]: https://en.wikipedia.org/wiki/YAML
|
||||
|
|
26
doc/md043.md
26
doc/md043.md
|
@ -16,7 +16,7 @@ structure for a set of files.
|
|||
To require exactly the following structure:
|
||||
|
||||
```markdown
|
||||
# Head
|
||||
# Heading
|
||||
## Item
|
||||
### Detail
|
||||
```
|
||||
|
@ -25,7 +25,7 @@ Set the `headings` parameter to:
|
|||
|
||||
```json
|
||||
[
|
||||
"# Head",
|
||||
"# Heading",
|
||||
"## Item",
|
||||
"### Detail"
|
||||
]
|
||||
|
@ -34,7 +34,7 @@ Set the `headings` parameter to:
|
|||
To allow optional headings as with the following structure:
|
||||
|
||||
```markdown
|
||||
# Head
|
||||
# Heading
|
||||
## Item
|
||||
### Detail (optional)
|
||||
## Foot
|
||||
|
@ -47,7 +47,7 @@ special value `"+"` meaning "one or more unspecified headings" and set the
|
|||
|
||||
```json
|
||||
[
|
||||
"# Head",
|
||||
"# Heading",
|
||||
"## Item",
|
||||
"*",
|
||||
"## Foot",
|
||||
|
@ -55,6 +55,24 @@ special value `"+"` meaning "one or more unspecified headings" and set the
|
|||
]
|
||||
```
|
||||
|
||||
To allow a single required heading to vary as with a project name:
|
||||
|
||||
```markdown
|
||||
# Project Name
|
||||
## Description
|
||||
## Examples
|
||||
```
|
||||
|
||||
Use the special value `"?"` meaning "exactly one unspecified heading":
|
||||
|
||||
```json
|
||||
[
|
||||
"?",
|
||||
"## Description",
|
||||
"## Examples"
|
||||
]
|
||||
```
|
||||
|
||||
When an error is detected, this rule outputs the line number of the first
|
||||
problematic heading (otherwise, it outputs the last line number of the file).
|
||||
|
||||
|
|
10
doc/md045.md
10
doc/md045.md
|
@ -4,7 +4,7 @@ Tags: `accessibility`, `images`
|
|||
|
||||
Aliases: `no-alt-text`
|
||||
|
||||
This rule is triggered when an image is missing alternate text (alt text)
|
||||
This rule reports a violation when an image is missing alternate text (alt text)
|
||||
information.
|
||||
|
||||
Alternate text is commonly specified inline as:
|
||||
|
@ -29,12 +29,20 @@ Or with HTML as:
|
|||
<img src="image.jpg" alt="Alternate text" />
|
||||
```
|
||||
|
||||
Note: If the [HTML `aria-hidden` attribute][aria-hidden] is used to hide the
|
||||
image from assistive technology, this rule does not report a violation:
|
||||
|
||||
```html
|
||||
<img src="image.jpg" aria-hidden="true" />
|
||||
```
|
||||
|
||||
Guidance for writing alternate text is available from the [W3C][w3c],
|
||||
[Wikipedia][wikipedia], and [other locations][phase2technology].
|
||||
|
||||
Rationale: Alternate text is important for accessibility and describes the
|
||||
content of an image for people who may not be able to see it.
|
||||
|
||||
[aria-hidden]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-hidden
|
||||
[phase2technology]: https://www.phase2technology.com/blog/no-more-excuses
|
||||
[w3c]: https://www.w3.org/WAI/alt/
|
||||
[wikipedia]: https://en.wikipedia.org/wiki/Alt_attribute
|
||||
|
|
17
doc/md051.md
17
doc/md051.md
|
@ -7,6 +7,8 @@ Aliases: `link-fragments`
|
|||
Parameters:
|
||||
|
||||
- `ignore_case`: Ignore case of fragments (`boolean`, default `false`)
|
||||
- `ignored_pattern`: Pattern for ignoring additional fragments (`string`,
|
||||
default ``)
|
||||
|
||||
Fixable: Some violations can be fixed by tooling
|
||||
|
||||
|
@ -64,6 +66,13 @@ attribute can be used to define a fragment:
|
|||
An `a` tag can be useful in scenarios where a heading is not appropriate or for
|
||||
control over the text of the fragment identifier.
|
||||
|
||||
[HTML links to `#top` scroll to the top of a document][html-top-fragment]. This
|
||||
rule allows that syntax (using lower-case for consistency):
|
||||
|
||||
```markdown
|
||||
[Link](#top)
|
||||
```
|
||||
|
||||
This rule also recognizes the custom fragment syntax used by GitHub to highlight
|
||||
[specific content in a document][github-linking-to-content].
|
||||
|
||||
|
@ -79,6 +88,12 @@ And this link to content starting within line 19 running into line 21:
|
|||
[Link](#L19C5-L21C11)
|
||||
```
|
||||
|
||||
Some Markdown generators dynamically create and insert headings when building
|
||||
documents, for example by combining a fixed prefix like `figure-` and an
|
||||
incrementing numeric counter. To ignore such generated fragments, set the
|
||||
`ignored_pattern` [regular expression][RegEx] parameter to a pattern that
|
||||
matches (e.g., `^figure-`).
|
||||
|
||||
Rationale: [GitHub section links][github-section-links] are created
|
||||
automatically for every heading when Markdown content is displayed on GitHub.
|
||||
This makes it easy to link directly to different sections within a document.
|
||||
|
@ -93,3 +108,5 @@ append an incrementing integer as needed for uniqueness.
|
|||
[github-section-links]: https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#section-links
|
||||
[github-heading-algorithm]: https://github.com/gjtorikian/html-pipeline/blob/f13a1534cb650ba17af400d1acd3a22c28004c09/lib/html/pipeline/toc_filter.rb
|
||||
[github-linking-to-content]: https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-a-permanent-link-to-a-code-snippet#linking-to-markdown#linking-to-markdown
|
||||
[html-top-fragment]: https://html.spec.whatwg.org/multipage/browsing-the-web.html#scrolling-to-a-fragment
|
||||
[RegEx]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions
|
||||
|
|
12
doc/md052.md
12
doc/md052.md
|
@ -6,6 +6,7 @@ Aliases: `reference-links-images`
|
|||
|
||||
Parameters:
|
||||
|
||||
- `ignored_labels`: Ignored link labels (`string[]`, default `["x"]`)
|
||||
- `shortcut_syntax`: Include shortcut syntax (`boolean`, default `false`)
|
||||
|
||||
Links and images in Markdown can provide the link destination or image source
|
||||
|
@ -38,3 +39,14 @@ so "shortcut" syntax is ignored by default. To include "shortcut" syntax, set
|
|||
the `include_shortcut` parameter to `true`. Note that doing so produces warnings
|
||||
for *all* text in the document that *could* be a shortcut. If bracketed text is
|
||||
intentional, brackets can be escaped with the `\` character: `\[example\]`.
|
||||
|
||||
If there are link labels that are deliberately unreferenced, they can be ignored
|
||||
by setting the `ignored_labels` parameter to the list of strings to ignore. The
|
||||
default value of this parameter ignores the checkbox syntax used by
|
||||
[GitHub Flavored Markdown task list items][gfm-tasklist]:
|
||||
|
||||
```markdown
|
||||
- [x] Checked task list item
|
||||
```
|
||||
|
||||
[gfm-tasklist]: https://github.github.com/gfm/#task-list-items-extension-
|
||||
|
|
|
@ -29,9 +29,9 @@ reference has the corresponding label. The "full", "collapsed", and "shortcut"
|
|||
formats are all supported.
|
||||
|
||||
If there are reference definitions that are deliberately unreferenced, they can
|
||||
be ignored by setting the `ignored_definitions` parameter. The default value of
|
||||
this parameter ignores the following convention for adding non-HTML comments to
|
||||
Markdown:
|
||||
be ignored by setting the `ignored_definitions` parameter to the list of strings
|
||||
to ignore. The default value of this parameter ignores the following convention
|
||||
for adding non-HTML comments to Markdown:
|
||||
|
||||
```markdown
|
||||
[//]: # (This behaves like a comment)
|
||||
|
|
30
doc/md059.md
Normal file
30
doc/md059.md
Normal file
|
@ -0,0 +1,30 @@
|
|||
# `MD059` - Link text should be descriptive
|
||||
|
||||
Tags: `accessibility`, `links`
|
||||
|
||||
Aliases: `descriptive-link-text`
|
||||
|
||||
Parameters:
|
||||
|
||||
- `prohibited_texts`: Prohibited link texts (`string[]`, default `["click
|
||||
here","here","link","more"]`)
|
||||
|
||||
This rule is triggered when a link has generic text like `[click here](...)` or
|
||||
`[link](...)`.
|
||||
|
||||
Link text should be descriptive and communicate the purpose of the link (e.g.,
|
||||
`[Download the budget document](...)` or `[CommonMark Specification](...)`).
|
||||
This is especially important for screen readers which sometimes present links
|
||||
without context.
|
||||
|
||||
By default, this rule prohibits a small number of common English words/phrases.
|
||||
To customize that list of words/phrases, set the `prohibited_texts` parameter to
|
||||
an `Array` of `string`s.
|
||||
|
||||
Note: For languages other than English, use the `prohibited_texts` parameter to
|
||||
customize the list for that language. It is *not* a goal for this rule to have
|
||||
translations for every language.
|
||||
|
||||
Note: This rule checks Markdown links; HTML links are ignored.
|
||||
|
||||
More information: <https://webaim.org/techniques/hypertext/>
|
|
@ -25,20 +25,11 @@ export default [
|
|||
"demo/markdown-it.min.js",
|
||||
"demo/markdownlint-browser.js",
|
||||
"demo/markdownlint-browser.min.js",
|
||||
"demo/micromark-browser.js",
|
||||
"demo/micromark-html-browser.js",
|
||||
"example/typescript/type-check.js",
|
||||
"micromark/micromark.cjs",
|
||||
"micromark/micromark.dev.cjs",
|
||||
"micromark/micromark-browser.js",
|
||||
"micromark/micromark-browser.dev.js",
|
||||
"example/typescript/type-check-*",
|
||||
"test-repos/**"
|
||||
]
|
||||
},
|
||||
{
|
||||
"languageOptions": {
|
||||
"sourceType": "commonjs"
|
||||
},
|
||||
"linterOptions": {
|
||||
"reportUnusedDisableDirectives": true
|
||||
},
|
||||
|
@ -88,7 +79,6 @@ export default [
|
|||
"unicorn/no-null": "off",
|
||||
"unicorn/no-useless-undefined": "off",
|
||||
"unicorn/prefer-at": "off",
|
||||
"unicorn/prefer-module": "off",
|
||||
"unicorn/prefer-string-raw": "off",
|
||||
"unicorn/prefer-string-replace-all": "off",
|
||||
"unicorn/prefer-string-slice": "off",
|
||||
|
@ -107,15 +97,20 @@ export default [
|
|||
},
|
||||
{
|
||||
"files": [
|
||||
"**/*.mjs"
|
||||
"**/*.js",
|
||||
"**/*.cjs"
|
||||
],
|
||||
"languageOptions": {
|
||||
"sourceType": "module"
|
||||
"sourceType": "commonjs",
|
||||
"globals": {
|
||||
"module": "readonly",
|
||||
"require": "readonly"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"demo/*.js"
|
||||
"demo/default.js"
|
||||
],
|
||||
"languageOptions": {
|
||||
"globals": {
|
||||
|
@ -131,26 +126,42 @@ export default [
|
|||
"no-invalid-this": "off",
|
||||
"no-shadow": "off",
|
||||
"no-var": "off",
|
||||
"unicorn/prefer-module": "off",
|
||||
"unicorn/prefer-query-selector": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"example/*.js"
|
||||
"example/*.cjs"
|
||||
],
|
||||
"languageOptions": {
|
||||
"sourceType": "commonjs"
|
||||
},
|
||||
"rules": {
|
||||
"n/no-missing-require": "off",
|
||||
"no-console": "off",
|
||||
"no-invalid-this": "off",
|
||||
"no-shadow": "off"
|
||||
"no-invalid-this": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"test/rules/**/*.js"
|
||||
"example/standalone.mjs"
|
||||
],
|
||||
"rules": {
|
||||
"jsdoc/valid-types": "off"
|
||||
"no-console": "off",
|
||||
"no-constant-condition": "off"
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"test/rules/**/*.js",
|
||||
"test/rules/**/*.cjs"
|
||||
],
|
||||
"languageOptions": {
|
||||
"sourceType": "commonjs"
|
||||
},
|
||||
"rules": {
|
||||
"unicorn/prefer-module": "off"
|
||||
}
|
||||
}
|
||||
];
|
||||
|
|
28
example/Gruntfile.cjs
Normal file
28
example/Gruntfile.cjs
Normal file
|
@ -0,0 +1,28 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports = function wrapper(grunt) {
|
||||
grunt.initConfig({
|
||||
"markdownlint": {
|
||||
"example": {
|
||||
"src": [ "*.md" ]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.registerMultiTask("markdownlint", function task() {
|
||||
const done = this.async();
|
||||
import("markdownlint/async").then(({ lint }) => {
|
||||
lint(
|
||||
{ "files": this.filesSrc },
|
||||
function callback(err, result) {
|
||||
const resultString = err || ((result || "").toString());
|
||||
if (resultString) {
|
||||
grunt.fail.warn("\n" + resultString + "\n");
|
||||
}
|
||||
done(!err || !resultString);
|
||||
});
|
||||
}).catch(done);
|
||||
});
|
||||
};
|
|
@ -1,28 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const markdownlint = require("../lib/markdownlint");
|
||||
|
||||
module.exports = function wrapper(grunt) {
|
||||
grunt.initConfig({
|
||||
"markdownlint": {
|
||||
"example": {
|
||||
"src": [ "*.md" ]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.registerMultiTask("markdownlint", function task() {
|
||||
const done = this.async();
|
||||
markdownlint(
|
||||
{ "files": this.filesSrc },
|
||||
function callback(err, result) {
|
||||
const resultString = err || ((result || "").toString());
|
||||
if (resultString) {
|
||||
grunt.fail.warn("\n" + resultString + "\n");
|
||||
}
|
||||
done(!err || !resultString);
|
||||
});
|
||||
});
|
||||
};
|
24
example/gulpfile.cjs
Normal file
24
example/gulpfile.cjs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const gulp = require("gulp");
|
||||
const through2 = require("through2");
|
||||
|
||||
// Simple task wrapper
|
||||
gulp.task("markdownlint", function task() {
|
||||
return gulp.src("*.md", { "read": false })
|
||||
.pipe(through2.obj(function obj(file, enc, next) {
|
||||
import("markdownlint/async").then(({ lint }) => {
|
||||
lint(
|
||||
{ "files": [ file.relative ] },
|
||||
function callback(err, result) {
|
||||
const resultString = (result || "").toString();
|
||||
if (resultString) {
|
||||
console.log(resultString);
|
||||
}
|
||||
next(err, file);
|
||||
});
|
||||
}).catch(next);
|
||||
}));
|
||||
});
|
|
@ -1,23 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const gulp = require("gulp");
|
||||
const through2 = require("through2");
|
||||
const markdownlint = require("../lib/markdownlint");
|
||||
|
||||
// Simple task wrapper
|
||||
gulp.task("markdownlint", function task() {
|
||||
return gulp.src("*.md", { "read": false })
|
||||
.pipe(through2.obj(function obj(file, enc, next) {
|
||||
markdownlint(
|
||||
{ "files": [ file.relative ] },
|
||||
function callback(err, result) {
|
||||
const resultString = (result || "").toString();
|
||||
if (resultString) {
|
||||
console.log(resultString);
|
||||
}
|
||||
next(err, file);
|
||||
});
|
||||
}));
|
||||
});
|
|
@ -1,31 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const markdownlint = require("../lib/markdownlint");
|
||||
|
||||
const options = {
|
||||
"files": [ "good.md", "bad.md" ],
|
||||
"strings": {
|
||||
"good.string": "# good.string\n\nThis string passes all rules.\n",
|
||||
"bad.string": "#bad.string\n\n#This string fails\tsome rules.\n"
|
||||
}
|
||||
};
|
||||
|
||||
// Makes a synchronous call, using result.toString for pretty formatting
|
||||
const result = markdownlint.sync(options);
|
||||
console.log(result.toString());
|
||||
|
||||
// Makes an asynchronous call
|
||||
markdownlint(options, function callback(err, result) {
|
||||
if (!err) {
|
||||
console.log(result.toString());
|
||||
}
|
||||
});
|
||||
|
||||
// Displays the result object directly
|
||||
markdownlint(options, function callback(err, result) {
|
||||
if (!err) {
|
||||
console.dir(result, { "colors": true, "depth": null });
|
||||
}
|
||||
});
|
54
example/standalone.mjs
Normal file
54
example/standalone.mjs
Normal file
|
@ -0,0 +1,54 @@
|
|||
// @ts-check
|
||||
|
||||
import { applyFixes, getVersion } from "markdownlint";
|
||||
import { lint as lintAsync } from "markdownlint/async";
|
||||
import { lint as lintPromise } from "markdownlint/promise";
|
||||
import { lint as lintSync } from "markdownlint/sync";
|
||||
|
||||
// Displays the library version
|
||||
console.log(getVersion());
|
||||
|
||||
const options = {
|
||||
"files": [ "good.md", "bad.md" ],
|
||||
"strings": {
|
||||
"good.string": "# good.string\n\nThis string passes all rules.\n",
|
||||
"bad.string": "#bad.string\n\n#This string fails\tsome rules.\n"
|
||||
}
|
||||
};
|
||||
|
||||
if (true) {
|
||||
|
||||
// Makes a synchronous call, uses result.toString for pretty formatting
|
||||
const results = lintSync(options);
|
||||
console.log(results.toString());
|
||||
|
||||
}
|
||||
|
||||
if (true) {
|
||||
|
||||
// Makes an asynchronous call, uses result.toString for pretty formatting
|
||||
lintAsync(options, function callback(error, results) {
|
||||
if (!error && results) {
|
||||
console.log(results.toString());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (true) {
|
||||
|
||||
// Makes a Promise-based asynchronous call, displays the result object directly
|
||||
const results = await lintPromise(options);
|
||||
console.dir(results, { "colors": true, "depth": null });
|
||||
|
||||
}
|
||||
|
||||
if (true) {
|
||||
|
||||
// Fixes all supported violations in Markdown content
|
||||
const original = "# Heading";
|
||||
const results = lintSync({ "strings": { "content": original } });
|
||||
const fixed = applyFixes(original, results.content);
|
||||
console.log(fixed);
|
||||
|
||||
}
|
2
example/typescript/.gitignore
vendored
2
example/typescript/.gitignore
vendored
|
@ -1 +1 @@
|
|||
type-check.js
|
||||
type-check-*
|
||||
|
|
|
@ -1,25 +1,30 @@
|
|||
// Attempt to validate all the type declarations in markdownlint.d.ts
|
||||
// Attempt to validate important type declarations
|
||||
|
||||
import markdownlint from "../..";
|
||||
import { Configuration, ConfigurationStrict, LintResults, Options, Rule, RuleParams, RuleOnError, RuleOnErrorInfo } from "../../lib/exports.mjs";
|
||||
import { applyFix, applyFixes, getVersion } from "../../lib/exports.mjs";
|
||||
import { lint as lintAsync, readConfig as readConfigAsync } from "../../lib/exports-async.mjs";
|
||||
import { lint as lintPromise, readConfig as readConfigPromise } from "../../lib/exports-promise.mjs";
|
||||
import { lint as lintSync, readConfig as readConfigSync } from "../../lib/exports-sync.mjs";
|
||||
|
||||
const assert = require("assert");
|
||||
import assert from "assert";
|
||||
import markdownIt from "markdown-it";
|
||||
const markdownlintJsonPath = "../../.markdownlint.json";
|
||||
|
||||
const version: string = markdownlint.getVersion();
|
||||
const version: string = getVersion();
|
||||
assert(/^\d+\.\d+\.\d+$/.test(version));
|
||||
|
||||
function assertConfiguration(config: markdownlint.Configuration) {
|
||||
function assertConfiguration(config: Configuration) {
|
||||
assert(!!config);
|
||||
assert.deepEqual(config["line-length"], { "strict": true, "code_blocks": false });
|
||||
// config assignment is covered by markdownlint.Options
|
||||
}
|
||||
|
||||
function assertConfigurationCallback(err: Error | null, config?: markdownlint.Configuration) {
|
||||
function assertConfigurationCallback(err: Error | null, config?: Configuration) {
|
||||
assert(!err);
|
||||
config && assertConfiguration(config);
|
||||
}
|
||||
|
||||
function assertLintResults(results: markdownlint.LintResults) {
|
||||
function assertLintResults(results: LintResults) {
|
||||
assert(!!results);
|
||||
assert.equal(results["string"].length, 1);
|
||||
assert.equal(results["string"][0].lineNumber, 1);
|
||||
|
@ -60,23 +65,23 @@ function assertLintResults(results: markdownlint.LintResults) {
|
|||
};
|
||||
}
|
||||
|
||||
function assertLintResultsCallback(err: Error | null, results?: markdownlint.LintResults) {
|
||||
function assertLintResultsCallback(err: Error | null, results?: LintResults) {
|
||||
assert(!err);
|
||||
results && assertLintResults(results);
|
||||
}
|
||||
|
||||
assertConfiguration(markdownlint.readConfigSync(markdownlintJsonPath));
|
||||
assertConfiguration(markdownlint.readConfigSync(markdownlintJsonPath, [ JSON.parse ]));
|
||||
assertConfiguration(readConfigSync(markdownlintJsonPath));
|
||||
assertConfiguration(readConfigSync(markdownlintJsonPath, [ JSON.parse ]));
|
||||
|
||||
markdownlint.readConfig(markdownlintJsonPath, assertConfigurationCallback);
|
||||
markdownlint.readConfig(markdownlintJsonPath, [ JSON.parse ], assertConfigurationCallback);
|
||||
readConfigAsync(markdownlintJsonPath, assertConfigurationCallback);
|
||||
readConfigAsync(markdownlintJsonPath, [ JSON.parse ], assertConfigurationCallback);
|
||||
|
||||
(async () => {
|
||||
assertConfigurationCallback(null, await markdownlint.promises.readConfig(markdownlintJsonPath));
|
||||
assertConfigurationCallback(null, await markdownlint.promises.readConfig(markdownlintJsonPath, [ JSON.parse ]))
|
||||
assertConfigurationCallback(null, await readConfigPromise(markdownlintJsonPath));
|
||||
assertConfigurationCallback(null, await readConfigPromise(markdownlintJsonPath, [ JSON.parse ]))
|
||||
})();
|
||||
|
||||
let options: markdownlint.Options;
|
||||
let options: Options;
|
||||
options = {
|
||||
"files": [ "../bad.md" ],
|
||||
"strings": {
|
||||
|
@ -93,32 +98,32 @@ options = {
|
|||
"frontMatter": /---/,
|
||||
"handleRuleFailures": false,
|
||||
"noInlineConfig": false,
|
||||
"markdownItPlugins": [ [ require("markdown-it-sub") ] ]
|
||||
"markdownItFactory": () => markdownIt()
|
||||
};
|
||||
|
||||
assertLintResults(markdownlint.sync(options));
|
||||
markdownlint(options, assertLintResultsCallback);
|
||||
assertLintResults(lintSync(options));
|
||||
lintAsync(options, assertLintResultsCallback);
|
||||
(async () => {
|
||||
assertLintResultsCallback(null, await markdownlint.promises.markdownlint(options));
|
||||
assertLintResultsCallback(null, await lintPromise(options));
|
||||
})();
|
||||
|
||||
options.files = "../bad.md";
|
||||
assertLintResults(markdownlint.sync(options));
|
||||
markdownlint(options, assertLintResultsCallback);
|
||||
assertLintResults(lintSync(options));
|
||||
lintAsync(options, assertLintResultsCallback);
|
||||
(async () => {
|
||||
assertLintResultsCallback(null, await markdownlint.promises.markdownlint(options));
|
||||
assertLintResultsCallback(null, await lintPromise(options));
|
||||
})();
|
||||
|
||||
const testRule: markdownlint.Rule = {
|
||||
const testRule: Rule = {
|
||||
"names": [ "test-rule" ],
|
||||
"description": "Test rule",
|
||||
"information": new URL("https://example.com/rule-information"),
|
||||
"tags": [ "test-tag" ],
|
||||
"parser": "none",
|
||||
"function": function rule(params: markdownlint.RuleParams, onError: markdownlint.RuleOnError) {
|
||||
"function": function rule(params: RuleParams, onError: RuleOnError) {
|
||||
assert(!!params);
|
||||
assert(!!onError);
|
||||
let ruleParams: markdownlint.RuleParams;
|
||||
let ruleParams: RuleParams;
|
||||
ruleParams = {
|
||||
"name": "name",
|
||||
"parsers": {
|
||||
|
@ -140,7 +145,7 @@ const testRule: markdownlint.Rule = {
|
|||
"version": "1.2.3"
|
||||
};
|
||||
assert(ruleParams);
|
||||
let ruleOnErrorInfo: markdownlint.RuleOnErrorInfo;
|
||||
let ruleOnErrorInfo: RuleOnErrorInfo;
|
||||
ruleOnErrorInfo = {
|
||||
"lineNumber": 1,
|
||||
"detail": "detail",
|
||||
|
@ -160,14 +165,14 @@ const testRule: markdownlint.Rule = {
|
|||
};
|
||||
|
||||
options.customRules = [ testRule ];
|
||||
assertLintResults(markdownlint.sync(options));
|
||||
markdownlint(options, assertLintResultsCallback);
|
||||
assertLintResults(lintSync(options));
|
||||
lintAsync(options, assertLintResultsCallback);
|
||||
(async () => {
|
||||
assertLintResultsCallback(null, await markdownlint.promises.markdownlint(options));
|
||||
assertLintResultsCallback(null, await lintPromise(options));
|
||||
})();
|
||||
|
||||
assert.equal(
|
||||
markdownlint.applyFix(
|
||||
applyFix(
|
||||
"# Fixing\n",
|
||||
{
|
||||
"insertText": "Head",
|
||||
|
@ -180,7 +185,7 @@ assert.equal(
|
|||
);
|
||||
|
||||
assert.equal(
|
||||
markdownlint.applyFixes(
|
||||
applyFixes(
|
||||
"# Fixing\n",
|
||||
[
|
||||
{
|
||||
|
@ -196,7 +201,7 @@ assert.equal(
|
|||
"# Heading\n"
|
||||
);
|
||||
|
||||
const configuration: markdownlint.Configuration = {
|
||||
const configuration: Configuration = {
|
||||
"custom-rule": true,
|
||||
"no-hard-tabs": false,
|
||||
"heading-style": {
|
||||
|
@ -204,7 +209,7 @@ const configuration: markdownlint.Configuration = {
|
|||
}
|
||||
};
|
||||
assert(configuration);
|
||||
const configurationStrict: markdownlint.ConfigurationStrict = {
|
||||
const configurationStrict: ConfigurationStrict = {
|
||||
// "custom-rule": true,
|
||||
"no-hard-tabs": false,
|
||||
"heading-style": {
|
||||
|
|
|
@ -1 +1 @@
|
|||
test.js
|
||||
test.cjs
|
||||
|
|
|
@ -22,8 +22,8 @@ be useful to custom rule authors and may avoid duplicating code.
|
|||
*None* - The entire body of code is tested to 100% coverage by the core
|
||||
`markdownlint` project, so there are no additional tests here.
|
||||
|
||||
[custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/CustomRules.md
|
||||
[custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/CustomRules.md
|
||||
[jsdoc]: https://en.m.wikipedia.org/wiki/JSDoc
|
||||
[markdown]: https://en.wikipedia.org/wiki/Markdown
|
||||
[markdownlint]: https://github.com/DavidAnson/markdownlint
|
||||
[rules]: https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/Rules.md
|
||||
[rules]: https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/Rules.md
|
||||
|
|
|
@ -4,15 +4,21 @@
|
|||
|
||||
const micromark = require("./micromark-helpers.cjs");
|
||||
|
||||
const { newLineRe, nextLinesRe } = require("./shared.js");
|
||||
const { newLineRe, nextLinesRe } = require("./shared.cjs");
|
||||
|
||||
module.exports.newLineRe = newLineRe;
|
||||
module.exports.nextLinesRe = nextLinesRe;
|
||||
|
||||
/** @typedef {import("../lib/markdownlint.js").RuleOnError} RuleOnError */
|
||||
/** @typedef {import("../lib/markdownlint.js").RuleOnErrorFixInfo} RuleOnErrorFixInfo */
|
||||
/** @typedef {import("../lib/exports.mjs").RuleOnError} RuleOnError */
|
||||
/** @typedef {import("../lib/exports.mjs").RuleOnErrorFixInfo} RuleOnErrorFixInfo */
|
||||
/** @typedef {import("../lib/exports.mjs").MicromarkToken} MicromarkToken */
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @typedef {import("micromark-extension-gfm-footnote", { with: { "resolution-mode": "import" } })} */
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @typedef {import("../lib/micromark-types.d.mts", { with: { "resolution-mode": "import" } })} */
|
||||
|
||||
// Regular expression for matching common front matter (YAML and TOML)
|
||||
// @ts-ignore
|
||||
module.exports.frontMatterRe =
|
||||
/((^---[^\S\r\n\u2028\u2029]*$[\s\S]+?^---\s*)|(^\+\+\+[^\S\r\n\u2028\u2029]*$[\s\S]+?^(\+\+\+|\.\.\.)\s*)|(^\{[^\S\r\n\u2028\u2029]*$[\s\S]+?^\}\s*))(\r\n|\r|\n|$)/m;
|
||||
|
||||
|
@ -304,7 +310,7 @@ module.exports.addErrorDetailIf = addErrorDetailIf;
|
|||
*/
|
||||
function addErrorContext(
|
||||
onError, lineNumber, context, start, end, range, fixInfo) {
|
||||
context = ellipsify(context, start, end);
|
||||
context = ellipsify(context.replace(newLineRe, "\n"), start, end);
|
||||
addError(onError, lineNumber, undefined, context, range, fixInfo);
|
||||
}
|
||||
module.exports.addErrorContext = addErrorContext;
|
||||
|
@ -336,8 +342,8 @@ const positionLessThanOrEqual = (lineA, columnA, lineB, columnB) => (
|
|||
/**
|
||||
* Returns whether two ranges (or MicromarkTokens) overlap anywhere.
|
||||
*
|
||||
* @param {FileRange|import("../lib/markdownlint.js").MicromarkToken} rangeA Range A.
|
||||
* @param {FileRange|import("../lib/markdownlint.js").MicromarkToken} rangeB Range B.
|
||||
* @param {FileRange|MicromarkToken} rangeA Range A.
|
||||
* @param {FileRange|MicromarkToken} rangeB Range B.
|
||||
* @returns {boolean} True iff the two ranges overlap.
|
||||
*/
|
||||
module.exports.hasOverlap = function hasOverlap(rangeA, rangeB) {
|
||||
|
@ -364,11 +370,12 @@ module.exports.frontMatterHasTitle =
|
|||
/**
|
||||
* Returns an object with information about reference links and images.
|
||||
*
|
||||
* @param {import("../helpers/micromark-helpers.cjs").Token[]} tokens Micromark tokens.
|
||||
* @param {MicromarkToken[]} tokens Micromark tokens.
|
||||
* @returns {Object} Reference link/image data.
|
||||
*/
|
||||
function getReferenceLinkImageData(tokens) {
|
||||
const normalizeReference = (s) => s.toLowerCase().trim().replace(/\s+/g, " ");
|
||||
const getText = (t) => t?.children.filter((c) => c.type !== "blockQuotePrefix").map((c) => c.text).join("");
|
||||
const references = new Map();
|
||||
const shortcuts = new Map();
|
||||
const addReferenceToDictionary = (token, label, isShortcut) => {
|
||||
|
@ -440,7 +447,7 @@ function getReferenceLinkImageData(tokens) {
|
|||
const isFullOrCollapsed = (token.children.length === 2) && !token.children.some((t) => t.type === "resource");
|
||||
const [ labelText ] = micromark.getDescendantsByType(token, [ "label", "labelText" ]);
|
||||
const [ referenceString ] = micromark.getDescendantsByType(token, [ "reference", "referenceString" ]);
|
||||
let label = labelText?.text;
|
||||
let label = getText(labelText);
|
||||
// Identify if footnote
|
||||
if (!isShortcut && !isFullOrCollapsed) {
|
||||
const [ footnoteCallMarker, footnoteCallString ] = token.children.filter(
|
||||
|
@ -453,7 +460,7 @@ function getReferenceLinkImageData(tokens) {
|
|||
}
|
||||
// Track link (handle shortcuts separately due to ambiguity in "text [text] text")
|
||||
if (isShortcut || isFullOrCollapsed) {
|
||||
addReferenceToDictionary(token, referenceString?.text || label, isShortcut);
|
||||
addReferenceToDictionary(token, getText(referenceString) || label, isShortcut);
|
||||
}
|
||||
}
|
||||
break;
|
|
@ -2,10 +2,13 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { flatTokensSymbol, htmlFlowSymbol } = require("./shared.js");
|
||||
const { flatTokensSymbol, htmlFlowSymbol } = require("./shared.cjs");
|
||||
|
||||
/** @typedef {import("markdownlint-micromark").TokenType} TokenType */
|
||||
/** @typedef {import("../lib/markdownlint.js").MicromarkToken} Token */
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @typedef {import("micromark-util-types", { with: { "resolution-mode": "import" } }).TokenType} TokenType */
|
||||
/** @typedef {import("../lib/exports.mjs").MicromarkToken} Token */
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @typedef {import("../lib/micromark-types.d.mts", { with: { "resolution-mode": "import" } })} */
|
||||
|
||||
/**
|
||||
* Determines if a Micromark token is within an htmlFlow type.
|
||||
|
@ -76,12 +79,11 @@ function addRangeToSet(set, start, end) {
|
|||
* Filter a list of Micromark tokens by predicate.
|
||||
*
|
||||
* @param {Token[]} tokens Micromark tokens.
|
||||
* @param {AllowedPredicate} [allowed] Allowed token predicate.
|
||||
* @param {AllowedPredicate} allowed Allowed token predicate.
|
||||
* @param {TransformPredicate} [transformChildren] Transform predicate.
|
||||
* @returns {Token[]} Filtered tokens.
|
||||
*/
|
||||
function filterByPredicate(tokens, allowed, transformChildren) {
|
||||
allowed = allowed || (() => true);
|
||||
const result = [];
|
||||
const queue = [
|
||||
{
|
||||
|
@ -214,8 +216,12 @@ function getHeadingStyle(heading) {
|
|||
* @returns {string} Heading text.
|
||||
*/
|
||||
function getHeadingText(heading) {
|
||||
const headingTexts = getDescendantsByType(heading, [ [ "atxHeadingText", "setextHeadingText" ] ]);
|
||||
return headingTexts[0]?.text.replace(/[\r\n]+/g, " ") || "";
|
||||
const headingText = getDescendantsByType(heading, [ [ "atxHeadingText", "setextHeadingText" ] ])
|
||||
.flatMap((descendant) => descendant.children.filter((child) => child.type !== "htmlText"))
|
||||
.map((data) => data.text)
|
||||
.join("")
|
||||
.replace(/[\r\n]+/g, " ");
|
||||
return headingText || "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -264,6 +270,26 @@ function getParentOfType(token, types) {
|
|||
return current;
|
||||
}
|
||||
|
||||
const docfxTabSyntaxRe = /^#tab\//;
|
||||
|
||||
/**
|
||||
* Returns whether the specified Micromark token looks like a Docfx tab.
|
||||
*
|
||||
* @param {Token | null} heading Micromark token.
|
||||
* @returns {boolean} True iff the token looks like a Docfx tab.
|
||||
*/
|
||||
function isDocfxTab(heading) {
|
||||
// See https://dotnet.github.io/docfx/docs/markdown.html?tabs=linux%2Cdotnet#tabs
|
||||
if (heading?.type === "atxHeading") {
|
||||
const headingTexts = getDescendantsByType(heading, [ "atxHeadingText" ]);
|
||||
if ((headingTexts.length === 1) && (headingTexts[0].children.length === 1) && (headingTexts[0].children[0].type === "link")) {
|
||||
const resourceDestinationStrings = filterByTypes(headingTexts[0].children[0].children, [ "resourceDestinationString" ]);
|
||||
return (resourceDestinationStrings.length === 1) && docfxTabSyntaxRe.test(resourceDestinationStrings[0].text);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set containing token types that do not contain content.
|
||||
*
|
||||
|
@ -276,7 +302,11 @@ const nonContentTokens = new Set([
|
|||
"lineEnding",
|
||||
"lineEndingBlank",
|
||||
"linePrefix",
|
||||
"listItemIndent"
|
||||
"listItemIndent",
|
||||
"undefinedReference",
|
||||
"undefinedReferenceCollapsed",
|
||||
"undefinedReferenceFull",
|
||||
"undefinedReferenceShortcut"
|
||||
]);
|
||||
|
||||
module.exports = {
|
||||
|
@ -291,6 +321,7 @@ module.exports = {
|
|||
getHtmlTagInfo,
|
||||
getParentOfType,
|
||||
inHtmlFlow,
|
||||
isDocfxTab,
|
||||
isHtmlFlowComment,
|
||||
nonContentTokens
|
||||
};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
{
|
||||
"name": "markdownlint-rule-helpers",
|
||||
"version": "0.27.0",
|
||||
"version": "0.29.0",
|
||||
"description": "A collection of markdownlint helper functions for custom rules",
|
||||
"main": "./helpers.js",
|
||||
"main": "./helpers.cjs",
|
||||
"exports": {
|
||||
".": "./helpers.js",
|
||||
".": "./helpers.cjs",
|
||||
"./micromark": "./micromark-helpers.cjs"
|
||||
},
|
||||
"author": "David Anson (https://dlaa.me/)",
|
||||
|
@ -19,9 +19,6 @@
|
|||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"dependencies": {
|
||||
"markdownlint-micromark": "0.1.2"
|
||||
},
|
||||
"keywords": [
|
||||
"markdownlint",
|
||||
"markdownlint-rule"
|
||||
|
|
|
@ -7,7 +7,7 @@ const test = require("ava").default;
|
|||
const { "exports": packageExports, name } = require("../helpers/package.json");
|
||||
|
||||
const exportMappings = new Map([
|
||||
[ ".", "../helpers/helpers.js" ],
|
||||
[ ".", "../helpers/helpers.cjs" ],
|
||||
[ "./micromark", "../helpers/micromark-helpers.cjs" ]
|
||||
]);
|
||||
|
||||
|
|
70
lib/cache.js
70
lib/cache.js
|
@ -1,70 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const helpers = require("../helpers");
|
||||
const { filterByTypes } = require("../helpers/micromark-helpers.cjs");
|
||||
|
||||
/** @type {Map<string, object>} */
|
||||
const map = new Map();
|
||||
let params = undefined;
|
||||
|
||||
/**
|
||||
* Initializes (resets) the cache.
|
||||
*
|
||||
* @param {import("./markdownlint").RuleParams} [p] Rule parameters object.
|
||||
* @returns {void}
|
||||
*/
|
||||
function initialize(p) {
|
||||
map.clear();
|
||||
params = p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cached object value - computes it and caches it.
|
||||
*
|
||||
* @param {string} name Cache object name.
|
||||
* @param {Function} getValue Getter for object value.
|
||||
* @returns {Object} Object value.
|
||||
*/
|
||||
function getCached(name, getValue) {
|
||||
if (map.has(name)) {
|
||||
return map.get(name);
|
||||
}
|
||||
const value = getValue();
|
||||
map.set(name, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters a list of Micromark tokens by type and caches the result.
|
||||
*
|
||||
* @param {import("./markdownlint").MicromarkTokenType[]} types Types to allow.
|
||||
* @param {boolean} [htmlFlow] Whether to include htmlFlow content.
|
||||
* @returns {import("./markdownlint").MicromarkToken[]} Filtered tokens.
|
||||
*/
|
||||
function filterByTypesCached(types, htmlFlow) {
|
||||
return getCached(
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
JSON.stringify(arguments),
|
||||
() => filterByTypes(params.parsers.micromark.tokens, types, htmlFlow)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a reference link and image data object.
|
||||
*
|
||||
* @returns {Object} Reference link and image data object.
|
||||
*/
|
||||
function getReferenceLinkImageData() {
|
||||
return getCached(
|
||||
getReferenceLinkImageData.name,
|
||||
() => helpers.getReferenceLinkImageData(params.parsers.micromark.tokens)
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
initialize,
|
||||
filterByTypesCached,
|
||||
getReferenceLinkImageData
|
||||
};
|
76
lib/cache.mjs
Normal file
76
lib/cache.mjs
Normal file
|
@ -0,0 +1,76 @@
|
|||
// @ts-check
|
||||
|
||||
import { getReferenceLinkImageData as helpersGetReferenceLinkImageData } from "../helpers/helpers.cjs";
|
||||
import { filterByTypes } from "../helpers/micromark-helpers.cjs";
|
||||
|
||||
/** @typedef {import("markdownlint").RuleParams} RuleParams */
|
||||
/** @typedef {import("markdownlint").MicromarkToken} MicromarkToken */
|
||||
/** @typedef {import("markdownlint").MicromarkTokenType} MicromarkTokenType */
|
||||
|
||||
/** @type {Map<string, object>} */
|
||||
const map = new Map();
|
||||
/** @type {RuleParams | undefined} */
|
||||
let params = undefined;
|
||||
|
||||
/**
|
||||
* Initializes (resets) the cache.
|
||||
*
|
||||
* @param {RuleParams} [p] Rule parameters object.
|
||||
* @returns {void}
|
||||
*/
|
||||
export function initialize(p) {
|
||||
map.clear();
|
||||
params = p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cached Micromark token array (for testing).
|
||||
*
|
||||
* @returns {MicromarkToken[]} Micromark tokens.
|
||||
*/
|
||||
export function micromarkTokens() {
|
||||
return params?.parsers.micromark.tokens || [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cached object value - computes it and caches it.
|
||||
*
|
||||
* @param {string} name Cache object name.
|
||||
* @param {Function} getValue Getter for object value.
|
||||
* @returns {Object} Object value.
|
||||
*/
|
||||
function getCached(name, getValue) {
|
||||
if (map.has(name)) {
|
||||
return map.get(name);
|
||||
}
|
||||
const value = getValue();
|
||||
map.set(name, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters a list of Micromark tokens by type and caches the result.
|
||||
*
|
||||
* @param {MicromarkTokenType[]} types Types to allow.
|
||||
* @param {boolean} [htmlFlow] Whether to include htmlFlow content.
|
||||
* @returns {MicromarkToken[]} Filtered tokens.
|
||||
*/
|
||||
export function filterByTypesCached(types, htmlFlow) {
|
||||
return getCached(
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
JSON.stringify(arguments),
|
||||
() => filterByTypes(micromarkTokens(), types, htmlFlow)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a reference link and image data object.
|
||||
*
|
||||
* @returns {Object} Reference link and image data object.
|
||||
*/
|
||||
export function getReferenceLinkImageData() {
|
||||
return getCached(
|
||||
getReferenceLinkImageData.name,
|
||||
() => helpersGetReferenceLinkImageData(micromarkTokens())
|
||||
);
|
||||
}
|
332
lib/configuration-strict.d.ts
vendored
332
lib/configuration-strict.d.ts
vendored
|
@ -19,15 +19,15 @@ export interface ConfigurationStrict {
|
|||
*/
|
||||
extends?: string | null;
|
||||
/**
|
||||
* MD001/heading-increment : Heading levels should only increment by one level at a time : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md001.md
|
||||
* MD001/heading-increment : Heading levels should only increment by one level at a time : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md001.md
|
||||
*/
|
||||
MD001?: boolean;
|
||||
/**
|
||||
* MD001/heading-increment : Heading levels should only increment by one level at a time : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md001.md
|
||||
* MD001/heading-increment : Heading levels should only increment by one level at a time : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md001.md
|
||||
*/
|
||||
"heading-increment"?: boolean;
|
||||
/**
|
||||
* MD003/heading-style : Heading style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md003.md
|
||||
* MD003/heading-style : Heading style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md003.md
|
||||
*/
|
||||
MD003?:
|
||||
| boolean
|
||||
|
@ -38,7 +38,7 @@ export interface ConfigurationStrict {
|
|||
style?: "consistent" | "atx" | "atx_closed" | "setext" | "setext_with_atx" | "setext_with_atx_closed";
|
||||
};
|
||||
/**
|
||||
* MD003/heading-style : Heading style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md003.md
|
||||
* MD003/heading-style : Heading style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md003.md
|
||||
*/
|
||||
"heading-style"?:
|
||||
| boolean
|
||||
|
@ -49,7 +49,7 @@ export interface ConfigurationStrict {
|
|||
style?: "consistent" | "atx" | "atx_closed" | "setext" | "setext_with_atx" | "setext_with_atx_closed";
|
||||
};
|
||||
/**
|
||||
* MD004/ul-style : Unordered list style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md004.md
|
||||
* MD004/ul-style : Unordered list style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md004.md
|
||||
*/
|
||||
MD004?:
|
||||
| boolean
|
||||
|
@ -60,7 +60,7 @@ export interface ConfigurationStrict {
|
|||
style?: "consistent" | "asterisk" | "plus" | "dash" | "sublist";
|
||||
};
|
||||
/**
|
||||
* MD004/ul-style : Unordered list style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md004.md
|
||||
* MD004/ul-style : Unordered list style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md004.md
|
||||
*/
|
||||
"ul-style"?:
|
||||
| boolean
|
||||
|
@ -71,15 +71,15 @@ export interface ConfigurationStrict {
|
|||
style?: "consistent" | "asterisk" | "plus" | "dash" | "sublist";
|
||||
};
|
||||
/**
|
||||
* MD005/list-indent : Inconsistent indentation for list items at the same level : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md005.md
|
||||
* MD005/list-indent : Inconsistent indentation for list items at the same level : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md005.md
|
||||
*/
|
||||
MD005?: boolean;
|
||||
/**
|
||||
* MD005/list-indent : Inconsistent indentation for list items at the same level : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md005.md
|
||||
* MD005/list-indent : Inconsistent indentation for list items at the same level : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md005.md
|
||||
*/
|
||||
"list-indent"?: boolean;
|
||||
/**
|
||||
* MD007/ul-indent : Unordered list indentation : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md007.md
|
||||
* MD007/ul-indent : Unordered list indentation : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md007.md
|
||||
*/
|
||||
MD007?:
|
||||
| boolean
|
||||
|
@ -98,7 +98,7 @@ export interface ConfigurationStrict {
|
|||
start_indent?: number;
|
||||
};
|
||||
/**
|
||||
* MD007/ul-indent : Unordered list indentation : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md007.md
|
||||
* MD007/ul-indent : Unordered list indentation : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md007.md
|
||||
*/
|
||||
"ul-indent"?:
|
||||
| boolean
|
||||
|
@ -117,7 +117,7 @@ export interface ConfigurationStrict {
|
|||
start_indent?: number;
|
||||
};
|
||||
/**
|
||||
* MD009/no-trailing-spaces : Trailing spaces : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md009.md
|
||||
* MD009/no-trailing-spaces : Trailing spaces : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md009.md
|
||||
*/
|
||||
MD009?:
|
||||
| boolean
|
||||
|
@ -136,7 +136,7 @@ export interface ConfigurationStrict {
|
|||
strict?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD009/no-trailing-spaces : Trailing spaces : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md009.md
|
||||
* MD009/no-trailing-spaces : Trailing spaces : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md009.md
|
||||
*/
|
||||
"no-trailing-spaces"?:
|
||||
| boolean
|
||||
|
@ -155,7 +155,7 @@ export interface ConfigurationStrict {
|
|||
strict?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD010/no-hard-tabs : Hard tabs : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md010.md
|
||||
* MD010/no-hard-tabs : Hard tabs : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md010.md
|
||||
*/
|
||||
MD010?:
|
||||
| boolean
|
||||
|
@ -174,7 +174,7 @@ export interface ConfigurationStrict {
|
|||
spaces_per_tab?: number;
|
||||
};
|
||||
/**
|
||||
* MD010/no-hard-tabs : Hard tabs : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md010.md
|
||||
* MD010/no-hard-tabs : Hard tabs : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md010.md
|
||||
*/
|
||||
"no-hard-tabs"?:
|
||||
| boolean
|
||||
|
@ -193,15 +193,15 @@ export interface ConfigurationStrict {
|
|||
spaces_per_tab?: number;
|
||||
};
|
||||
/**
|
||||
* MD011/no-reversed-links : Reversed link syntax : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md011.md
|
||||
* MD011/no-reversed-links : Reversed link syntax : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md011.md
|
||||
*/
|
||||
MD011?: boolean;
|
||||
/**
|
||||
* MD011/no-reversed-links : Reversed link syntax : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md011.md
|
||||
* MD011/no-reversed-links : Reversed link syntax : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md011.md
|
||||
*/
|
||||
"no-reversed-links"?: boolean;
|
||||
/**
|
||||
* MD012/no-multiple-blanks : Multiple consecutive blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md012.md
|
||||
* MD012/no-multiple-blanks : Multiple consecutive blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md012.md
|
||||
*/
|
||||
MD012?:
|
||||
| boolean
|
||||
|
@ -212,7 +212,7 @@ export interface ConfigurationStrict {
|
|||
maximum?: number;
|
||||
};
|
||||
/**
|
||||
* MD012/no-multiple-blanks : Multiple consecutive blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md012.md
|
||||
* MD012/no-multiple-blanks : Multiple consecutive blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md012.md
|
||||
*/
|
||||
"no-multiple-blanks"?:
|
||||
| boolean
|
||||
|
@ -223,7 +223,7 @@ export interface ConfigurationStrict {
|
|||
maximum?: number;
|
||||
};
|
||||
/**
|
||||
* MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md013.md
|
||||
* MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md013.md
|
||||
*/
|
||||
MD013?:
|
||||
| boolean
|
||||
|
@ -262,7 +262,7 @@ export interface ConfigurationStrict {
|
|||
stern?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md013.md
|
||||
* MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md013.md
|
||||
*/
|
||||
"line-length"?:
|
||||
| boolean
|
||||
|
@ -301,47 +301,47 @@ export interface ConfigurationStrict {
|
|||
stern?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD014/commands-show-output : Dollar signs used before commands without showing output : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md014.md
|
||||
* MD014/commands-show-output : Dollar signs used before commands without showing output : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md014.md
|
||||
*/
|
||||
MD014?: boolean;
|
||||
/**
|
||||
* MD014/commands-show-output : Dollar signs used before commands without showing output : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md014.md
|
||||
* MD014/commands-show-output : Dollar signs used before commands without showing output : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md014.md
|
||||
*/
|
||||
"commands-show-output"?: boolean;
|
||||
/**
|
||||
* MD018/no-missing-space-atx : No space after hash on atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md018.md
|
||||
* MD018/no-missing-space-atx : No space after hash on atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md018.md
|
||||
*/
|
||||
MD018?: boolean;
|
||||
/**
|
||||
* MD018/no-missing-space-atx : No space after hash on atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md018.md
|
||||
* MD018/no-missing-space-atx : No space after hash on atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md018.md
|
||||
*/
|
||||
"no-missing-space-atx"?: boolean;
|
||||
/**
|
||||
* MD019/no-multiple-space-atx : Multiple spaces after hash on atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md019.md
|
||||
* MD019/no-multiple-space-atx : Multiple spaces after hash on atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md019.md
|
||||
*/
|
||||
MD019?: boolean;
|
||||
/**
|
||||
* MD019/no-multiple-space-atx : Multiple spaces after hash on atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md019.md
|
||||
* MD019/no-multiple-space-atx : Multiple spaces after hash on atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md019.md
|
||||
*/
|
||||
"no-multiple-space-atx"?: boolean;
|
||||
/**
|
||||
* MD020/no-missing-space-closed-atx : No space inside hashes on closed atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md020.md
|
||||
* MD020/no-missing-space-closed-atx : No space inside hashes on closed atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md020.md
|
||||
*/
|
||||
MD020?: boolean;
|
||||
/**
|
||||
* MD020/no-missing-space-closed-atx : No space inside hashes on closed atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md020.md
|
||||
* MD020/no-missing-space-closed-atx : No space inside hashes on closed atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md020.md
|
||||
*/
|
||||
"no-missing-space-closed-atx"?: boolean;
|
||||
/**
|
||||
* MD021/no-multiple-space-closed-atx : Multiple spaces inside hashes on closed atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md021.md
|
||||
* MD021/no-multiple-space-closed-atx : Multiple spaces inside hashes on closed atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md021.md
|
||||
*/
|
||||
MD021?: boolean;
|
||||
/**
|
||||
* MD021/no-multiple-space-closed-atx : Multiple spaces inside hashes on closed atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md021.md
|
||||
* MD021/no-multiple-space-closed-atx : Multiple spaces inside hashes on closed atx style heading : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md021.md
|
||||
*/
|
||||
"no-multiple-space-closed-atx"?: boolean;
|
||||
/**
|
||||
* MD022/blanks-around-headings : Headings should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md022.md
|
||||
* MD022/blanks-around-headings : Headings should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md022.md
|
||||
*/
|
||||
MD022?:
|
||||
| boolean
|
||||
|
@ -356,7 +356,7 @@ export interface ConfigurationStrict {
|
|||
lines_below?: number | number[];
|
||||
};
|
||||
/**
|
||||
* MD022/blanks-around-headings : Headings should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md022.md
|
||||
* MD022/blanks-around-headings : Headings should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md022.md
|
||||
*/
|
||||
"blanks-around-headings"?:
|
||||
| boolean
|
||||
|
@ -371,15 +371,15 @@ export interface ConfigurationStrict {
|
|||
lines_below?: number | number[];
|
||||
};
|
||||
/**
|
||||
* MD023/heading-start-left : Headings must start at the beginning of the line : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md023.md
|
||||
* MD023/heading-start-left : Headings must start at the beginning of the line : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md023.md
|
||||
*/
|
||||
MD023?: boolean;
|
||||
/**
|
||||
* MD023/heading-start-left : Headings must start at the beginning of the line : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md023.md
|
||||
* MD023/heading-start-left : Headings must start at the beginning of the line : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md023.md
|
||||
*/
|
||||
"heading-start-left"?: boolean;
|
||||
/**
|
||||
* MD024/no-duplicate-heading : Multiple headings with the same content : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md024.md
|
||||
* MD024/no-duplicate-heading : Multiple headings with the same content : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md024.md
|
||||
*/
|
||||
MD024?:
|
||||
| boolean
|
||||
|
@ -390,7 +390,7 @@ export interface ConfigurationStrict {
|
|||
siblings_only?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD024/no-duplicate-heading : Multiple headings with the same content : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md024.md
|
||||
* MD024/no-duplicate-heading : Multiple headings with the same content : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md024.md
|
||||
*/
|
||||
"no-duplicate-heading"?:
|
||||
| boolean
|
||||
|
@ -401,52 +401,52 @@ export interface ConfigurationStrict {
|
|||
siblings_only?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD025/single-title/single-h1 : Multiple top-level headings in the same document : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md025.md
|
||||
* MD025/single-title/single-h1 : Multiple top-level headings in the same document : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md025.md
|
||||
*/
|
||||
MD025?:
|
||||
| boolean
|
||||
| {
|
||||
/**
|
||||
* Heading level
|
||||
*/
|
||||
level?: number;
|
||||
/**
|
||||
* RegExp for matching title in front matter
|
||||
*/
|
||||
front_matter_title?: string;
|
||||
/**
|
||||
* Heading level
|
||||
*/
|
||||
level?: number;
|
||||
};
|
||||
/**
|
||||
* MD025/single-title/single-h1 : Multiple top-level headings in the same document : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md025.md
|
||||
* MD025/single-title/single-h1 : Multiple top-level headings in the same document : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md025.md
|
||||
*/
|
||||
"single-title"?:
|
||||
| boolean
|
||||
| {
|
||||
/**
|
||||
* Heading level
|
||||
*/
|
||||
level?: number;
|
||||
/**
|
||||
* RegExp for matching title in front matter
|
||||
*/
|
||||
front_matter_title?: string;
|
||||
/**
|
||||
* Heading level
|
||||
*/
|
||||
level?: number;
|
||||
};
|
||||
/**
|
||||
* MD025/single-title/single-h1 : Multiple top-level headings in the same document : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md025.md
|
||||
* MD025/single-title/single-h1 : Multiple top-level headings in the same document : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md025.md
|
||||
*/
|
||||
"single-h1"?:
|
||||
| boolean
|
||||
| {
|
||||
/**
|
||||
* Heading level
|
||||
*/
|
||||
level?: number;
|
||||
/**
|
||||
* RegExp for matching title in front matter
|
||||
*/
|
||||
front_matter_title?: string;
|
||||
/**
|
||||
* Heading level
|
||||
*/
|
||||
level?: number;
|
||||
};
|
||||
/**
|
||||
* MD026/no-trailing-punctuation : Trailing punctuation in heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md026.md
|
||||
* MD026/no-trailing-punctuation : Trailing punctuation in heading : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md026.md
|
||||
*/
|
||||
MD026?:
|
||||
| boolean
|
||||
|
@ -457,7 +457,7 @@ export interface ConfigurationStrict {
|
|||
punctuation?: string;
|
||||
};
|
||||
/**
|
||||
* MD026/no-trailing-punctuation : Trailing punctuation in heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md026.md
|
||||
* MD026/no-trailing-punctuation : Trailing punctuation in heading : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md026.md
|
||||
*/
|
||||
"no-trailing-punctuation"?:
|
||||
| boolean
|
||||
|
@ -468,23 +468,37 @@ export interface ConfigurationStrict {
|
|||
punctuation?: string;
|
||||
};
|
||||
/**
|
||||
* MD027/no-multiple-space-blockquote : Multiple spaces after blockquote symbol : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md027.md
|
||||
* MD027/no-multiple-space-blockquote : Multiple spaces after blockquote symbol : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md027.md
|
||||
*/
|
||||
MD027?: boolean;
|
||||
MD027?:
|
||||
| boolean
|
||||
| {
|
||||
/**
|
||||
* Include list items
|
||||
*/
|
||||
list_items?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD027/no-multiple-space-blockquote : Multiple spaces after blockquote symbol : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md027.md
|
||||
* MD027/no-multiple-space-blockquote : Multiple spaces after blockquote symbol : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md027.md
|
||||
*/
|
||||
"no-multiple-space-blockquote"?: boolean;
|
||||
"no-multiple-space-blockquote"?:
|
||||
| boolean
|
||||
| {
|
||||
/**
|
||||
* Include list items
|
||||
*/
|
||||
list_items?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD028/no-blanks-blockquote : Blank line inside blockquote : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md028.md
|
||||
* MD028/no-blanks-blockquote : Blank line inside blockquote : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md028.md
|
||||
*/
|
||||
MD028?: boolean;
|
||||
/**
|
||||
* MD028/no-blanks-blockquote : Blank line inside blockquote : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md028.md
|
||||
* MD028/no-blanks-blockquote : Blank line inside blockquote : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md028.md
|
||||
*/
|
||||
"no-blanks-blockquote"?: boolean;
|
||||
/**
|
||||
* MD029/ol-prefix : Ordered list item prefix : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md029.md
|
||||
* MD029/ol-prefix : Ordered list item prefix : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md029.md
|
||||
*/
|
||||
MD029?:
|
||||
| boolean
|
||||
|
@ -495,7 +509,7 @@ export interface ConfigurationStrict {
|
|||
style?: "one" | "ordered" | "one_or_ordered" | "zero";
|
||||
};
|
||||
/**
|
||||
* MD029/ol-prefix : Ordered list item prefix : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md029.md
|
||||
* MD029/ol-prefix : Ordered list item prefix : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md029.md
|
||||
*/
|
||||
"ol-prefix"?:
|
||||
| boolean
|
||||
|
@ -506,7 +520,7 @@ export interface ConfigurationStrict {
|
|||
style?: "one" | "ordered" | "one_or_ordered" | "zero";
|
||||
};
|
||||
/**
|
||||
* MD030/list-marker-space : Spaces after list markers : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md030.md
|
||||
* MD030/list-marker-space : Spaces after list markers : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md030.md
|
||||
*/
|
||||
MD030?:
|
||||
| boolean
|
||||
|
@ -529,7 +543,7 @@ export interface ConfigurationStrict {
|
|||
ol_multi?: number;
|
||||
};
|
||||
/**
|
||||
* MD030/list-marker-space : Spaces after list markers : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md030.md
|
||||
* MD030/list-marker-space : Spaces after list markers : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md030.md
|
||||
*/
|
||||
"list-marker-space"?:
|
||||
| boolean
|
||||
|
@ -552,7 +566,7 @@ export interface ConfigurationStrict {
|
|||
ol_multi?: number;
|
||||
};
|
||||
/**
|
||||
* MD031/blanks-around-fences : Fenced code blocks should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md031.md
|
||||
* MD031/blanks-around-fences : Fenced code blocks should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md031.md
|
||||
*/
|
||||
MD031?:
|
||||
| boolean
|
||||
|
@ -563,7 +577,7 @@ export interface ConfigurationStrict {
|
|||
list_items?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD031/blanks-around-fences : Fenced code blocks should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md031.md
|
||||
* MD031/blanks-around-fences : Fenced code blocks should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md031.md
|
||||
*/
|
||||
"blanks-around-fences"?:
|
||||
| boolean
|
||||
|
@ -574,15 +588,15 @@ export interface ConfigurationStrict {
|
|||
list_items?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD032/blanks-around-lists : Lists should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md032.md
|
||||
* MD032/blanks-around-lists : Lists should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md032.md
|
||||
*/
|
||||
MD032?: boolean;
|
||||
/**
|
||||
* MD032/blanks-around-lists : Lists should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md032.md
|
||||
* MD032/blanks-around-lists : Lists should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md032.md
|
||||
*/
|
||||
"blanks-around-lists"?: boolean;
|
||||
/**
|
||||
* MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md033.md
|
||||
* MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md033.md
|
||||
*/
|
||||
MD033?:
|
||||
| boolean
|
||||
|
@ -593,7 +607,7 @@ export interface ConfigurationStrict {
|
|||
allowed_elements?: string[];
|
||||
};
|
||||
/**
|
||||
* MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md033.md
|
||||
* MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md033.md
|
||||
*/
|
||||
"no-inline-html"?:
|
||||
| boolean
|
||||
|
@ -604,15 +618,15 @@ export interface ConfigurationStrict {
|
|||
allowed_elements?: string[];
|
||||
};
|
||||
/**
|
||||
* MD034/no-bare-urls : Bare URL used : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md034.md
|
||||
* MD034/no-bare-urls : Bare URL used : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md034.md
|
||||
*/
|
||||
MD034?: boolean;
|
||||
/**
|
||||
* MD034/no-bare-urls : Bare URL used : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md034.md
|
||||
* MD034/no-bare-urls : Bare URL used : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md034.md
|
||||
*/
|
||||
"no-bare-urls"?: boolean;
|
||||
/**
|
||||
* MD035/hr-style : Horizontal rule style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md035.md
|
||||
* MD035/hr-style : Horizontal rule style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md035.md
|
||||
*/
|
||||
MD035?:
|
||||
| boolean
|
||||
|
@ -623,7 +637,7 @@ export interface ConfigurationStrict {
|
|||
style?: string;
|
||||
};
|
||||
/**
|
||||
* MD035/hr-style : Horizontal rule style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md035.md
|
||||
* MD035/hr-style : Horizontal rule style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md035.md
|
||||
*/
|
||||
"hr-style"?:
|
||||
| boolean
|
||||
|
@ -634,7 +648,7 @@ export interface ConfigurationStrict {
|
|||
style?: string;
|
||||
};
|
||||
/**
|
||||
* MD036/no-emphasis-as-heading : Emphasis used instead of a heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md036.md
|
||||
* MD036/no-emphasis-as-heading : Emphasis used instead of a heading : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md036.md
|
||||
*/
|
||||
MD036?:
|
||||
| boolean
|
||||
|
@ -645,7 +659,7 @@ export interface ConfigurationStrict {
|
|||
punctuation?: string;
|
||||
};
|
||||
/**
|
||||
* MD036/no-emphasis-as-heading : Emphasis used instead of a heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md036.md
|
||||
* MD036/no-emphasis-as-heading : Emphasis used instead of a heading : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md036.md
|
||||
*/
|
||||
"no-emphasis-as-heading"?:
|
||||
| boolean
|
||||
|
@ -656,31 +670,31 @@ export interface ConfigurationStrict {
|
|||
punctuation?: string;
|
||||
};
|
||||
/**
|
||||
* MD037/no-space-in-emphasis : Spaces inside emphasis markers : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md037.md
|
||||
* MD037/no-space-in-emphasis : Spaces inside emphasis markers : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md037.md
|
||||
*/
|
||||
MD037?: boolean;
|
||||
/**
|
||||
* MD037/no-space-in-emphasis : Spaces inside emphasis markers : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md037.md
|
||||
* MD037/no-space-in-emphasis : Spaces inside emphasis markers : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md037.md
|
||||
*/
|
||||
"no-space-in-emphasis"?: boolean;
|
||||
/**
|
||||
* MD038/no-space-in-code : Spaces inside code span elements : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md038.md
|
||||
* MD038/no-space-in-code : Spaces inside code span elements : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md038.md
|
||||
*/
|
||||
MD038?: boolean;
|
||||
/**
|
||||
* MD038/no-space-in-code : Spaces inside code span elements : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md038.md
|
||||
* MD038/no-space-in-code : Spaces inside code span elements : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md038.md
|
||||
*/
|
||||
"no-space-in-code"?: boolean;
|
||||
/**
|
||||
* MD039/no-space-in-links : Spaces inside link text : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md039.md
|
||||
* MD039/no-space-in-links : Spaces inside link text : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md039.md
|
||||
*/
|
||||
MD039?: boolean;
|
||||
/**
|
||||
* MD039/no-space-in-links : Spaces inside link text : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md039.md
|
||||
* MD039/no-space-in-links : Spaces inside link text : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md039.md
|
||||
*/
|
||||
"no-space-in-links"?: boolean;
|
||||
/**
|
||||
* MD040/fenced-code-language : Fenced code blocks should have a language specified : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md040.md
|
||||
* MD040/fenced-code-language : Fenced code blocks should have a language specified : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md040.md
|
||||
*/
|
||||
MD040?:
|
||||
| boolean
|
||||
|
@ -695,7 +709,7 @@ export interface ConfigurationStrict {
|
|||
language_only?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD040/fenced-code-language : Fenced code blocks should have a language specified : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md040.md
|
||||
* MD040/fenced-code-language : Fenced code blocks should have a language specified : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md040.md
|
||||
*/
|
||||
"fenced-code-language"?:
|
||||
| boolean
|
||||
|
@ -710,60 +724,72 @@ export interface ConfigurationStrict {
|
|||
language_only?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD041/first-line-heading/first-line-h1 : First line in a file should be a top-level heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md041.md
|
||||
* MD041/first-line-heading/first-line-h1 : First line in a file should be a top-level heading : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md041.md
|
||||
*/
|
||||
MD041?:
|
||||
| boolean
|
||||
| {
|
||||
/**
|
||||
* Heading level
|
||||
* Allow content before first heading
|
||||
*/
|
||||
level?: number;
|
||||
allow_preamble?: boolean;
|
||||
/**
|
||||
* RegExp for matching title in front matter
|
||||
*/
|
||||
front_matter_title?: string;
|
||||
/**
|
||||
* Heading level
|
||||
*/
|
||||
level?: number;
|
||||
};
|
||||
/**
|
||||
* MD041/first-line-heading/first-line-h1 : First line in a file should be a top-level heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md041.md
|
||||
* MD041/first-line-heading/first-line-h1 : First line in a file should be a top-level heading : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md041.md
|
||||
*/
|
||||
"first-line-heading"?:
|
||||
| boolean
|
||||
| {
|
||||
/**
|
||||
* Heading level
|
||||
* Allow content before first heading
|
||||
*/
|
||||
level?: number;
|
||||
allow_preamble?: boolean;
|
||||
/**
|
||||
* RegExp for matching title in front matter
|
||||
*/
|
||||
front_matter_title?: string;
|
||||
/**
|
||||
* Heading level
|
||||
*/
|
||||
level?: number;
|
||||
};
|
||||
/**
|
||||
* MD041/first-line-heading/first-line-h1 : First line in a file should be a top-level heading : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md041.md
|
||||
* MD041/first-line-heading/first-line-h1 : First line in a file should be a top-level heading : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md041.md
|
||||
*/
|
||||
"first-line-h1"?:
|
||||
| boolean
|
||||
| {
|
||||
/**
|
||||
* Heading level
|
||||
* Allow content before first heading
|
||||
*/
|
||||
level?: number;
|
||||
allow_preamble?: boolean;
|
||||
/**
|
||||
* RegExp for matching title in front matter
|
||||
*/
|
||||
front_matter_title?: string;
|
||||
/**
|
||||
* Heading level
|
||||
*/
|
||||
level?: number;
|
||||
};
|
||||
/**
|
||||
* MD042/no-empty-links : No empty links : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md042.md
|
||||
* MD042/no-empty-links : No empty links : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md042.md
|
||||
*/
|
||||
MD042?: boolean;
|
||||
/**
|
||||
* MD042/no-empty-links : No empty links : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md042.md
|
||||
* MD042/no-empty-links : No empty links : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md042.md
|
||||
*/
|
||||
"no-empty-links"?: boolean;
|
||||
/**
|
||||
* MD043/required-headings : Required heading structure : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md043.md
|
||||
* MD043/required-headings : Required heading structure : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md043.md
|
||||
*/
|
||||
MD043?:
|
||||
| boolean
|
||||
|
@ -778,7 +804,7 @@ export interface ConfigurationStrict {
|
|||
match_case?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD043/required-headings : Required heading structure : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md043.md
|
||||
* MD043/required-headings : Required heading structure : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md043.md
|
||||
*/
|
||||
"required-headings"?:
|
||||
| boolean
|
||||
|
@ -793,7 +819,7 @@ export interface ConfigurationStrict {
|
|||
match_case?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD044/proper-names : Proper names should have the correct capitalization : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md044.md
|
||||
* MD044/proper-names : Proper names should have the correct capitalization : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md044.md
|
||||
*/
|
||||
MD044?:
|
||||
| boolean
|
||||
|
@ -812,7 +838,7 @@ export interface ConfigurationStrict {
|
|||
html_elements?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD044/proper-names : Proper names should have the correct capitalization : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md044.md
|
||||
* MD044/proper-names : Proper names should have the correct capitalization : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md044.md
|
||||
*/
|
||||
"proper-names"?:
|
||||
| boolean
|
||||
|
@ -831,15 +857,15 @@ export interface ConfigurationStrict {
|
|||
html_elements?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD045/no-alt-text : Images should have alternate text (alt text) : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md045.md
|
||||
* MD045/no-alt-text : Images should have alternate text (alt text) : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md045.md
|
||||
*/
|
||||
MD045?: boolean;
|
||||
/**
|
||||
* MD045/no-alt-text : Images should have alternate text (alt text) : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md045.md
|
||||
* MD045/no-alt-text : Images should have alternate text (alt text) : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md045.md
|
||||
*/
|
||||
"no-alt-text"?: boolean;
|
||||
/**
|
||||
* MD046/code-block-style : Code block style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md046.md
|
||||
* MD046/code-block-style : Code block style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md046.md
|
||||
*/
|
||||
MD046?:
|
||||
| boolean
|
||||
|
@ -850,7 +876,7 @@ export interface ConfigurationStrict {
|
|||
style?: "consistent" | "fenced" | "indented";
|
||||
};
|
||||
/**
|
||||
* MD046/code-block-style : Code block style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md046.md
|
||||
* MD046/code-block-style : Code block style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md046.md
|
||||
*/
|
||||
"code-block-style"?:
|
||||
| boolean
|
||||
|
@ -861,15 +887,15 @@ export interface ConfigurationStrict {
|
|||
style?: "consistent" | "fenced" | "indented";
|
||||
};
|
||||
/**
|
||||
* MD047/single-trailing-newline : Files should end with a single newline character : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md047.md
|
||||
* MD047/single-trailing-newline : Files should end with a single newline character : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md047.md
|
||||
*/
|
||||
MD047?: boolean;
|
||||
/**
|
||||
* MD047/single-trailing-newline : Files should end with a single newline character : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md047.md
|
||||
* MD047/single-trailing-newline : Files should end with a single newline character : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md047.md
|
||||
*/
|
||||
"single-trailing-newline"?: boolean;
|
||||
/**
|
||||
* MD048/code-fence-style : Code fence style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md048.md
|
||||
* MD048/code-fence-style : Code fence style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md048.md
|
||||
*/
|
||||
MD048?:
|
||||
| boolean
|
||||
|
@ -880,7 +906,7 @@ export interface ConfigurationStrict {
|
|||
style?: "consistent" | "backtick" | "tilde";
|
||||
};
|
||||
/**
|
||||
* MD048/code-fence-style : Code fence style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md048.md
|
||||
* MD048/code-fence-style : Code fence style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md048.md
|
||||
*/
|
||||
"code-fence-style"?:
|
||||
| boolean
|
||||
|
@ -891,7 +917,7 @@ export interface ConfigurationStrict {
|
|||
style?: "consistent" | "backtick" | "tilde";
|
||||
};
|
||||
/**
|
||||
* MD049/emphasis-style : Emphasis style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md049.md
|
||||
* MD049/emphasis-style : Emphasis style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md049.md
|
||||
*/
|
||||
MD049?:
|
||||
| boolean
|
||||
|
@ -902,7 +928,7 @@ export interface ConfigurationStrict {
|
|||
style?: "consistent" | "asterisk" | "underscore";
|
||||
};
|
||||
/**
|
||||
* MD049/emphasis-style : Emphasis style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md049.md
|
||||
* MD049/emphasis-style : Emphasis style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md049.md
|
||||
*/
|
||||
"emphasis-style"?:
|
||||
| boolean
|
||||
|
@ -913,7 +939,7 @@ export interface ConfigurationStrict {
|
|||
style?: "consistent" | "asterisk" | "underscore";
|
||||
};
|
||||
/**
|
||||
* MD050/strong-style : Strong style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md050.md
|
||||
* MD050/strong-style : Strong style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md050.md
|
||||
*/
|
||||
MD050?:
|
||||
| boolean
|
||||
|
@ -924,7 +950,7 @@ export interface ConfigurationStrict {
|
|||
style?: "consistent" | "asterisk" | "underscore";
|
||||
};
|
||||
/**
|
||||
* MD050/strong-style : Strong style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md050.md
|
||||
* MD050/strong-style : Strong style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md050.md
|
||||
*/
|
||||
"strong-style"?:
|
||||
| boolean
|
||||
|
@ -935,7 +961,7 @@ export interface ConfigurationStrict {
|
|||
style?: "consistent" | "asterisk" | "underscore";
|
||||
};
|
||||
/**
|
||||
* MD051/link-fragments : Link fragments should be valid : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md051.md
|
||||
* MD051/link-fragments : Link fragments should be valid : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md051.md
|
||||
*/
|
||||
MD051?:
|
||||
| boolean
|
||||
|
@ -944,9 +970,13 @@ export interface ConfigurationStrict {
|
|||
* Ignore case of fragments
|
||||
*/
|
||||
ignore_case?: boolean;
|
||||
/**
|
||||
* Pattern for ignoring additional fragments
|
||||
*/
|
||||
ignored_pattern?: string;
|
||||
};
|
||||
/**
|
||||
* MD051/link-fragments : Link fragments should be valid : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md051.md
|
||||
* MD051/link-fragments : Link fragments should be valid : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md051.md
|
||||
*/
|
||||
"link-fragments"?:
|
||||
| boolean
|
||||
|
@ -955,31 +985,43 @@ export interface ConfigurationStrict {
|
|||
* Ignore case of fragments
|
||||
*/
|
||||
ignore_case?: boolean;
|
||||
/**
|
||||
* Pattern for ignoring additional fragments
|
||||
*/
|
||||
ignored_pattern?: string;
|
||||
};
|
||||
/**
|
||||
* MD052/reference-links-images : Reference links and images should use a label that is defined : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md052.md
|
||||
* MD052/reference-links-images : Reference links and images should use a label that is defined : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md052.md
|
||||
*/
|
||||
MD052?:
|
||||
| boolean
|
||||
| {
|
||||
/**
|
||||
* Include shortcut syntax
|
||||
* Ignored link labels
|
||||
*/
|
||||
shortcut_syntax?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD052/reference-links-images : Reference links and images should use a label that is defined : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md052.md
|
||||
*/
|
||||
"reference-links-images"?:
|
||||
| boolean
|
||||
| {
|
||||
ignored_labels?: string[];
|
||||
/**
|
||||
* Include shortcut syntax
|
||||
*/
|
||||
shortcut_syntax?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD053/link-image-reference-definitions : Link and image reference definitions should be needed : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md053.md
|
||||
* MD052/reference-links-images : Reference links and images should use a label that is defined : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md052.md
|
||||
*/
|
||||
"reference-links-images"?:
|
||||
| boolean
|
||||
| {
|
||||
/**
|
||||
* Ignored link labels
|
||||
*/
|
||||
ignored_labels?: string[];
|
||||
/**
|
||||
* Include shortcut syntax
|
||||
*/
|
||||
shortcut_syntax?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD053/link-image-reference-definitions : Link and image reference definitions should be needed : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md053.md
|
||||
*/
|
||||
MD053?:
|
||||
| boolean
|
||||
|
@ -990,7 +1032,7 @@ export interface ConfigurationStrict {
|
|||
ignored_definitions?: string[];
|
||||
};
|
||||
/**
|
||||
* MD053/link-image-reference-definitions : Link and image reference definitions should be needed : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md053.md
|
||||
* MD053/link-image-reference-definitions : Link and image reference definitions should be needed : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md053.md
|
||||
*/
|
||||
"link-image-reference-definitions"?:
|
||||
| boolean
|
||||
|
@ -1001,7 +1043,7 @@ export interface ConfigurationStrict {
|
|||
ignored_definitions?: string[];
|
||||
};
|
||||
/**
|
||||
* MD054/link-image-style : Link and image style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md054.md
|
||||
* MD054/link-image-style : Link and image style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md054.md
|
||||
*/
|
||||
MD054?:
|
||||
| boolean
|
||||
|
@ -1032,7 +1074,7 @@ export interface ConfigurationStrict {
|
|||
url_inline?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD054/link-image-style : Link and image style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md054.md
|
||||
* MD054/link-image-style : Link and image style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md054.md
|
||||
*/
|
||||
"link-image-style"?:
|
||||
| boolean
|
||||
|
@ -1063,7 +1105,7 @@ export interface ConfigurationStrict {
|
|||
url_inline?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD055/table-pipe-style : Table pipe style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md055.md
|
||||
* MD055/table-pipe-style : Table pipe style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md055.md
|
||||
*/
|
||||
MD055?:
|
||||
| boolean
|
||||
|
@ -1074,7 +1116,7 @@ export interface ConfigurationStrict {
|
|||
style?: "consistent" | "leading_only" | "trailing_only" | "leading_and_trailing" | "no_leading_or_trailing";
|
||||
};
|
||||
/**
|
||||
* MD055/table-pipe-style : Table pipe style : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md055.md
|
||||
* MD055/table-pipe-style : Table pipe style : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md055.md
|
||||
*/
|
||||
"table-pipe-style"?:
|
||||
| boolean
|
||||
|
@ -1085,21 +1127,43 @@ export interface ConfigurationStrict {
|
|||
style?: "consistent" | "leading_only" | "trailing_only" | "leading_and_trailing" | "no_leading_or_trailing";
|
||||
};
|
||||
/**
|
||||
* MD056/table-column-count : Table column count : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md056.md
|
||||
* MD056/table-column-count : Table column count : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md056.md
|
||||
*/
|
||||
MD056?: boolean;
|
||||
/**
|
||||
* MD056/table-column-count : Table column count : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md056.md
|
||||
* MD056/table-column-count : Table column count : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md056.md
|
||||
*/
|
||||
"table-column-count"?: boolean;
|
||||
/**
|
||||
* MD058/blanks-around-tables : Tables should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md058.md
|
||||
* MD058/blanks-around-tables : Tables should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md058.md
|
||||
*/
|
||||
MD058?: boolean;
|
||||
/**
|
||||
* MD058/blanks-around-tables : Tables should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.36.1/doc/md058.md
|
||||
* MD058/blanks-around-tables : Tables should be surrounded by blank lines : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md058.md
|
||||
*/
|
||||
"blanks-around-tables"?: boolean;
|
||||
/**
|
||||
* MD059/descriptive-link-text : Link text should be descriptive : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md059.md
|
||||
*/
|
||||
MD059?:
|
||||
| boolean
|
||||
| {
|
||||
/**
|
||||
* Prohibited link texts
|
||||
*/
|
||||
prohibited_texts?: string[];
|
||||
};
|
||||
/**
|
||||
* MD059/descriptive-link-text : Link text should be descriptive : https://github.com/DavidAnson/markdownlint/blob/v0.38.0/doc/md059.md
|
||||
*/
|
||||
"descriptive-link-text"?:
|
||||
| boolean
|
||||
| {
|
||||
/**
|
||||
* Prohibited link texts
|
||||
*/
|
||||
prohibited_texts?: string[];
|
||||
};
|
||||
/**
|
||||
* headings : MD001, MD003, MD018, MD019, MD020, MD021, MD022, MD023, MD024, MD025, MD026, MD036, MD041, MD043
|
||||
*/
|
||||
|
@ -1125,7 +1189,7 @@ export interface ConfigurationStrict {
|
|||
*/
|
||||
hard_tab?: boolean;
|
||||
/**
|
||||
* links : MD011, MD034, MD039, MD042, MD051, MD052, MD053, MD054
|
||||
* links : MD011, MD034, MD039, MD042, MD051, MD052, MD053, MD054, MD059
|
||||
*/
|
||||
links?: boolean;
|
||||
/**
|
||||
|
@ -1185,7 +1249,7 @@ export interface ConfigurationStrict {
|
|||
*/
|
||||
spelling?: boolean;
|
||||
/**
|
||||
* accessibility : MD045
|
||||
* accessibility : MD045, MD059
|
||||
*/
|
||||
accessibility?: boolean;
|
||||
/**
|
||||
|
|
2
lib/configuration.d.ts
vendored
2
lib/configuration.d.ts
vendored
|
@ -1,4 +1,4 @@
|
|||
import { ConfigurationStrict } from "./configuration-strict";
|
||||
import type { ConfigurationStrict } from "./configuration-strict.d.ts";
|
||||
|
||||
export interface Configuration extends ConfigurationStrict {
|
||||
/**
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports.deprecatedRuleNames = [];
|
||||
module.exports.fixableRuleNames = [
|
||||
export const deprecatedRuleNames = [];
|
||||
export const fixableRuleNames = [
|
||||
"MD004", "MD005", "MD007", "MD009", "MD010", "MD011",
|
||||
"MD012", "MD014", "MD018", "MD019", "MD020", "MD021",
|
||||
"MD022", "MD023", "MD026", "MD027", "MD030", "MD031",
|
||||
|
@ -11,5 +9,5 @@ module.exports.fixableRuleNames = [
|
|||
"MD047", "MD049", "MD050", "MD051", "MD053", "MD054",
|
||||
"MD058"
|
||||
];
|
||||
module.exports.homepage = "https://github.com/DavidAnson/markdownlint";
|
||||
module.exports.version = "0.36.1";
|
||||
export const homepage = "https://github.com/DavidAnson/markdownlint";
|
||||
export const version = "0.38.0";
|
16
lib/defer-require.cjs
Normal file
16
lib/defer-require.cjs
Normal file
|
@ -0,0 +1,16 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Calls require for markdownit.cjs. Used to synchronously defer loading because module.createRequire is buggy under webpack (https://github.com/webpack/webpack/issues/16724).
|
||||
*
|
||||
* @returns {any} Exported module content.
|
||||
*/
|
||||
function requireMarkdownItCjs() {
|
||||
return require("./markdownit.cjs");
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
requireMarkdownItCjs
|
||||
};
|
1
lib/exports-async.d.mts
Normal file
1
lib/exports-async.d.mts
Normal file
|
@ -0,0 +1 @@
|
|||
export { lintAsync as lint, readConfigAsync as readConfig } from "./markdownlint.mjs";
|
3
lib/exports-async.mjs
Normal file
3
lib/exports-async.mjs
Normal file
|
@ -0,0 +1,3 @@
|
|||
// @ts-check
|
||||
|
||||
export { lintAsync as lint, readConfigAsync as readConfig } from "./markdownlint.mjs";
|
1
lib/exports-promise.d.mts
Normal file
1
lib/exports-promise.d.mts
Normal file
|
@ -0,0 +1 @@
|
|||
export { extendConfigPromise as extendConfig, lintPromise as lint, readConfigPromise as readConfig } from "./markdownlint.mjs";
|
3
lib/exports-promise.mjs
Normal file
3
lib/exports-promise.mjs
Normal file
|
@ -0,0 +1,3 @@
|
|||
// @ts-check
|
||||
|
||||
export { extendConfigPromise as extendConfig, lintPromise as lint, readConfigPromise as readConfig } from "./markdownlint.mjs";
|
1
lib/exports-sync.d.mts
Normal file
1
lib/exports-sync.d.mts
Normal file
|
@ -0,0 +1 @@
|
|||
export { lintSync as lint, readConfigSync as readConfig } from "./markdownlint.mjs";
|
3
lib/exports-sync.mjs
Normal file
3
lib/exports-sync.mjs
Normal file
|
@ -0,0 +1,3 @@
|
|||
// @ts-check
|
||||
|
||||
export { lintSync as lint, readConfigSync as readConfig } from "./markdownlint.mjs";
|
30
lib/exports.d.mts
Normal file
30
lib/exports.d.mts
Normal file
|
@ -0,0 +1,30 @@
|
|||
export { resolveModule } from "./resolve-module.cjs";
|
||||
export type Configuration = import("./markdownlint.mjs").Configuration;
|
||||
export type ConfigurationParser = import("./markdownlint.mjs").ConfigurationParser;
|
||||
export type ConfigurationStrict = import("./markdownlint.mjs").ConfigurationStrict;
|
||||
export type FixInfo = import("./markdownlint.mjs").FixInfo;
|
||||
export type LintCallback = import("./markdownlint.mjs").LintCallback;
|
||||
export type LintContentCallback = import("./markdownlint.mjs").LintContentCallback;
|
||||
export type LintError = import("./markdownlint.mjs").LintError;
|
||||
export type LintResults = import("./markdownlint.mjs").LintResults;
|
||||
export type MarkdownItFactory = import("./markdownlint.mjs").MarkdownItFactory;
|
||||
export type MarkdownItToken = import("./markdownlint.mjs").MarkdownItToken;
|
||||
export type MarkdownParsers = import("./markdownlint.mjs").MarkdownParsers;
|
||||
export type MicromarkToken = import("./markdownlint.mjs").MicromarkToken;
|
||||
export type MicromarkTokenType = import("./markdownlint.mjs").MicromarkTokenType;
|
||||
export type Options = import("./markdownlint.mjs").Options;
|
||||
export type ParserMarkdownIt = import("./markdownlint.mjs").ParserMarkdownIt;
|
||||
export type ParserMicromark = import("./markdownlint.mjs").ParserMicromark;
|
||||
export type Plugin = import("./markdownlint.mjs").Plugin;
|
||||
export type ReadConfigCallback = import("./markdownlint.mjs").ReadConfigCallback;
|
||||
export type ResolveConfigExtendsCallback = import("./markdownlint.mjs").ResolveConfigExtendsCallback;
|
||||
export type Rule = import("./markdownlint.mjs").Rule;
|
||||
export type RuleConfiguration = import("./markdownlint.mjs").RuleConfiguration;
|
||||
export type RuleFunction = import("./markdownlint.mjs").RuleFunction;
|
||||
export type RuleOnError = import("./markdownlint.mjs").RuleOnError;
|
||||
export type RuleOnErrorFixInfo = import("./markdownlint.mjs").RuleOnErrorFixInfo;
|
||||
export type RuleOnErrorFixInfoNormalized = import("./markdownlint.mjs").RuleOnErrorFixInfoNormalized;
|
||||
export type RuleOnErrorInfo = import("./markdownlint.mjs").RuleOnErrorInfo;
|
||||
export type RuleParams = import("./markdownlint.mjs").RuleParams;
|
||||
export type ToStringCallback = import("./markdownlint.mjs").ToStringCallback;
|
||||
export { applyFix, applyFixes, getVersion } from "./markdownlint.mjs";
|
33
lib/exports.mjs
Normal file
33
lib/exports.mjs
Normal file
|
@ -0,0 +1,33 @@
|
|||
// @ts-check
|
||||
|
||||
export { applyFix, applyFixes, getVersion } from "./markdownlint.mjs";
|
||||
export { resolveModule } from "./resolve-module.cjs";
|
||||
|
||||
/** @typedef {import("./markdownlint.mjs").Configuration} Configuration */
|
||||
/** @typedef {import("./markdownlint.mjs").ConfigurationParser} ConfigurationParser */
|
||||
/** @typedef {import("./markdownlint.mjs").ConfigurationStrict} ConfigurationStrict */
|
||||
/** @typedef {import("./markdownlint.mjs").FixInfo} FixInfo */
|
||||
/** @typedef {import("./markdownlint.mjs").LintCallback} LintCallback */
|
||||
/** @typedef {import("./markdownlint.mjs").LintContentCallback} LintContentCallback */
|
||||
/** @typedef {import("./markdownlint.mjs").LintError} LintError */
|
||||
/** @typedef {import("./markdownlint.mjs").LintResults} LintResults */
|
||||
/** @typedef {import("./markdownlint.mjs").MarkdownItFactory} MarkdownItFactory */
|
||||
/** @typedef {import("./markdownlint.mjs").MarkdownItToken} MarkdownItToken */
|
||||
/** @typedef {import("./markdownlint.mjs").MarkdownParsers} MarkdownParsers */
|
||||
/** @typedef {import("./markdownlint.mjs").MicromarkToken} MicromarkToken */
|
||||
/** @typedef {import("./markdownlint.mjs").MicromarkTokenType} MicromarkTokenType */
|
||||
/** @typedef {import("./markdownlint.mjs").Options} Options */
|
||||
/** @typedef {import("./markdownlint.mjs").ParserMarkdownIt} ParserMarkdownIt */
|
||||
/** @typedef {import("./markdownlint.mjs").ParserMicromark} ParserMicromark */
|
||||
/** @typedef {import("./markdownlint.mjs").Plugin} Plugin */
|
||||
/** @typedef {import("./markdownlint.mjs").ReadConfigCallback} ReadConfigCallback */
|
||||
/** @typedef {import("./markdownlint.mjs").ResolveConfigExtendsCallback} ResolveConfigExtendsCallback */
|
||||
/** @typedef {import("./markdownlint.mjs").Rule} Rule */
|
||||
/** @typedef {import("./markdownlint.mjs").RuleConfiguration} RuleConfiguration */
|
||||
/** @typedef {import("./markdownlint.mjs").RuleFunction} RuleFunction */
|
||||
/** @typedef {import("./markdownlint.mjs").RuleOnError} RuleOnError */
|
||||
/** @typedef {import("./markdownlint.mjs").RuleOnErrorFixInfo} RuleOnErrorFixInfo */
|
||||
/** @typedef {import("./markdownlint.mjs").RuleOnErrorFixInfoNormalized} RuleOnErrorFixInfoNormalized */
|
||||
/** @typedef {import("./markdownlint.mjs").RuleOnErrorInfo} RuleOnErrorInfo */
|
||||
/** @typedef {import("./markdownlint.mjs").RuleParams} RuleParams */
|
||||
/** @typedef {import("./markdownlint.mjs").ToStringCallback} ToStringCallback */
|
|
@ -4,6 +4,11 @@
|
|||
|
||||
const { newLineRe } = require("../helpers");
|
||||
|
||||
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529
|
||||
/** @typedef {import("markdownlint").MarkdownIt} MarkdownIt */
|
||||
/** @typedef {import("markdownlint").MarkdownItToken} MarkdownItToken */
|
||||
/** @typedef {import("markdownlint").Plugin} Plugin */
|
||||
|
||||
/**
|
||||
* @callback InlineCodeSpanCallback
|
||||
* @param {string} code Code content.
|
||||
|
@ -67,7 +72,7 @@ function forEachInlineCodeSpan(input, handler) {
|
|||
/**
|
||||
* Freeze all freeze-able members of a token and its children.
|
||||
*
|
||||
* @param {import("./markdownlint").MarkdownItToken} token A markdown-it token.
|
||||
* @param {MarkdownItToken} token A markdown-it token.
|
||||
* @returns {void}
|
||||
*/
|
||||
function freezeToken(token) {
|
||||
|
@ -92,14 +97,13 @@ function freezeToken(token) {
|
|||
/**
|
||||
* Annotate tokens with line/lineNumber and freeze them.
|
||||
*
|
||||
* @param {Object[]} tokens Array of markdown-it tokens.
|
||||
* @param {import("markdown-it").Token[]} tokens Array of markdown-it tokens.
|
||||
* @param {string[]} lines Lines of Markdown content.
|
||||
* @returns {void}
|
||||
*/
|
||||
function annotateAndFreezeTokens(tokens, lines) {
|
||||
let trMap = null;
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").MarkdownItToken[] */
|
||||
/** @type {MarkdownItToken[]} */
|
||||
// @ts-ignore
|
||||
const markdownItTokens = tokens;
|
||||
for (const token of markdownItTokens) {
|
||||
|
@ -148,21 +152,14 @@ function annotateAndFreezeTokens(tokens, lines) {
|
|||
/**
|
||||
* Gets an array of markdown-it tokens for the input.
|
||||
*
|
||||
* @param {import("./markdownlint").Plugin[]} markdownItPlugins Additional plugins.
|
||||
* @param {MarkdownIt} markdownIt Instance of the markdown-it parser.
|
||||
* @param {string} content Markdown content.
|
||||
* @param {string[]} lines Lines of Markdown content.
|
||||
* @returns {import("../lib/markdownlint").MarkdownItToken} Array of markdown-it tokens.
|
||||
* @returns {MarkdownItToken[]} Array of markdown-it tokens.
|
||||
*/
|
||||
function getMarkdownItTokens(markdownItPlugins, content, lines) {
|
||||
const markdownit = require("markdown-it");
|
||||
const md = markdownit({ "html": true });
|
||||
for (const plugin of markdownItPlugins) {
|
||||
// @ts-ignore
|
||||
md.use(...plugin);
|
||||
}
|
||||
const tokens = md.parse(content, {});
|
||||
function getMarkdownItTokens(markdownIt, content, lines) {
|
||||
const tokens = markdownIt.parse(content, {});
|
||||
annotateAndFreezeTokens(tokens, lines);
|
||||
// @ts-ignore
|
||||
return tokens;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
export = markdownlint;
|
||||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
|
@ -6,49 +5,60 @@ export = markdownlint;
|
|||
* @param {LintCallback} callback Callback (err, result) function.
|
||||
* @returns {void}
|
||||
*/
|
||||
declare function markdownlint(options: Options | null, callback: LintCallback): void;
|
||||
declare namespace markdownlint {
|
||||
export { markdownlintSync as sync, readConfig, readConfigSync, getVersion, promises, applyFix, applyFixes, RuleFunction, RuleParams, MarkdownParsers, ParserMarkdownIt, ParserMicromark, MarkdownItToken, MicromarkTokenType, MicromarkToken, RuleOnError, RuleOnErrorInfo, RuleOnErrorFixInfo, RuleOnErrorFixInfoNormalized, Rule, Options, Plugin, ToStringCallback, LintResults, LintError, FixInfo, LintContentCallback, LintCallback, Configuration, ConfigurationStrict, RuleConfiguration, ConfigurationParser, ReadConfigCallback, ResolveConfigExtendsCallback };
|
||||
}
|
||||
export function lintAsync(options: Options | null, callback: LintCallback): void;
|
||||
/**
|
||||
* Lint specified Markdown files synchronously.
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @returns {Promise<LintResults>} Results object.
|
||||
*/
|
||||
export function lintPromise(options: Options | null): Promise<LintResults>;
|
||||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @returns {LintResults} Results object.
|
||||
*/
|
||||
declare function markdownlintSync(options: Options | null): LintResults;
|
||||
export function lintSync(options: Options | null): LintResults;
|
||||
/**
|
||||
* Extend specified configuration object.
|
||||
*
|
||||
* @param {Configuration} config Configuration object.
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[] | undefined} parsers Parsing function(s).
|
||||
* @param {Object} fs File system implementation.
|
||||
* @returns {Promise<Configuration>} Configuration object.
|
||||
*/
|
||||
export function extendConfigPromise(config: Configuration, file: string, parsers: ConfigurationParser[] | undefined, fs: any): Promise<Configuration>;
|
||||
/**
|
||||
* Read specified configuration file.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[] | ReadConfigCallback} parsers Parsing
|
||||
* @param {ConfigurationParser[] | ReadConfigCallback} [parsers] Parsing
|
||||
* function(s).
|
||||
* @param {Object} [fs] File system implementation.
|
||||
* @param {ReadConfigCallback} [callback] Callback (err, result) function.
|
||||
* @returns {void}
|
||||
*/
|
||||
declare function readConfig(file: string, parsers: ConfigurationParser[] | ReadConfigCallback, fs?: any, callback?: ReadConfigCallback): void;
|
||||
export function readConfigAsync(file: string, parsers?: ConfigurationParser[] | ReadConfigCallback, fs?: any, callback?: ReadConfigCallback): void;
|
||||
/**
|
||||
* Read specified configuration file synchronously.
|
||||
* Read specified configuration file.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
||||
* @param {Object} [fs] File system implementation.
|
||||
* @returns {Promise<Configuration>} Configuration object.
|
||||
*/
|
||||
export function readConfigPromise(file: string, parsers?: ConfigurationParser[], fs?: any): Promise<Configuration>;
|
||||
/**
|
||||
* Read specified configuration file.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
||||
* @param {Object} [fs] File system implementation.
|
||||
* @returns {Configuration} Configuration object.
|
||||
* @throws An Error if processing fails.
|
||||
*/
|
||||
declare function readConfigSync(file: string, parsers?: ConfigurationParser[], fs?: any): Configuration;
|
||||
/**
|
||||
* Gets the (semantic) version of the library.
|
||||
*
|
||||
* @returns {string} SemVer string.
|
||||
*/
|
||||
declare function getVersion(): string;
|
||||
declare namespace promises {
|
||||
export { markdownlintPromise as markdownlint };
|
||||
export { extendConfigPromise as extendConfig };
|
||||
export { readConfigPromise as readConfig };
|
||||
}
|
||||
export function readConfigSync(file: string, parsers?: ConfigurationParser[], fs?: any): Configuration;
|
||||
/**
|
||||
* Applies the specified fix to a Markdown content line.
|
||||
*
|
||||
|
@ -57,7 +67,7 @@ declare namespace promises {
|
|||
* @param {string} [lineEnding] Line ending to use.
|
||||
* @returns {string | null} Fixed content or null if deleted.
|
||||
*/
|
||||
declare function applyFix(line: string, fixInfo: RuleOnErrorFixInfo, lineEnding?: string): string | null;
|
||||
export function applyFix(line: string, fixInfo: RuleOnErrorFixInfo, lineEnding?: string): string | null;
|
||||
/**
|
||||
* Applies as many of the specified fixes as possible to Markdown content.
|
||||
*
|
||||
|
@ -65,15 +75,38 @@ declare function applyFix(line: string, fixInfo: RuleOnErrorFixInfo, lineEnding?
|
|||
* @param {RuleOnErrorInfo[]} errors RuleOnErrorInfo instances.
|
||||
* @returns {string} Fixed content.
|
||||
*/
|
||||
declare function applyFixes(input: string, errors: RuleOnErrorInfo[]): string;
|
||||
export function applyFixes(input: string, errors: RuleOnErrorInfo[]): string;
|
||||
/**
|
||||
* Gets the (semantic) version of the library.
|
||||
*
|
||||
* @returns {string} SemVer string.
|
||||
*/
|
||||
export function getVersion(): string;
|
||||
/**
|
||||
* Result object for getEnabledRulesPerLineNumber.
|
||||
*/
|
||||
export type EnabledRulesPerLineNumberResult = {
|
||||
/**
|
||||
* Effective configuration.
|
||||
*/
|
||||
effectiveConfig: Configuration;
|
||||
/**
|
||||
* Enabled rules per line number.
|
||||
*/
|
||||
enabledRulesPerLineNumber: any[];
|
||||
/**
|
||||
* Enabled rule list.
|
||||
*/
|
||||
enabledRuleList: Rule[];
|
||||
};
|
||||
/**
|
||||
* Function to implement rule logic.
|
||||
*/
|
||||
type RuleFunction = (params: RuleParams, onError: RuleOnError) => void;
|
||||
export type RuleFunction = (params: RuleParams, onError: RuleOnError) => void;
|
||||
/**
|
||||
* Rule parameters.
|
||||
*/
|
||||
type RuleParams = {
|
||||
export type RuleParams = {
|
||||
/**
|
||||
* File/string name.
|
||||
*/
|
||||
|
@ -102,7 +135,7 @@ type RuleParams = {
|
|||
/**
|
||||
* Markdown parser data.
|
||||
*/
|
||||
type MarkdownParsers = {
|
||||
export type MarkdownParsers = {
|
||||
/**
|
||||
* Markdown parser data from markdown-it (only present when Rule.parser is "markdownit").
|
||||
*/
|
||||
|
@ -115,7 +148,7 @@ type MarkdownParsers = {
|
|||
/**
|
||||
* Markdown parser data from markdown-it.
|
||||
*/
|
||||
type ParserMarkdownIt = {
|
||||
export type ParserMarkdownIt = {
|
||||
/**
|
||||
* Token objects from markdown-it.
|
||||
*/
|
||||
|
@ -124,7 +157,7 @@ type ParserMarkdownIt = {
|
|||
/**
|
||||
* Markdown parser data from micromark.
|
||||
*/
|
||||
type ParserMicromark = {
|
||||
export type ParserMicromark = {
|
||||
/**
|
||||
* Token objects from micromark.
|
||||
*/
|
||||
|
@ -133,7 +166,7 @@ type ParserMicromark = {
|
|||
/**
|
||||
* markdown-it token.
|
||||
*/
|
||||
type MarkdownItToken = {
|
||||
export type MarkdownItToken = {
|
||||
/**
|
||||
* HTML attributes.
|
||||
*/
|
||||
|
@ -195,11 +228,11 @@ type MarkdownItToken = {
|
|||
*/
|
||||
line: string;
|
||||
};
|
||||
type MicromarkTokenType = import("markdownlint-micromark").TokenType;
|
||||
export type MicromarkTokenType = import("micromark-util-types").TokenType;
|
||||
/**
|
||||
* micromark token.
|
||||
*/
|
||||
type MicromarkToken = {
|
||||
export type MicromarkToken = {
|
||||
/**
|
||||
* Token type.
|
||||
*/
|
||||
|
@ -236,11 +269,11 @@ type MicromarkToken = {
|
|||
/**
|
||||
* Error-reporting callback.
|
||||
*/
|
||||
type RuleOnError = (onErrorInfo: RuleOnErrorInfo) => void;
|
||||
export type RuleOnError = (onErrorInfo: RuleOnErrorInfo) => void;
|
||||
/**
|
||||
* Fix information for RuleOnError callback.
|
||||
*/
|
||||
type RuleOnErrorInfo = {
|
||||
export type RuleOnErrorInfo = {
|
||||
/**
|
||||
* Line number (1-based).
|
||||
*/
|
||||
|
@ -269,7 +302,7 @@ type RuleOnErrorInfo = {
|
|||
/**
|
||||
* Fix information for RuleOnErrorInfo.
|
||||
*/
|
||||
type RuleOnErrorFixInfo = {
|
||||
export type RuleOnErrorFixInfo = {
|
||||
/**
|
||||
* Line number (1-based).
|
||||
*/
|
||||
|
@ -290,7 +323,7 @@ type RuleOnErrorFixInfo = {
|
|||
/**
|
||||
* RuleOnErrorInfo with all optional properties present.
|
||||
*/
|
||||
type RuleOnErrorFixInfoNormalized = {
|
||||
export type RuleOnErrorFixInfoNormalized = {
|
||||
/**
|
||||
* Line number (1-based).
|
||||
*/
|
||||
|
@ -311,7 +344,7 @@ type RuleOnErrorFixInfoNormalized = {
|
|||
/**
|
||||
* Rule definition.
|
||||
*/
|
||||
type Rule = {
|
||||
export type Rule = {
|
||||
/**
|
||||
* Rule name(s).
|
||||
*/
|
||||
|
@ -341,10 +374,27 @@ type Rule = {
|
|||
*/
|
||||
function: RuleFunction;
|
||||
};
|
||||
/**
|
||||
* Method used by the markdown-it parser to parse input.
|
||||
*/
|
||||
export type MarkdownItParse = (src: string, env: any) => any[];
|
||||
/**
|
||||
* Instance of the markdown-it parser.
|
||||
*/
|
||||
export type MarkdownIt = {
|
||||
/**
|
||||
* Method to parse input.
|
||||
*/
|
||||
parse: MarkdownItParse;
|
||||
};
|
||||
/**
|
||||
* Gets an instance of the markdown-it parser. Any plugins should already have been loaded.
|
||||
*/
|
||||
export type MarkdownItFactory = () => MarkdownIt | Promise<MarkdownIt>;
|
||||
/**
|
||||
* Configuration options.
|
||||
*/
|
||||
type Options = {
|
||||
export type Options = {
|
||||
/**
|
||||
* Configuration object.
|
||||
*/
|
||||
|
@ -374,9 +424,9 @@ type Options = {
|
|||
*/
|
||||
handleRuleFailures?: boolean;
|
||||
/**
|
||||
* Additional plugins.
|
||||
* Function to create a markdown-it parser.
|
||||
*/
|
||||
markdownItPlugins?: Plugin[];
|
||||
markdownItFactory?: MarkdownItFactory;
|
||||
/**
|
||||
* True to ignore HTML directives.
|
||||
*/
|
||||
|
@ -395,21 +445,21 @@ type Options = {
|
|||
/**
|
||||
* A markdown-it plugin.
|
||||
*/
|
||||
type Plugin = any[];
|
||||
export type Plugin = any[];
|
||||
/**
|
||||
* Function to pretty-print lint results.
|
||||
*/
|
||||
type ToStringCallback = (ruleAliases?: boolean) => string;
|
||||
export type ToStringCallback = (ruleAliases?: boolean) => string;
|
||||
/**
|
||||
* Lint results (for resultVersion 3).
|
||||
*/
|
||||
type LintResults = {
|
||||
export type LintResults = {
|
||||
[x: string]: LintError[];
|
||||
};
|
||||
/**
|
||||
* Lint error.
|
||||
*/
|
||||
type LintError = {
|
||||
export type LintError = {
|
||||
/**
|
||||
* Line number (1-based).
|
||||
*/
|
||||
|
@ -446,7 +496,7 @@ type LintError = {
|
|||
/**
|
||||
* Fix information.
|
||||
*/
|
||||
type FixInfo = {
|
||||
export type FixInfo = {
|
||||
/**
|
||||
* Line number (1-based).
|
||||
*/
|
||||
|
@ -467,60 +517,34 @@ type FixInfo = {
|
|||
/**
|
||||
* Called with the result of linting a string or document.
|
||||
*/
|
||||
type LintContentCallback = (error: Error | null, result?: LintError[]) => void;
|
||||
export type LintContentCallback = (error: Error | null, result?: LintError[]) => void;
|
||||
/**
|
||||
* Called with the result of the lint function.
|
||||
*/
|
||||
type LintCallback = (error: Error | null, results?: LintResults) => void;
|
||||
export type LintCallback = (error: Error | null, results?: LintResults) => void;
|
||||
/**
|
||||
* Configuration object for linting rules. For the JSON schema, see
|
||||
* {@link ../schema/markdownlint-config-schema.json}.
|
||||
*/
|
||||
type Configuration = import("./configuration").Configuration;
|
||||
export type Configuration = import("./configuration.d.ts").Configuration;
|
||||
/**
|
||||
* Configuration object for linting rules strictly. For the JSON schema, see
|
||||
* {@link ../schema/markdownlint-config-schema-strict.json}.
|
||||
*/
|
||||
type ConfigurationStrict = import("./configuration-strict").ConfigurationStrict;
|
||||
export type ConfigurationStrict = import("./configuration-strict.d.ts").ConfigurationStrict;
|
||||
/**
|
||||
* Rule configuration.
|
||||
*/
|
||||
type RuleConfiguration = boolean | any;
|
||||
export type RuleConfiguration = boolean | any;
|
||||
/**
|
||||
* Parses a configuration string and returns a configuration object.
|
||||
*/
|
||||
type ConfigurationParser = (text: string) => Configuration;
|
||||
export type ConfigurationParser = (text: string) => Configuration;
|
||||
/**
|
||||
* Called with the result of the readConfig function.
|
||||
*/
|
||||
type ReadConfigCallback = (err: Error | null, config?: Configuration) => void;
|
||||
export type ReadConfigCallback = (err: Error | null, config?: Configuration) => void;
|
||||
/**
|
||||
* Called with the result of the resolveConfigExtends function.
|
||||
*/
|
||||
type ResolveConfigExtendsCallback = (err: Error | null, path?: string) => void;
|
||||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options} options Configuration options.
|
||||
* @returns {Promise<LintResults>} Results object.
|
||||
*/
|
||||
declare function markdownlintPromise(options: Options): Promise<LintResults>;
|
||||
/**
|
||||
* Extend specified configuration object.
|
||||
*
|
||||
* @param {Configuration} config Configuration object.
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
||||
* @param {Object} [fs] File system implementation.
|
||||
* @returns {Promise<Configuration>} Configuration object.
|
||||
*/
|
||||
declare function extendConfigPromise(config: Configuration, file: string, parsers?: ConfigurationParser[], fs?: any): Promise<Configuration>;
|
||||
/**
|
||||
* Read specified configuration file.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
||||
* @param {Object} [fs] File system implementation.
|
||||
* @returns {Promise<Configuration>} Configuration object.
|
||||
*/
|
||||
declare function readConfigPromise(file: string, parsers?: ConfigurationParser[], fs?: any): Promise<Configuration>;
|
||||
export type ResolveConfigExtendsCallback = (err: Error | null, path?: string) => void;
|
File diff suppressed because it is too large
Load diff
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getHeadingLevel } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getHeadingLevel } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD001", "heading-increment" ],
|
||||
"description": "Heading levels should only increment by one level at a time",
|
||||
"tags": [ "headings" ],
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getHeadingLevel, getHeadingStyle } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getHeadingLevel, getHeadingStyle } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD003", "heading-style" ],
|
||||
"description": "Heading style",
|
||||
"tags": [ "headings" ],
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getDescendantsByType, getParentOfType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType, getParentOfType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const markerToStyle = {
|
||||
"-": "dash",
|
||||
|
@ -29,9 +27,8 @@ const validStyles = new Set([
|
|||
"sublist"
|
||||
]);
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD004", "ul-style" ],
|
||||
"description": "Unordered list style",
|
||||
"tags": [ "bullet", "ul" ],
|
||||
|
@ -43,7 +40,7 @@ module.exports = {
|
|||
for (const listUnordered of filterByTypesCached([ "listUnordered" ])) {
|
||||
let nesting = 0;
|
||||
if (style === "sublist") {
|
||||
/** @type {import("../helpers/micromark-helpers.cjs").Token | null} */
|
||||
/** @type {import("markdownlint").MicromarkToken | null} */
|
||||
let parent = listUnordered;
|
||||
// @ts-ignore
|
||||
while ((parent = getParentOfType(parent, [ "listOrdered", "listUnordered" ]))) {
|
|
@ -1,13 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError, addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addError, addErrorDetailIf } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD005", "list-indent" ],
|
||||
"description": "Inconsistent indentation for list items at the same level",
|
||||
"tags": [ "bullet", "ul", "indentation" ],
|
|
@ -1,23 +1,18 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getParentOfType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getParentOfType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("markdownlint-micromark").TokenType[] */
|
||||
/** @type {import("micromark-util-types").TokenType[]} */
|
||||
const unorderedListTypes =
|
||||
[ "blockQuotePrefix", "listItemPrefix", "listUnordered" ];
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("markdownlint-micromark").TokenType[] */
|
||||
/** @type {import("micromark-util-types").TokenType[]} */
|
||||
const unorderedParentTypes =
|
||||
[ "blockQuote", "listOrdered", "listUnordered" ];
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD007", "ul-indent" ],
|
||||
"description": "Unordered list indentation",
|
||||
"tags": [ "bullet", "ul", "indentation" ],
|
||||
|
@ -35,7 +30,7 @@ module.exports = {
|
|||
lastBlockQuotePrefix = token;
|
||||
} else if (type === "listUnordered") {
|
||||
let nesting = 0;
|
||||
/** @type {import("../helpers/micromark-helpers.cjs").Token | null} */
|
||||
/** @type {import("markdownlint").MicromarkToken | null} */
|
||||
let current = token;
|
||||
while (
|
||||
// @ts-ignore
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError } from "../helpers/helpers.cjs";
|
||||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addError } = require("../helpers");
|
||||
const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD009", "no-trailing-spaces" ],
|
||||
"description": "Trailing spaces",
|
||||
"tags": [ "whitespace" ],
|
|
@ -1,16 +1,13 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addError, hasOverlap } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addError, hasOverlap } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const tabRe = /\t+/g;
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD010", "no-hard-tabs" ],
|
||||
"description": "Hard tabs",
|
||||
"tags": [ "whitespace", "hard_tab" ],
|
||||
|
@ -26,8 +23,7 @@ module.exports = {
|
|||
const spaceMultiplier = (spacesPerTab === undefined) ?
|
||||
1 :
|
||||
Math.max(0, Number(spacesPerTab));
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("../helpers/micromark-helpers.cjs").TokenType[] */
|
||||
/** @type {import("markdownlint").MicromarkTokenType[]} */
|
||||
const exclusionTypes = [];
|
||||
if (includeCode) {
|
||||
if (ignoreCodeLanguages.size > 0) {
|
||||
|
@ -60,7 +56,7 @@ module.exports = {
|
|||
const lineNumber = lineIndex + 1;
|
||||
const column = match.index + 1;
|
||||
const length = match[0].length;
|
||||
/** @type {import("../helpers").FileRange} */
|
||||
/** @type {import("../helpers/helpers.cjs").FileRange} */
|
||||
const range = { "startLine": lineNumber, "startColumn": column, "endLine": lineNumber, "endColumn": column + length - 1 };
|
||||
if (!codeRanges.some((codeRange) => hasOverlap(codeRange, range))) {
|
||||
addError(
|
|
@ -1,17 +1,13 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError, hasOverlap } from "../helpers/helpers.cjs";
|
||||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addError, hasOverlap } = require("../helpers");
|
||||
const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
const reversedLinkRe = /(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;
|
||||
|
||||
const reversedLinkRe =
|
||||
/(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD011", "no-reversed-links" ],
|
||||
"description": "Reversed link syntax",
|
||||
"tags": [ "links" ],
|
||||
|
@ -34,7 +30,7 @@ module.exports = {
|
|||
) {
|
||||
const column = match.index + preChar.length + 1;
|
||||
const length = match[0].length - preChar.length;
|
||||
/** @type {import("../helpers").FileRange} */
|
||||
/** @type {import("../helpers/helpers.cjs").FileRange} */
|
||||
const range = { "startLine": lineNumber, "startColumn": column, "endLine": lineNumber, "endColumn": column + length - 1 };
|
||||
if (!codeTexts.some((codeText) => hasOverlap(codeText, range))) {
|
||||
addError(
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD012", "no-multiple-blanks" ],
|
||||
"description": "Multiple consecutive blank lines",
|
||||
"tags": [ "whitespace", "blank_lines" ],
|
|
@ -1,20 +1,19 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getReferenceLinkImageData } = require("./cache");
|
||||
const { addRangeToSet, getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached, getReferenceLinkImageData } from "./cache.mjs";
|
||||
import { addRangeToSet, getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
|
||||
const longLineRePrefix = "^.{";
|
||||
const longLineRePostfixRelaxed = "}.*\\s.*$";
|
||||
const longLineRePostfixStrict = "}.+$";
|
||||
const sternModeRe = /^(?:[#>\s]*\s)?\S*$/;
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @typedef {import("micromark-extension-gfm-autolink-literal")} */
|
||||
/** @typedef {import("micromark-extension-gfm-table")} */
|
||||
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD013", "line-length" ],
|
||||
"description": "Line length",
|
||||
"tags": [ "line_length" ],
|
|
@ -1,15 +1,12 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const dollarCommandRe = /^(\s*)(\$\s+)/;
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD014", "commands-show-output" ],
|
||||
"description": "Dollar signs used before commands without showing output",
|
||||
"tags": [ "code" ],
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD018", "no-missing-space-atx" ],
|
||||
"description": "No space after hash on atx style heading",
|
||||
"tags": [ "headings", "atx", "spaces" ],
|
|
@ -1,16 +1,14 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext } = require("../helpers/helpers");
|
||||
const { getHeadingStyle } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { getHeadingStyle } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/**
|
||||
* Validate heading sequence and whitespace length at start or end.
|
||||
*
|
||||
* @param {import("./markdownlint").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("./markdownlint").MicromarkToken} heading ATX heading token.
|
||||
* @param {import("markdownlint").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("markdownlint").MicromarkToken} heading ATX heading token.
|
||||
* @param {number} delta Direction to scan.
|
||||
* @returns {void}
|
||||
*/
|
||||
|
@ -47,9 +45,8 @@ function validateHeadingSpaces(onError, heading, delta) {
|
|||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule[] */
|
||||
module.exports = [
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
export default [
|
||||
{
|
||||
"names": [ "MD019", "no-multiple-space-atx" ],
|
||||
"description": "Multiple spaces after hash on atx style heading",
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD020", "no-missing-space-closed-atx" ],
|
||||
"description": "No space inside hashes on closed atx style heading",
|
||||
"tags": [ "headings", "atx_closed", "spaces" ],
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf, isBlankLine } = require("../helpers");
|
||||
const { getBlockQuotePrefixText, getHeadingLevel } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf, isBlankLine } from "../helpers/helpers.cjs";
|
||||
import { getBlockQuotePrefixText, getHeadingLevel } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const defaultLines = 1;
|
||||
|
||||
|
@ -21,9 +19,8 @@ const getLinesFunction = (linesParam) => {
|
|||
return () => lines;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD022", "blanks-around-headings" ],
|
||||
"description": "Headings should be surrounded by blank lines",
|
||||
"tags": [ "headings", "blank_lines" ],
|
|
@ -1,13 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD023", "heading-start-left" ],
|
||||
"description": "Headings must start at the beginning of the line",
|
||||
"tags": [ "headings", "spaces" ],
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { getHeadingLevel, getHeadingText } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { getHeadingLevel, getHeadingText } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD024", "no-duplicate-heading" ],
|
||||
"description": "Multiple headings with the same content",
|
||||
"tags": [ "headings" ],
|
40
lib/md025.js
40
lib/md025.js
|
@ -1,40 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext, frontMatterHasTitle } = require("../helpers");
|
||||
const { getHeadingLevel, getHeadingText } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
"names": [ "MD025", "single-title", "single-h1" ],
|
||||
"description": "Multiple top-level headings in the same document",
|
||||
"tags": [ "headings" ],
|
||||
"parser": "micromark",
|
||||
"function": function MD025(params, onError) {
|
||||
const level = Number(params.config.level || 1);
|
||||
const foundFrontMatterTitle =
|
||||
frontMatterHasTitle(
|
||||
params.frontMatterLines,
|
||||
params.config.front_matter_title
|
||||
);
|
||||
let hasTopLevelHeading = false;
|
||||
for (const heading of filterByTypesCached([ "atxHeading", "setextHeading" ])) {
|
||||
const headingLevel = getHeadingLevel(heading);
|
||||
if (headingLevel === level) {
|
||||
if (hasTopLevelHeading || foundFrontMatterTitle) {
|
||||
const headingText = getHeadingText(heading);
|
||||
addErrorContext(
|
||||
onError,
|
||||
heading.startLine,
|
||||
headingText
|
||||
);
|
||||
} else if (heading.startLine === 1) {
|
||||
hasTopLevelHeading = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
45
lib/md025.mjs
Normal file
45
lib/md025.mjs
Normal file
|
@ -0,0 +1,45 @@
|
|||
// @ts-check
|
||||
|
||||
import { addErrorContext, frontMatterHasTitle } from "../helpers/helpers.cjs";
|
||||
import { getHeadingLevel, getHeadingText, isDocfxTab, isHtmlFlowComment, nonContentTokens } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD025", "single-title", "single-h1" ],
|
||||
"description": "Multiple top-level headings in the same document",
|
||||
"tags": [ "headings" ],
|
||||
"parser": "micromark",
|
||||
"function": function MD025(params, onError) {
|
||||
const level = Number(params.config.level || 1);
|
||||
const { tokens } = params.parsers.micromark;
|
||||
const matchingHeadings = filterByTypesCached([ "atxHeading", "setextHeading" ])
|
||||
.filter((heading) => (level === getHeadingLevel(heading)) && !isDocfxTab(heading));
|
||||
if (matchingHeadings.length > 0) {
|
||||
const foundFrontMatterTitle =
|
||||
frontMatterHasTitle(
|
||||
params.frontMatterLines,
|
||||
params.config.front_matter_title
|
||||
);
|
||||
// Front matter title counts as a top-level heading if present
|
||||
let hasTopLevelHeading = foundFrontMatterTitle;
|
||||
if (!hasTopLevelHeading) {
|
||||
// Check if the first matching heading is a top-level heading
|
||||
const previousTokens = tokens.slice(0, tokens.indexOf(matchingHeadings[0]));
|
||||
hasTopLevelHeading = previousTokens.every(
|
||||
(token) => nonContentTokens.has(token.type) || isHtmlFlowComment(token)
|
||||
);
|
||||
}
|
||||
if (hasTopLevelHeading) {
|
||||
// All other matching headings are violations
|
||||
for (const heading of matchingHeadings.slice(foundFrontMatterTitle ? 0 : 1)) {
|
||||
addErrorContext(
|
||||
onError,
|
||||
heading.startLine,
|
||||
getHeadingText(heading)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError, allPunctuationNoQuestion, endOfLineGemojiCodeRe,
|
||||
endOfLineHtmlEntityRe, escapeForRegExp } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addError, allPunctuationNoQuestion, endOfLineGemojiCodeRe,
|
||||
endOfLineHtmlEntityRe, escapeForRegExp } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD026", "no-trailing-punctuation" ],
|
||||
"description": "Trailing punctuation in heading",
|
||||
"tags": [ "headings" ],
|
37
lib/md027.js
37
lib/md027.js
|
@ -1,37 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
"names": [ "MD027", "no-multiple-space-blockquote" ],
|
||||
"description": "Multiple spaces after blockquote symbol",
|
||||
"tags": [ "blockquote", "whitespace", "indentation" ],
|
||||
"parser": "micromark",
|
||||
"function": function MD027(params, onError) {
|
||||
for (const token of filterByTypesCached([ "linePrefix" ])) {
|
||||
const siblings = token.parent?.children || params.parsers.micromark.tokens;
|
||||
if (siblings[siblings.indexOf(token) - 1]?.type === "blockQuotePrefix") {
|
||||
const { startColumn, startLine, text } = token;
|
||||
const { length } = text;
|
||||
const line = params.lines[startLine - 1];
|
||||
addErrorContext(
|
||||
onError,
|
||||
startLine,
|
||||
line,
|
||||
undefined,
|
||||
undefined,
|
||||
[ startColumn, length ],
|
||||
{
|
||||
"editColumn": startColumn,
|
||||
"deleteCount": length
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
50
lib/md027.mjs
Normal file
50
lib/md027.mjs
Normal file
|
@ -0,0 +1,50 @@
|
|||
// @ts-check
|
||||
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { getParentOfType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("../helpers/micromark-helpers.cjs").TokenType[]} */
|
||||
const listTypes = [ "listOrdered", "listUnordered" ];
|
||||
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD027", "no-multiple-space-blockquote" ],
|
||||
"description": "Multiple spaces after blockquote symbol",
|
||||
"tags": [ "blockquote", "whitespace", "indentation" ],
|
||||
"parser": "micromark",
|
||||
"function": function MD027(params, onError) {
|
||||
const listItems = params.config.list_items;
|
||||
const includeListItems = (listItems === undefined) ? true : !!listItems;
|
||||
const { tokens } = params.parsers.micromark;
|
||||
for (const token of filterByTypesCached([ "linePrefix" ])) {
|
||||
const parent = token.parent;
|
||||
const codeIndented = parent?.type === "codeIndented";
|
||||
const siblings = parent?.children || tokens;
|
||||
if (
|
||||
!codeIndented &&
|
||||
(siblings[siblings.indexOf(token) - 1]?.type === "blockQuotePrefix") &&
|
||||
(includeListItems || (
|
||||
!listTypes.includes(siblings[siblings.indexOf(token) + 1]?.type) &&
|
||||
!getParentOfType(token, listTypes)
|
||||
))
|
||||
) {
|
||||
const { startColumn, startLine, text } = token;
|
||||
const { length } = text;
|
||||
const line = params.lines[startLine - 1];
|
||||
addErrorContext(
|
||||
onError,
|
||||
startLine,
|
||||
line,
|
||||
undefined,
|
||||
undefined,
|
||||
[ startColumn, length ],
|
||||
{
|
||||
"editColumn": startColumn,
|
||||
"deleteCount": length
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,15 +1,12 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addError } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addError } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const ignoreTypes = new Set([ "lineEnding", "listItemIndent", "linePrefix" ]);
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD028", "no-blanks-blockquote" ],
|
||||
"description": "Blank line inside blockquote",
|
||||
"tags": [ "blockquote", "whitespace" ],
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const listStyleExamples = {
|
||||
"one": "1/1/1",
|
||||
|
@ -15,16 +13,15 @@ const listStyleExamples = {
|
|||
/**
|
||||
* Gets the value of an ordered list item prefix token.
|
||||
*
|
||||
* @param {import("../helpers/micromark-helpers.cjs").Token} listItemPrefix List item prefix token.
|
||||
* @param {import("markdownlint").MicromarkToken} listItemPrefix List item prefix token.
|
||||
* @returns {number} List item value.
|
||||
*/
|
||||
function getOrderedListItemValue(listItemPrefix) {
|
||||
return Number(getDescendantsByType(listItemPrefix, [ "listItemValue" ])[0].text);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD029", "ol-prefix" ],
|
||||
"description": "Ordered list item prefix",
|
||||
"tags": [ "ol" ],
|
|
@ -1,13 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD030", "list-marker-space" ],
|
||||
"description": "Spaces after list markers",
|
||||
"tags": [ "ol", "ul", "whitespace" ],
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext, isBlankLine } = require("../helpers");
|
||||
const { getParentOfType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext, isBlankLine } from "../helpers/helpers.cjs";
|
||||
import { getParentOfType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const codeFencePrefixRe = /^(.*?)[`~]/;
|
||||
|
||||
|
@ -14,7 +12,7 @@ const codeFencePrefixRe = /^(.*?)[`~]/;
|
|||
/**
|
||||
* Adds an error for the top or bottom of a code fence.
|
||||
*
|
||||
* @param {import("./markdownlint").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("markdownlint").RuleOnError} onError Error-reporting callback.
|
||||
* @param {ReadonlyStringArray} lines Lines of Markdown content.
|
||||
* @param {number} lineNumber Line number.
|
||||
* @param {boolean} top True iff top fence.
|
||||
|
@ -24,7 +22,7 @@ function addError(onError, lines, lineNumber, top) {
|
|||
const line = lines[lineNumber - 1];
|
||||
const [ , prefix ] = line.match(codeFencePrefixRe) || [];
|
||||
const fixInfo = (prefix === undefined) ?
|
||||
null :
|
||||
undefined :
|
||||
{
|
||||
"lineNumber": lineNumber + (top ? 0 : 1),
|
||||
"insertText": `${prefix.replace(/[^>]/g, " ").trim()}\n`
|
||||
|
@ -40,9 +38,8 @@ function addError(onError, lines, lineNumber, top) {
|
|||
);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD031", "blanks-around-fences" ],
|
||||
"description": "Fenced code blocks should be surrounded by blank lines",
|
||||
"tags": [ "code", "blank_lines" ],
|
|
@ -1,18 +1,15 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext, isBlankLine } = require("../helpers");
|
||||
const { filterByPredicate, getBlockQuotePrefixText, nonContentTokens } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext, isBlankLine } from "../helpers/helpers.cjs";
|
||||
import { filterByPredicate, getBlockQuotePrefixText, nonContentTokens } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const isList = (token) => (
|
||||
(token.type === "listOrdered") || (token.type === "listUnordered")
|
||||
);
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD032", "blanks-around-lists" ],
|
||||
"description": "Lists should be surrounded by blank lines",
|
||||
"tags": [ "bullet", "ul", "ol", "blank_lines" ],
|
||||
|
@ -48,13 +45,14 @@ module.exports = {
|
|||
}
|
||||
|
||||
// Find the "visual" end of the list
|
||||
const flattenedChildren = filterByPredicate(
|
||||
list.children,
|
||||
(token) => !nonContentTokens.has(token.type),
|
||||
(token) => nonContentTokens.has(token.type) ? [] : token.children
|
||||
);
|
||||
let endLine = list.endLine;
|
||||
const flattenedChildren = filterByPredicate(list.children);
|
||||
for (const child of flattenedChildren.reverse()) {
|
||||
if (!nonContentTokens.has(child.type)) {
|
||||
endLine = child.endLine;
|
||||
break;
|
||||
}
|
||||
if (flattenedChildren.length > 0) {
|
||||
endLine = flattenedChildren[flattenedChildren.length - 1].endLine;
|
||||
}
|
||||
|
||||
// Look for a blank line below the list
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue