Install dependencies
# Yarn
yarn add -D markdownlint markdownlint-cli2
# NPM
npm install -D markdownlint markdownlint-cli2
Add script to your package.json
"lint:md": "markdownlint-cli2 README.md"
Feel free to replace README.md with any files/globs that you want to lint
Using it with Prettier
Install dependencies
# Yarn
yarn add -D prettier
# NPM
npm install -D prettier
Update your script
"lint:md": "prettier --check README.md && markdownlint-cli2 README.md"
If you have long lines then you might find that Prettier doesn’t error, but markdownlint does. You can either disable line-height
rule in markdown lint or enable prose-wrap
in your Prettier configuration. You can do this by adding the following part to your package.json
"prettier": {
"proseWrap": "always"
},