Skip to content

markdownlint

markdownlint is the linter for markdown file.

安装

You have to install markdownlint-cli first. Currently markdownlint-cli v0.39 is supported.

shell
npm install markdownlint-cli -D
shell
yarn add markdownlint-cli -D
shell
pnpm install markdownlint-cli -D
shell
bun install markdownlint-cli -d

Configuration

JSON

Update your .markdownlint.json file.

json
{
  "$schema": "https://raw.githubusercontent.com/DavidAnson/markdownlint/main/schema/markdownlint-config-schema.json",
  "extends": "@modyqyw/fabric/markdownlint.json"
}

CLI

Update your package.json and add lint:markdownlint script.

json
{
  "scripts": {
    "lint:markdownlint": "markdownlint . --fix --ignore-path=.gitignore"
  }
}

Integration

VSC

Install the corresponding markdownlint plugin first.

Update user settings or workspace settings as appropriate.

json
{
  // markdownlint auto-fix after markdown manual save.
  "[markdown]": {
    "editor.codeActionsOnSave": {
      "source.fixAll.markdownlint": "explicit"
    }
  }
}

WebStorm

WebStorm can use plugin to get markdownlint support.

lint-staged

If you are using the lint-staged configuration provided by the package, see the lint-staged chapter.

If you are not, you can refer to the following configuration.

javascript
// lint-staged.config.mjs
// or lint-staged.config.js with "type": "module" in package.json
export default {
  '*.md': 'markdownlint --fix --ignore-path=.gitignore',
};

Released under the MIT License.