Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
markdownlint-cli2
Advanced tools
A fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files with the `markdownlint` library
markdownlint-cli2 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 Markdown Files
This command lints all Markdown files in the current directory and its subdirectories. It checks for common issues and style inconsistencies in Markdown files.
npx markdownlint-cli2 '**/*.md'
Using a Configuration File
This command uses a configuration file (.markdownlint.json) to specify custom linting rules. This allows for more granular control over the linting process.
npx markdownlint-cli2 '**/*.md' --config .markdownlint.json
Fixing Issues Automatically
This command not only lints the Markdown files but also attempts to fix any issues it finds automatically. This can save time by correcting common mistakes without manual intervention.
npx markdownlint-cli2-fix '**/*.md'
Ignoring Files
This command lints all Markdown files but ignores those in the node_modules directory. This is useful for excluding third-party files from the linting process.
npx markdownlint-cli2 '**/*.md' --ignore node_modules
remark-cli is a command-line interface for the remark library, which is used to process Markdown files. It offers similar functionality to markdownlint-cli2, including linting and formatting, but is part of the larger unified ecosystem, which provides a wide range of plugins for additional processing tasks.
markdownlint is the core library that markdownlint-cli2 is based on. It provides the underlying linting functionality and can be used programmatically within Node.js applications. While it does not offer a command-line interface out of the box, it can be integrated into custom scripts and build processes.
mdlint is another Markdown linter that focuses on simplicity and ease of use. It provides a basic set of linting rules and can be used as a command-line tool. While it may not be as feature-rich as markdownlint-cli2, it is a good option for users who need a straightforward linting solution.
A fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files with the
markdownlint
library
As a global CLI:
npm install markdownlint-cli2 --global
As a development dependency of the current package:
npm install markdownlint-cli2 --save-dev
Or use the container image available on Docker Hub as davidanson/markdownlint-cli2.
markdownlint
is a library for linting Markdown/
CommonMark files on Node.js using the
markdown-it parser.markdownlint-cli
is a traditional command-line interface
for markdownlint
.markdownlint-cli2
is a slightly unconventional
command-line interface for markdownlint
.markdownlint-cli2
is configuration-based and prioritizes speed and
simplicity.markdownlint-cli2
supports all the features of markdownlint-cli
(sometimes
a little differently).vscode-markdownlint
is a markdownlint
extension for
the Visual Studio Code editor.markdownlint-cli2
is designed to work well in conjunction with
vscode-markdownlint
.markdownlint-cli2
.markdownlint-cli2 vX.Y.Z (markdownlint vX.Y.Z)
https://github.com/DavidAnson/markdownlint-cli2
Syntax: markdownlint-cli2 glob0 [glob1] [...] [globN]
Glob expressions (from the globby library):
- * matches any number of characters, but not /
- ? matches a single character, but not /
- ** matches any number of characters, including / (when it's the only thing in a path part)
- {} allows for a comma-separated list of "or" expressions
- ! or # at the beginning of a pattern negate the match
Dot-only glob:
- The command "markdownlint-cli2 ." would lint every file in the current directory tree which is probably not intended
- Instead, it is mapped to "markdownlint-cli2 *.{md,markdown}" which lints all Markdown files in the current directory
- To lint every file in the current directory tree, the command "markdownlint-cli2 **" can be used instead
Configuration via:
- .markdownlint-cli2.jsonc
- .markdownlint-cli2.yaml
- .markdownlint-cli2.js
- .markdownlint.jsonc or .markdownlint.json
- .markdownlint.yaml or .markdownlint.yml
- .markdownlint.js
Cross-platform compatibility:
- UNIX and Windows shells expand globs according to different rules; quoting arguments is recommended
- Some Windows shells don't handle single-quoted (') arguments well; double-quote (") is recommended
- Shells that expand globs do not support negated patterns (!node_modules); quoting is required here
- Some UNIX shells parse exclamation (!) in double-quotes; hashtag (#) is recommended in these cases
- The path separator is forward slash (/) on all platforms; backslash (\) is automatically converted
Therefore, the most compatible glob syntax for cross-platform support:
$ markdownlint-cli2 "**/*.md" "#node_modules"
For scenarios where it is preferable to specify glob expressions in a
configuration file, the globs
property of .markdownlint-cli2.jsonc
or
.markdownlint-cli2.yaml
or .markdownlint-cli2.js
may be used instead of (or
in addition to) passing glob0 ... globN
on the command-line.
As shown above, the default command-line for markdownlint-cli2
looks something
like:
markdownlint-cli2 "**/*.md" "#node_modules"
However, because sharing configuration between "normal" and "fix" modes is so
common, the following command defaults the fix
property (see below) to true
:
markdownlint-cli2-fix "**/*.md" "#node_modules"
Other than the default behavior of the fix
property (which can be overridden
in both cases), these two commands behave identically.
A container image davidanson/markdownlint-cli2
can also be used (e.g., as part of a CI pipeline):
docker run -v $PWD:/workdir davidanson/markdownlint-cli2:0.3.1 "**/*.md" "#node_modules"
Notes:
node
runs with restricted permissions. If it is necessary to run as root
, pass
the -u root
option when invoking docker
.markdownlint-cli2
will execute within the /workdir
directory
inside the container. So, as shown above, bind mount
the project's directory there.
A custom working directory can be specified with Docker's -w
flag:
docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:0.3.1 "**/*.md" "#node_modules"
To invoke the markdownlint-cli2-fix
command instead, specify it via Docker's
--entrypoint
flag:
docker run -v $PWD:/workdir --entrypoint="markdownlint-cli2-fix" davidanson/markdownlint-cli2:0.3.1 "**/*.md" "#node_modules"
0
: Linting was successful and there were no errors1
: Linting was successful and there were errors2
: Linting was not completed due to a runtime issuemarkdownlint
documentation.markdownlint
documentation for information about the inline comment syntax
for enabling and disabling rules with HTML comments..markdownlint-cli2.jsonc
markdownlint
options
object.config
: markdownlint
config
object to configure
rules for this part of the directory tree
.markdownlint.{jsonc,json,yaml,yml,js}
file (see below) is present
in the same directory, it overrides the value of this propertycustomRules
: Array
of String
s (or Array
s of String
s) of module
names/paths of custom rules to load and use
when linting
String
is passed as the id
parameter to Node's
require functionJSONC
filemarkdownlint-rule
on npmfix
: Boolean
value to enable fixing of linting errors reported by rules
that emit fix information
frontMatter
: String
defining the RegExp
used to match and
ignore any front matter at the beginning of a document
String
is passed as the pattern
parameter to the
RegExp
constructor(^---\s*$[^]*?^---\s*$)(\r\n|\r|\n|$)
globs
: Array
of String
s defining glob expressions to append to the
command-line arguments
markdownlint-cli2
is runignores
: Array
of String
s defining glob expressions to ignore when
linting
markdownlint-cli2
is run
!
) and
appended to the command-line arguments before file enumerationmarkdownItPlugins
: Array
of Array
s, each of which has a String
naming a markdown-it plugin followed by
parameters
JSONC
file[ [ "plugin-name", param_0, param_1, ... ], ... ]
markdown-it-plugins
on npmnoInlineConfig
: Boolean
value to disable the support of
HTML comments within Markdown content
<!-- markdownlint-disable some-rule -->
noProgress
: Boolean
value to disable the display of progress on stdout
markdownlint-cli2
is runoutputFormatters
: Array
of Array
s, each of which has a String
naming an output formatter followed by parameters
JSONC
file[ [ "formatter-name", param_0, param_1, ... ], ... ]
markdownlint-cli2
is runmarkdownlint-cli2-formatter
on npm.markdownlint-cli2.jsonc
with all
properties set.markdownlint-cli2.yaml
.markdownlint-cli2.jsonc
..markdownlint-cli2.jsonc
described above..markdownlint-cli2.jsonc
file is present in the same directory, it
takes precedence..markdownlint-cli2.yaml
with all
properties set.markdownlint-cli2.js
.markdownlint-cli2.jsonc
.String
to identify the module name/path to load for
customRules
, markdownItPlugins
, and outputFormatters
, the corresponding
Object
or Function
can be provided directly..markdownlint-cli2.jsonc
described above..markdownlint-cli2.jsonc
or .markdownlint-cli2.yaml
file is present
in the same directory, it takes precedence..markdownlint-cli2.js
.markdownlint.jsonc
or .markdownlint.json
markdownlint
config
object.jsonc
and json
files are present in the same directory, the jsonc
version takes precedence.extends
property (documented in the link above)..markdownlint.jsonc
.markdownlint.yaml
or .markdownlint.yml
markdownlint
config
object.jsonc
/json
files described above.yaml
and yml
files are present in the same directory, the yaml
version takes precedence.jsonc
or json
file is present in the same directory, it takes
precedence..markdownlint.yaml
.markdownlint.js
markdownlint
config
object.jsonc
/json
files described above.jsonc
, json
, yaml
, or yml
file is present in the same directory,
it takes precedence..markdownlint.js
markdownlint-cli
INI
config format, .markdownlintrc
, and .markdownlintignore
are not
supported.vscode-markdownlint
.markdownlintignore
is not supported.To run markdownlint-cli2
as part of a pre-commit workflow, add a
reference to the repos
list in that project's .pre-commit-config.yaml
like:
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.3.1
hooks:
- id: markdownlint-cli2
Depending on the environment that workflow runs in, it may be necessary to override the version of Node.js used by pre-commit.
markdownlint-cli
markdown-it
plugins.markdownlint-cli2.js
and .markdownlint.js
.markdownlint-cli2.yaml
, add progressfix
, update bannermarkdownlint
)markdownlint-cli2-fix
commandmarkdownlint
)require
, increment minor version
require
require
to be more flexible0.3.1
FAQs
A fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files with the `markdownlint` library
The npm package markdownlint-cli2 receives a total of 115,666 weekly downloads. As such, markdownlint-cli2 popularity was classified as popular.
We found that markdownlint-cli2 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.