Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
markdownlint-cli
Advanced tools
The markdownlint-cli package is a command-line interface for the markdownlint library, which is used to lint Markdown files. It helps ensure that Markdown files adhere to a consistent style and are free of common errors.
Linting a single file
This command lints a single Markdown file (README.md) and outputs any issues found according to the default rules.
markdownlint README.md
Linting multiple files
This command lints all Markdown files in the 'docs' directory and its subdirectories, using a glob pattern to match the files.
markdownlint "docs/**/*.md"
Using a custom configuration file
This command lints the README.md file using a custom configuration file (.markdownlint.json) to specify the rules and options.
markdownlint -c .markdownlint.json README.md
Fixing linting issues automatically
This command attempts to automatically fix any linting issues found in the README.md file.
markdownlint --fix README.md
Ignoring specific files or directories
This command lints all Markdown files in the current directory, but ignores the 'node_modules' directory.
markdownlint . --ignore node_modules
remark-cli is a command-line interface for the remark library, which is a Markdown processor powered by plugins. It can be used to lint, format, and transform Markdown files. Compared to markdownlint-cli, remark-cli offers more flexibility through its plugin system, allowing for a wider range of transformations and customizations.
markdown-it is a Markdown parser that can be extended with plugins to add custom rules and transformations. While it is primarily used for parsing and rendering Markdown, it can also be used for linting with the appropriate plugins. markdown-it is more focused on parsing and rendering, whereas markdownlint-cli is specifically designed for linting.
markdown-lint is another linter for Markdown files, similar to markdownlint-cli. It provides a set of rules to enforce consistent style and catch common errors. However, markdown-lint is less feature-rich and less actively maintained compared to markdownlint-cli.
Command Line Interface for MarkdownLint
npm install -g markdownlint-cli
On macOS you can install via Homebrew:
brew install markdownlint-cli
markdownlint --help
Usage: markdownlint [options] <files|directories|globs>
MarkdownLint Command Line Interface
Options:
-V, --version output the version number
-c, --config <configFile> configuration file (JSON, JSONC, JS, YAML, or TOML)
--configPointer <pointer> JSON Pointer to object within configuration file (default: "")
-d, --dot include files/folders with a dot (for example `.github`)
-f, --fix fix basic errors (does not work with STDIN)
-i, --ignore <file|directory|glob> file(s) to ignore/exclude (default: [])
-j, --json write issues in json format
-o, --output <outputFile> write issues to file (no console)
-p, --ignore-path <file> path to file with ignore pattern(s)
-q, --quiet do not write issues to STDOUT
-r, --rules <file|directory|glob|package> include custom rule files (default: [])
-s, --stdin read from STDIN (does not work with files)
--enable <rules...> Enable certain rules, e.g. --enable MD013 MD041 --
--disable <rules...> Disable certain rules, e.g. --disable MD013 MD041 --
-h, --help display help for command
Or run using Docker and GitHub Packages:
docker run -v $PWD:/workdir ghcr.io/igorshubovych/markdownlint-cli:latest "*.md"
Note Because
--enable
and--disable
are variadic arguments that accept multiple values, it is necessary to end the list by passing--
before the<files|directories|globs>
argument like so:markdownlint --disable MD013 -- README.md
.
markdownlint-cli
supports advanced globbing patterns like **/*.md
(more information).
With shells like Bash, it may be necessary to quote globs so they are not interpreted by the shell.
For example, --ignore *.md
would be expanded by Bash to --ignore a.md b.md ...
before invoking markdownlint-cli
, causing it to ignore only the first file because --ignore
takes a single parameter (though it can be used multiple times).
Quoting the glob like --ignore '*.md'
passes it through unexpanded and ignores the set of files.
To lint all Markdown files in a Node.js project (excluding dependencies), the following commands might be used:
Windows CMD: markdownlint **/*.md --ignore node_modules
Linux Bash: markdownlint '**/*.md' --ignore node_modules
If present in the current folder, a .markdownlintignore
file will be used to ignore files and/or directories according to the rules for gitignore.
If the -p
/--ignore-path
option is present, the specified file will be used instead of .markdownlintignore
.
The order of operations is:
-p
/--ignore-path
(if specified) or .markdownlintignore
(if present)-i
/--ignore
option(s) that are specifiedWhen the --fix
option is specified, markdownlint-cli
tries to apply all fixes reported by the active rules and reports any errors that remain.
Because this option makes changes to the input files, it is good to make a backup first or work with files under source control so any unwanted changes can be undone.
Because not all rules include fix information when reporting errors, fixes may overlap, and not all errors are fixable,
--fix
will not usually address all errors.
markdownlint-cli
reuses the rules from markdownlint
package.
Configuration is stored in JSON, JSONC, YAML, INI, or TOML files in the same config format.
A sample configuration file:
{
"default": true,
"MD003": { "style": "atx_closed" },
"MD007": { "indent": 4 },
"no-hard-tabs": false,
"whitespace": false
}
For more examples, see .markdownlint.jsonc, .markdownlint.yaml, test-config.toml or the style folder.
The CLI argument --config
is not required.
If it is not provided, markdownlint-cli
looks for the file .markdownlint.jsonc
/.markdownlint.json
/.markdownlint.yaml
/.markdownlint.yml
in current folder, or for the file .markdownlintrc
in the current or all parent folders.
The algorithm is described in detail on the rc
package page.
Note that when relying on the lookup of a file named .markdownlintrc
in the current or parent folders, the only syntaxes accepted are INI and JSON, and the file cannot have an extension.
If the --config
argument is provided, the file must be valid JSON, JSONC, JS, or YAML.
JS configuration files contain JavaScript code, must have the .js
or .cjs
file extension, and must export (via module.exports = ...
) a configuration object of the form shown above.
If your workspace (project) is ESM-only ("type": "module"
set in the root package.json
file), then the configuration file should end with .cjs
file extension.
A JS configuration file may internally require
one or more npm packages as a way of reusing configuration across projects.
The --configPointer
argument allows the use of JSON Pointer syntax to identify a sub-object within the configuration object (per above).
This argument can be used with any configuration file type and makes it possible to nest a configuration object within another file like package.json
or pyproject.toml
(e.g., via /key
or /key/subkey
).
--enable
and --disable
override configuration files; if a configuration file disables MD123
and you pass --enable MD123
, it will be enabled.
If a rule is passed to both --enable
and --disable
, it will be disabled.
- JS configuration files must be provided via the
--config
argument; they are not automatically loaded because running untrusted code is a security concern.- TOML configuration files must be provided via the
--config
argument; they are not automatically loaded.
markdownlint-cli
returns one of the following exit codes:
0
: Program ran successfully1
: Linting errors2
: Unable to write -o
/--output
output file3
: Unable to load -r
/--rules
custom rule4
: Unexpected error (e.g. malformed config)To run markdownlint-cli
as part of a pre-commit workflow, add something like the below to the repos
list in the project's .pre-commit-config.yaml
:
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.43.0
hooks:
- id: markdownlint
Depending on the environment this workflow runs in, it may be necessary to override the language version of Node.js used by pre-commit.
.markdownlintignore
implementationMIT © Igor Shubovych
FAQs
MarkdownLint Command Line Interface
The npm package markdownlint-cli receives a total of 282,586 weekly downloads. As such, markdownlint-cli popularity was classified as popular.
We found that markdownlint-cli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.