feat: use go tool
This commit is contained in:
+258
@@ -0,0 +1,258 @@
|
||||
# Changelog
|
||||
|
||||
## 0.22.1
|
||||
|
||||
- Update dependencies
|
||||
|
||||
## 0.22.0
|
||||
|
||||
- Make `--config` parameter more flexible
|
||||
- Support TOML with `--config` parameter
|
||||
- Add `--configPointer` parameter
|
||||
- Update dependencies
|
||||
|
||||
## 0.21.0
|
||||
|
||||
- Refactor options/configuration file loading
|
||||
- Update dependencies
|
||||
|
||||
## 0.20.0
|
||||
|
||||
- Update dependencies (including `markdownlint`)
|
||||
|
||||
## 0.19.1
|
||||
|
||||
- Update `--format` to avoid trailing newline
|
||||
- Update dependencies
|
||||
|
||||
## 0.19.0
|
||||
|
||||
- Add `--format` parameter for editor integration
|
||||
- Update output formatters for severity `warning`
|
||||
- Explicitly version Docker containers for `pre-commit`
|
||||
- Update dependencies (including `markdownlint`)
|
||||
|
||||
## 0.18.1
|
||||
|
||||
- Update dependencies (including `markdownlint`)
|
||||
|
||||
## 0.18.0
|
||||
|
||||
- Use user ID in Docker containers for security
|
||||
- Update dependencies (including `markdownlint`)
|
||||
- Remove support for end-of-life Node 18
|
||||
|
||||
## 0.17.2
|
||||
|
||||
- Update dependencies (including `markdownlint`)
|
||||
|
||||
## 0.17.1
|
||||
|
||||
- Update dependencies (including `markdownlint`)
|
||||
|
||||
## 0.17.0
|
||||
|
||||
- Convert to ECMAScript modules
|
||||
- Use import() when loading modules
|
||||
- Update dependencies (including `markdownlint`)
|
||||
|
||||
## 0.16.0
|
||||
|
||||
- Try not to use require for modules (due to Node 22.12)
|
||||
- Update dependencies (EXcluding `markdownlint`)
|
||||
|
||||
## 0.15.0
|
||||
|
||||
- Add support for `stdin` input via `-` glob
|
||||
- Add output formatter based on string templates
|
||||
- Update dependencies (including `markdownlint`)
|
||||
|
||||
## 0.14.0
|
||||
|
||||
- Handle `--` parameter per POSIX convention
|
||||
- Add support for glob to `gitignore` configuration
|
||||
- Update dependencies (including `markdownlint`)
|
||||
|
||||
## 0.13.0
|
||||
|
||||
- Add `noBanner` and `gitignore` configuration options
|
||||
- Reduce install size by switching to `js-yaml` package
|
||||
- Add more detail to some error messages
|
||||
- Export JSONC/YAML parsers for reuse
|
||||
- Update dependencies (including `markdownlint`)
|
||||
|
||||
## 0.12.1
|
||||
|
||||
- Update JSONC parsing to handle trailing commas
|
||||
- Add documentation links to JSON schema
|
||||
- Update dependencies
|
||||
|
||||
## 0.12.0
|
||||
|
||||
- Remove deprecated `markdownlint-cli2-config` entry point
|
||||
- Use `markdownlint-cli2 --config ...` instead
|
||||
- Remove deprecated `markdownlint-cli2-fix` entry point
|
||||
- Use `markdownlint-cli2 --fix ...` instead
|
||||
- Add `--help` and `--no-globs` parameters
|
||||
- Improve and document included JSON schemas
|
||||
- Update dependencies (including `markdownlint`)
|
||||
|
||||
## 0.11.0
|
||||
|
||||
- Add `modulePaths` configuration option
|
||||
- Update dependencies (including `markdownlint`)
|
||||
- Remove support for end-of-life Node 16
|
||||
|
||||
## 0.10.0
|
||||
|
||||
- Add `showFound` configuration option
|
||||
- Add `.markdownlint-cli2.jsonc` config schema
|
||||
- Update dependencies (including `markdownlint`)
|
||||
|
||||
## 0.9.2
|
||||
|
||||
- Remove `npm-shrinkwrap.json` entirely to avoid `npm` failures
|
||||
|
||||
## 0.9.1
|
||||
|
||||
- Remove `devDependencies` from `npm-shrinkwrap.json` to avoid `npm` failures
|
||||
|
||||
## 0.9.0
|
||||
|
||||
- Add support for Node.js's `package.json` as a configuration file source
|
||||
- Add output formatter for Static Analysis Results Interchange Format/SARIF
|
||||
- Bundle `npm-shrinkwrap.json` for reproducible/faster installs
|
||||
- Update dependencies (including `markdownlint`)
|
||||
|
||||
## 0.8.1
|
||||
|
||||
- Handle `--config` edge case
|
||||
|
||||
## 0.8.0
|
||||
|
||||
- Add support for `--config` and `--fix` parameters
|
||||
- Update dependencies (including `markdownlint`)
|
||||
- Remove support for end-of-life Node 14
|
||||
|
||||
## 0.7.1
|
||||
|
||||
- Update dependencies (including `markdownlint`)
|
||||
|
||||
## 0.7.0
|
||||
|
||||
- Add support for `extends` in `config` property of `.markdownlint-cli2.*` files
|
||||
- Build and publish `davidanson/markdownlint-cli2-rules` Docker container image
|
||||
- Update dependencies (including `markdownlint`)
|
||||
|
||||
## 0.6.0
|
||||
|
||||
- Update dependencies (including `markdownlint`)
|
||||
|
||||
## 0.5.1
|
||||
|
||||
- Update dependencies
|
||||
|
||||
## 0.5.0
|
||||
|
||||
- New rules
|
||||
- Support modules (MJS) everywhere
|
||||
- Include dotfiles
|
||||
|
||||
## 0.4.0
|
||||
|
||||
- New rules
|
||||
- Async custom rules
|
||||
- Explicit config
|
||||
- CJS (breaking)
|
||||
|
||||
## 0.3.2
|
||||
|
||||
- Extensibility/Windows/consistency improvements
|
||||
|
||||
## 0.3.1
|
||||
|
||||
- Extensibility tweaks
|
||||
|
||||
## 0.3.0
|
||||
|
||||
- Add Docker container
|
||||
- Update dependencies
|
||||
|
||||
## 0.2.0
|
||||
|
||||
- Improve handling of Windows paths using backslash
|
||||
|
||||
## 0.1.3
|
||||
|
||||
- Support rule collections
|
||||
|
||||
## 0.1.2
|
||||
|
||||
- Update use of `require` to be more flexible
|
||||
|
||||
## 0.1.1
|
||||
|
||||
- Restore previous use of `require`
|
||||
|
||||
## 0.1.0
|
||||
|
||||
- Simplify use of `require`
|
||||
- Increment minor version
|
||||
|
||||
## 0.0.15
|
||||
|
||||
- Improve extensibility
|
||||
|
||||
## 0.0.14
|
||||
|
||||
- Update dependencies (including `markdownlint`)
|
||||
|
||||
## 0.0.13
|
||||
|
||||
- Add `markdownlint-cli2-fix` command
|
||||
|
||||
## 0.0.12
|
||||
|
||||
- Update dependencies (including `markdownlint`)
|
||||
|
||||
## 0.0.11
|
||||
|
||||
- Improve performance of `fix`
|
||||
- Update banner
|
||||
|
||||
## 0.0.10
|
||||
|
||||
- Improve performance and configuration
|
||||
|
||||
## 0.0.9
|
||||
|
||||
- Improve configuration file handling
|
||||
|
||||
## 0.0.8
|
||||
|
||||
- Support `.markdownlint-cli2.yaml`
|
||||
- Add progress
|
||||
|
||||
## 0.0.7
|
||||
|
||||
- Support `.markdownlint-cli2.js` and `.markdownlint.js`
|
||||
|
||||
## 0.0.6
|
||||
|
||||
- Improve handling of very large directory trees
|
||||
|
||||
## 0.0.5
|
||||
|
||||
- Improve support for ignoring files
|
||||
|
||||
## 0.0.4
|
||||
|
||||
- Support output formatters and `markdown-it` plugins
|
||||
|
||||
## 0.0.3
|
||||
|
||||
- Feature parity with `markdownlint-cli`
|
||||
|
||||
## 0.0.2
|
||||
|
||||
- Initial release
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) David Anson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+578
@@ -0,0 +1,578 @@
|
||||
# markdownlint-cli2
|
||||
|
||||
> A fast, flexible, configuration-based command-line interface for linting
|
||||
> Markdown/CommonMark files with the `markdownlint` library
|
||||
|
||||
[![npm version][npm-image]][npm-url]
|
||||
[![License][license-image]][license-url]
|
||||
|
||||
## Install
|
||||
|
||||
As a global CLI:
|
||||
|
||||
```bash
|
||||
npm install markdownlint-cli2 --global
|
||||
```
|
||||
|
||||
As a development dependency of the current [Node.js][nodejs] package:
|
||||
|
||||
```bash
|
||||
npm install markdownlint-cli2 --save-dev
|
||||
```
|
||||
|
||||
As a [Docker][docker] container image:
|
||||
|
||||
```bash
|
||||
docker pull davidanson/markdownlint-cli2
|
||||
```
|
||||
|
||||
As a global CLI with [Homebrew][homebrew]:
|
||||
|
||||
```bash
|
||||
brew install markdownlint-cli2
|
||||
```
|
||||
|
||||
As a [GitHub Action][github-action] via
|
||||
[`markdownlint-cli2-action`][markdownlint-cli2-action]:
|
||||
|
||||
```yaml
|
||||
- name: markdownlint-cli2-action
|
||||
uses: DavidAnson/markdownlint-cli2-action@main
|
||||
```
|
||||
|
||||
## Overview
|
||||
|
||||
- [`markdownlint`][markdownlint] is a library for linting [Markdown][markdown]/
|
||||
[CommonMark][commonmark] files on [Node.js][nodejs] using the
|
||||
[markdown-it][markdown-it] parser.
|
||||
- [`markdownlint-cli`][markdownlint-cli] is a traditional command-line interface
|
||||
for `markdownlint`.
|
||||
- [`markdownlint-cli2`][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`][vscode-markdownlint] is a `markdownlint` extension for
|
||||
the [Visual Studio Code editor][vscode].
|
||||
- `markdownlint-cli2` is designed to work well in conjunction with
|
||||
`vscode-markdownlint`.
|
||||
- More about the [motivation for `markdownlint-cli2`][markdownlint-cli2-blog].
|
||||
|
||||
## Use
|
||||
|
||||
### Command Line
|
||||
|
||||
```text
|
||||
markdownlint-cli2 vX.Y.Z (markdownlint vX.Y.Z)
|
||||
https://github.com/DavidAnson/markdownlint-cli2
|
||||
|
||||
Syntax: markdownlint-cli2 glob0 [glob1] [...] [globN] [--config file] [--configPointer pointer] [--fix] [--format] [--help] [--no-globs]
|
||||
|
||||
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 /
|
||||
- {} allows for a comma-separated list of "or" expressions
|
||||
- ! or # at the beginning of a pattern negate the match
|
||||
- : at the beginning identifies a literal file path
|
||||
- - as a glob represents standard input (stdin)
|
||||
|
||||
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
|
||||
|
||||
Optional parameters:
|
||||
- --config specifies the path to a configuration file to define the base configuration
|
||||
- --configPointer specifies a JSON Pointer to a configuration object within the --config file
|
||||
- --fix updates files to resolve fixable issues (can be overridden in configuration)
|
||||
- --format reads standard input (stdin), applies fixes, writes standard output (stdout)
|
||||
- --help writes this message to the console and exits without doing anything else
|
||||
- --no-globs ignores the "globs" property if present in the top-level options object
|
||||
|
||||
Configuration via:
|
||||
- .markdownlint-cli2.jsonc
|
||||
- .markdownlint-cli2.yaml
|
||||
- .markdownlint-cli2.cjs or .markdownlint-cli2.mjs
|
||||
- .markdownlint.jsonc or .markdownlint.json
|
||||
- .markdownlint.yaml or .markdownlint.yml
|
||||
- .markdownlint.cjs or .markdownlint.mjs
|
||||
|
||||
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
|
||||
- On any platform, passing the parameter "--" causes all remaining parameters to be treated literally
|
||||
|
||||
The most compatible 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`, `.yaml`,
|
||||
`.cjs`, or `.mjs` may be used instead of (or in addition to) passing
|
||||
`glob0 ... globN` on the command-line.
|
||||
|
||||
As shown above, a typical command-line for `markdownlint-cli2` looks something
|
||||
like:
|
||||
|
||||
```bash
|
||||
markdownlint-cli2 "**/*.md" "#node_modules"
|
||||
```
|
||||
|
||||
Because sharing the same configuration between "normal" and "fix" modes is
|
||||
common, the `--fix` argument can be used to default the `fix` property (see
|
||||
below) to `true` (though it can still be overridden by a configuration file):
|
||||
|
||||
```bash
|
||||
markdownlint-cli2 --fix "**/*.md" "#node_modules"
|
||||
```
|
||||
|
||||
In cases where it is not convenient to store a configuration file in the root
|
||||
of a project, the `--config` argument can be used to provide a path to any
|
||||
supported configuration file/format:
|
||||
|
||||
```bash
|
||||
markdownlint-cli2 --config "config/.markdownlint-cli2.jsonc" "**/*.md" "#node_modules"
|
||||
```
|
||||
|
||||
The configuration file name should be (or end with) one of the supported names
|
||||
above. For example, `.markdownlint.json` or `example.markdownlint-cli2.jsonc`.
|
||||
Alternatively, the configuration file name should have a supported extension
|
||||
like `.jsonc`, `.yaml`, `.mjs`, or `.toml` and its kind (see below) will be
|
||||
inferred. The configuration file will be loaded, parsed, and applied as a base
|
||||
configuration for the current directory - which will then be handled normally.
|
||||
|
||||
The `--configPointer` argument allows the use of [JSON Pointer][json-pointer]
|
||||
syntax to identify a sub-object within the configuration file specified by
|
||||
`--config` (see above). This argument can be used with any configuration file
|
||||
type and makes it possible to nest configuration data within another file like
|
||||
`package.json` or `pyproject.toml` (e.g., via `/key` or `/key/subkey`).
|
||||
|
||||
For example, a `package.json` file like this:
|
||||
|
||||
```json
|
||||
{
|
||||
"...": "...",
|
||||
"markdownlint-cli2": {
|
||||
"config": {
|
||||
"no-multiple-blanks": false
|
||||
},
|
||||
"noProgress": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Could be used like this:
|
||||
|
||||
```bash
|
||||
markdownlint-cli2 --config package.json --configPointer /markdownlint-cli2 "*.md"
|
||||
```
|
||||
|
||||
And a `pyproject.toml` file like this:
|
||||
|
||||
```toml
|
||||
[project]
|
||||
# ...
|
||||
|
||||
[tool.markdownlint-cli2]
|
||||
noProgress = true
|
||||
|
||||
[tool.markdownlint-cli2.config]
|
||||
no-multiple-blanks = false
|
||||
```
|
||||
|
||||
Could be used like this:
|
||||
|
||||
```bash
|
||||
markdownlint-cli2 --config pyproject.toml --configPointer /tool/markdownlint-cli2 "*.md"
|
||||
```
|
||||
|
||||
**Note**: The [TOML][toml] format is supported by `--config`, `--configPointer`,
|
||||
and the `extends` configuration property, but *not* for per-directory overrides.
|
||||
|
||||
### Container Image
|
||||
|
||||
A container image [`davidanson/markdownlint-cli2`][docker-hub-markdownlint-cli2]
|
||||
can also be used (e.g., as part of a CI pipeline):
|
||||
|
||||
```bash
|
||||
docker run -v $PWD:/workdir davidanson/markdownlint-cli2:v0.22.1 "**/*.md" "#node_modules"
|
||||
```
|
||||
|
||||
Notes:
|
||||
|
||||
- As when using the [command line][command-line], glob patterns are passed as
|
||||
arguments.
|
||||
- This image is built on the official [Node.js Docker image][nodejs-docker].
|
||||
Per security best practices, the [default user `node`][nodejs-docker-non-root]
|
||||
runs with restricted permissions. If it is necessary to run as `root`, pass
|
||||
the `-u root` option when invoking `docker`.
|
||||
- By default, `markdownlint-cli2` will execute within the `/workdir` directory
|
||||
*inside the container*. So, as shown above, [bind mount][docker-bind-mounts]
|
||||
the project's directory there.
|
||||
- A custom working directory can be specified with Docker's `-w` flag:
|
||||
|
||||
```bash
|
||||
docker run -w /myfolder -v $PWD:/myfolder davidanson/markdownlint-cli2:v0.22.1 "**/*.md" "#node_modules"
|
||||
```
|
||||
|
||||
For convenience, the container image
|
||||
[`davidanson/markdownlint-cli2-rules`][docker-hub-markdownlint-cli2-rules]
|
||||
includes the latest versions of custom rules published to npm with the tag
|
||||
[`markdownlint-rule`][markdownlint-rule]. These rules are installed globally
|
||||
onto the base image `davidanson/markdownlint-cli2`.
|
||||
|
||||
**Note**: This container image exists for convenience and is not an endorsement
|
||||
of the rules within.
|
||||
|
||||
### Output Formatters
|
||||
|
||||
In addition to (or instead of) the default behavior of writing a list of all
|
||||
issues to the standard error (`stderr`) device, custom output formatters can be
|
||||
configured to produce a variety of outputs like:
|
||||
|
||||
- [List of issues (default)][formatter-default]
|
||||
- [List of issues with color and links][formatter-pretty]
|
||||
- [GitLab Code Quality report file][formatter-codequality]
|
||||
- [JSON file][formatter-json]
|
||||
- [JUnit XML file][formatter-junit]
|
||||
- [Static Analysis Results Interchange Format/SARIF file][formatter-sarif]
|
||||
- [Summary of issues found][formatter-summarize]
|
||||
- [Flexible string template][formatter-template] supporting:
|
||||
- Azure Pipelines Task command LogIssue format
|
||||
- GitHub Actions workflow commands format
|
||||
|
||||
[formatter-default]: ./formatter-default/README.md
|
||||
[formatter-codequality]: ./formatter-codequality/README.md
|
||||
[formatter-json]: ./formatter-json/README.md
|
||||
[formatter-junit]: ./formatter-junit/README.md
|
||||
[formatter-pretty]: ./formatter-pretty/README.md
|
||||
[formatter-sarif]: ./formatter-sarif/README.md
|
||||
[formatter-summarize]: ./formatter-summarize/README.md
|
||||
[formatter-template]: ./formatter-template/README.md
|
||||
|
||||
For more information, refer to the documentation for the `outputFormatters`
|
||||
parameter below.
|
||||
|
||||
### Exit Codes
|
||||
|
||||
- `0`: Linting was successful and there were no errors (there may be warnings)
|
||||
- `1`: Linting was successful and there were errors (and possibly warnings)
|
||||
- `2`: Linting was not successful due to a problem or failure
|
||||
|
||||
### Formatting
|
||||
|
||||
Some editors implement document formatting by invoking an external program,
|
||||
passing the text of the current document on standard input (`stdin`), and
|
||||
reading the formatted result from standard output (`stdout`). This scenario is
|
||||
supported by the `--format` command-line parameter. When `--format` is set:
|
||||
|
||||
- Globs and other input sources are ignored
|
||||
- The `--fix` parameter is implicitly set
|
||||
- The exit code `1` is not used
|
||||
|
||||
## Rule List
|
||||
|
||||
- See the [Rules / Aliases][markdownlint-rules-aliases] and
|
||||
[Tags][markdownlint-rules-tags] sections of the `markdownlint` documentation.
|
||||
|
||||
## Glob expressions
|
||||
|
||||
- Globbing is performed by the [globby][globby] library; refer to that
|
||||
documentation for more information and examples.
|
||||
|
||||
## Configuration
|
||||
|
||||
- See the [Configuration][markdownlint-configuration] section of the
|
||||
`markdownlint` documentation for information about the inline comment syntax
|
||||
for enabling and disabling rules with HTML comments.
|
||||
- In general, glob expressions should match files under the current directory;
|
||||
the configuration for that directory will apply to the entire tree.
|
||||
- When glob expressions match files *not* under the current directory,
|
||||
configuration for the current directory is applied to the closest common
|
||||
parent directory.
|
||||
- Paths beginning with `~` are resolved relative to the user's home directory
|
||||
(typically `$HOME` on UNIX and `%USERPROFILE%` on Windows)
|
||||
- There are two kinds of configuration file (both detailed below):
|
||||
- Configuration files like `.markdownlint-cli2.*` allow complete control of
|
||||
`markdownlint-cli2` behavior and are also used by `vscode-markdownlint`.
|
||||
- If multiple of these files are present in the same directory, only one is
|
||||
used according to the following precedence:
|
||||
1. `.markdownlint-cli2.jsonc`
|
||||
2. `.markdownlint-cli2.yaml`
|
||||
3. `.markdownlint-cli2.cjs`
|
||||
4. `.markdownlint-cli2.mjs`
|
||||
- Configuration files like `.markdownlint.*` allow control over only the
|
||||
`markdownlint` `config` object and tend to be supported more broadly (such
|
||||
as by `markdownlint-cli`).
|
||||
- If multiple of these files are present in the same directory, only one is
|
||||
used according to the following precedence:
|
||||
1. `.markdownlint.jsonc`
|
||||
2. `.markdownlint.json`
|
||||
3. `.markdownlint.yaml`
|
||||
4. `.markdownlint.yml`
|
||||
5. `.markdownlint.cjs`
|
||||
6. `.markdownlint.mjs`
|
||||
- Both configuration file types can appear in any directory and will override
|
||||
configuration defined in the project root or any directories in between.
|
||||
- The VS Code extension includes a [JSON Schema][json-schema] definition for the
|
||||
`JSON(C)` configuration files described below. This adds auto-complete and can
|
||||
make it easier to define proper structure.
|
||||
- See [markdownlint-cli2-config-schema.json][markdownlint-cli2-config-schema]
|
||||
for that schema and [ValidatingConfiguration.md][validating-configuration] for
|
||||
ways to use it to validate configuration files.
|
||||
|
||||
### `.markdownlint-cli2.jsonc`
|
||||
|
||||
- The format of this file is a [JSONC][jsonc] object similar to the
|
||||
[`markdownlint` `options` object][markdownlint-options].
|
||||
- Valid properties are:
|
||||
- `config`: [`markdownlint` `config` object][markdownlint-config] to configure
|
||||
rules for this part of the directory tree
|
||||
- If a `.markdownlint.{jsonc,json,yaml,yml,cjs,mjs}` file (see below) is
|
||||
present in the same directory, it overrides the value of this property
|
||||
- If the `config` object contains an `extends` property, it will be resolved
|
||||
the same as `.markdownlint.{jsonc,json,yaml,yml,cjs,mjs}` (see below)
|
||||
- `customRules`: `Array` of `String`s (or `Array`s of `String`s) of module
|
||||
names/paths of [custom rules][markdownlint-custom-rules] to load and use
|
||||
when linting
|
||||
- Relative paths are resolved based on the location of the `JSONC` file
|
||||
- Search [`markdownlint-rule` on npm][markdownlint-rule]
|
||||
- `fix`: `Boolean` value to enable fixing of linting errors reported by rules
|
||||
that emit fix information
|
||||
- Fixes are made directly to the relevant file(s); no backup is created
|
||||
- `frontMatter`: `String` defining the [`RegExp`][regexp] used to match and
|
||||
ignore any [front matter][front-matter] at the beginning of a document
|
||||
- The `String` is passed as the `pattern` parameter to the
|
||||
[`RegExp` constructor][regexp-constructor]
|
||||
- For example: `(^---\s*$[^]*?^---\s*$)(\r\n|\r|\n|$)`
|
||||
- `gitignore`: `Boolean` or `String` value to automatically ignore files
|
||||
referenced by `.gitignore` (or similar) when linting
|
||||
- When the value `true` is specified, all `.gitignore` files in the tree
|
||||
*and up to the repository root* are used (default `git` behavior)
|
||||
- When a `String` value is specified, that glob pattern is used to identify
|
||||
the set of ignore files to use
|
||||
- The value `**/.gitignore` corresponds to the `Boolean` value `true` *but
|
||||
does not use `.gitignore` files up to the repository root*
|
||||
- The value `.gitignore` uses only the file in the root of the tree;
|
||||
this is usually equivalent and can be much faster for large trees
|
||||
- This top-level setting is valid **only** in the directory from which
|
||||
`markdownlint-cli2` is run
|
||||
- `globs`: `Array` of `String`s defining glob expressions to append to the
|
||||
command-line arguments
|
||||
- This setting can be used instead of (or in addition to) passing globs on
|
||||
the command-line and offers identical performance
|
||||
- This setting is ignored when the `--no-globs` parameter is passed on the
|
||||
command-line
|
||||
- This top-level setting is valid **only** in the directory from which
|
||||
`markdownlint-cli2` is run
|
||||
- `ignores`: `Array` of `String`s defining glob expressions to ignore when
|
||||
linting
|
||||
- This setting has the best performance when applied to the directory from
|
||||
which `markdownlint-cli2` is run
|
||||
- In this case, glob expressions are negated (by adding a leading `!`) and
|
||||
appended to the command-line arguments before file enumeration
|
||||
- The setting is not inherited by nested configuration files in this case
|
||||
- When this setting is applied in subdirectories, ignoring of files is done
|
||||
after file enumeration, so large directories can negatively impact
|
||||
performance
|
||||
- Nested configuration files inherit and reapply the setting to the
|
||||
contents of nested directories in this case
|
||||
- `markdownItPlugins`: `Array` of `Array`s, each of which has a `String`
|
||||
naming a [markdown-it plugin][markdown-it-syntax-extensions] followed by
|
||||
parameters
|
||||
- Plugins can be used to add support for additional Markdown syntax
|
||||
- Relative paths are resolved based on the location of the `JSONC` file
|
||||
- For example: `[ [ "plugin-name", param_0, param_1, ... ], ... ]`
|
||||
- Search [`markdown-it-plugins` on npm][markdown-it-plugins]
|
||||
- `modulePaths`: `Array` of `String`s providing additional paths to use when
|
||||
resolving module references (e.g., alternate locations for `node_modules`)
|
||||
- `noBanner`: `Boolean` value to disable the display of the banner message and
|
||||
version numbers on `stdout`
|
||||
- This top-level setting is valid **only** in the directory from which
|
||||
`markdownlint-cli2` is run
|
||||
- Use with `noProgress` to suppress all output to `stdout` (i.e., `--quiet`)
|
||||
- `noInlineConfig`: `Boolean` value to disable the support of
|
||||
[HTML comments][html-comment] within Markdown content
|
||||
- For example: `<!-- markdownlint-disable some-rule -->`
|
||||
- `noProgress`: `Boolean` value to disable the display of progress on `stdout`
|
||||
- This top-level setting is valid **only** in the directory from which
|
||||
`markdownlint-cli2` is run
|
||||
- Use with `noBanner` to suppress all output to `stdout` (i.e., `--quiet`)
|
||||
- `outputFormatters`: `Array` of `Array`s, each of which has a `String`
|
||||
naming an [output formatter][output-formatters] followed by parameters
|
||||
- Formatters can be used to customize the tool's output for different
|
||||
scenarios
|
||||
- Relative paths are resolved based on the location of the `JSONC` file
|
||||
- For example: `[ [ "formatter-name", param_0, param_1, ... ], ... ]`
|
||||
- This top-level setting is valid **only** in the directory from which
|
||||
`markdownlint-cli2` is run
|
||||
- Search [`markdownlint-cli2-formatter` on npm][markdownlint-cli2-formatter]
|
||||
- `showFound`: `Boolean` value to display the list of found files on `stdout`
|
||||
- This top-level setting is valid **only** in the directory from which
|
||||
`markdownlint-cli2` is run and **only** when `noProgress` has not been set
|
||||
- When referencing a module via the `customRules`, `markdownItPlugins`, or
|
||||
`outputFormatters` properties, each `String` identifier is passed to Node's
|
||||
[`require` function][nodejs-require] then (if that failed) its
|
||||
[`import` expression][nodejs-import-expression]
|
||||
- Importing a locally-installed module using a bare specifier (ex:
|
||||
`package-name`) or using a directory name (ex: `./package-dir`) will not
|
||||
work until [`import.meta.resolve`][nodejs-import-meta-resolve] is available
|
||||
- Settings in this file apply to the directory it is in and all subdirectories.
|
||||
- Settings **merge with** those applied by any versions of this file in a parent
|
||||
directory (up to the current directory).
|
||||
- For example: [`.markdownlint-cli2.jsonc`][markdownlint-cli2-jsonc] with all
|
||||
properties set
|
||||
|
||||
### `.markdownlint-cli2.yaml`
|
||||
|
||||
- The format of this file is a [YAML][yaml] object with the structure described
|
||||
above for `.markdownlint-cli2.jsonc`.
|
||||
- Other details are the same as for `.markdownlint-cli2.jsonc` described above.
|
||||
- For example: [`.markdownlint-cli2.yaml`][markdownlint-cli2-yaml] with all
|
||||
properties set
|
||||
|
||||
### `.markdownlint-cli2.cjs` or `.markdownlint-cli2.mjs`
|
||||
|
||||
- The format of this file is a [CommonJS module][commonjs-module] (`.cjs`) or
|
||||
[ECMAScript module][ecmascript-module] (`.mjs`) that exports the object
|
||||
described above for `.markdownlint-cli2.jsonc` (directly or from a `Promise`).
|
||||
- Instead of passing a `String` to identify the module name/path to load for
|
||||
`customRules`, `markdownItPlugins`, and `outputFormatters`, the corresponding
|
||||
`Object` or `Function` can be provided directly.
|
||||
- Other details are the same as for `.markdownlint-cli2.jsonc` described above.
|
||||
- For example: [`.markdownlint-cli2.cjs`][markdownlint-cli2-cjs] or
|
||||
[`.markdownlint-cli2.mjs`][markdownlint-cli2-mjs]
|
||||
|
||||
### `.markdownlint.jsonc` or `.markdownlint.json`
|
||||
|
||||
- The format of this file is a [JSONC][jsonc] or [JSON][json] object matching
|
||||
the [`markdownlint` `config` object][markdownlint-config].
|
||||
- Settings in this file apply to the directory it is in and all subdirectories
|
||||
- Settings **override** those applied by any versions of this file in a parent
|
||||
directory (up to the current directory).
|
||||
- To merge the settings of these files or share configuration, use the `extends`
|
||||
property (documented in the link above).
|
||||
- Both file types support comments in JSON.
|
||||
- For example: [`.markdownlint.jsonc`][markdownlint-jsonc]
|
||||
|
||||
### `.markdownlint.yaml` or `.markdownlint.yml`
|
||||
|
||||
- The format of this file is a [YAML][yaml] object representing the
|
||||
[`markdownlint` `config` object][markdownlint-config].
|
||||
- Other details are the same as for `jsonc`/`json` files described above.
|
||||
- For example: [`.markdownlint.yaml`][markdownlint-yaml]
|
||||
|
||||
### `.markdownlint.cjs` or `.markdownlint.mjs`
|
||||
|
||||
- The format of this file is a [CommonJS module][commonjs-module] (`.cjs`) or
|
||||
[ECMAScript module][ecmascript-module] (`.mjs`) that exports the
|
||||
[`markdownlint` `config` object][markdownlint-config] (directly or from a
|
||||
`Promise`).
|
||||
- Other details are the same as for `jsonc`/`json` files described above.
|
||||
- For example: [`.markdownlint.cjs`][markdownlint-cjs] or
|
||||
[`.markdownlint.mjs`][markdownlint-mjs]
|
||||
|
||||
## Compatibility
|
||||
|
||||
### `markdownlint-cli`
|
||||
|
||||
- The glob implementation and handling of pattern matching is slightly
|
||||
different.
|
||||
- Configuration files are supported in every directory (vs. only one at the
|
||||
root).
|
||||
- The `INI` config format, `.markdownlintrc`, and `.markdownlintignore` are not
|
||||
supported.
|
||||
|
||||
## pre-commit
|
||||
|
||||
To run `markdownlint-cli2` as part of a [pre-commit][pre-commit] workflow, add a
|
||||
reference to the `repos` list in that project's `.pre-commit-config.yaml` like:
|
||||
|
||||
```yaml
|
||||
- repo: https://github.com/DavidAnson/markdownlint-cli2
|
||||
rev: v0.22.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][pre-commit-version].
|
||||
|
||||
Setting the `id` above to `markdownlint-cli2-docker` uses the Docker container
|
||||
image instead. That image bundles Node.js and all dependencies and provides the
|
||||
most consistent experience because it is not affected by new releases of any
|
||||
dependencies.
|
||||
|
||||
## History
|
||||
|
||||
See [CHANGELOG.md][changelog].
|
||||
|
||||
[changelog]: CHANGELOG.md
|
||||
[command-line]: #command-line
|
||||
[commonmark]: https://commonmark.org/
|
||||
[commonjs-module]: https://nodejs.org/api/modules.html#modules-commonjs-modules
|
||||
[ecmascript-module]: https://nodejs.org/api/esm.html#modules-ecmascript-modules
|
||||
[docker]: https://www.docker.com
|
||||
[docker-bind-mounts]: https://docs.docker.com/storage/bind-mounts/
|
||||
[docker-hub-markdownlint-cli2]: https://hub.docker.com/r/davidanson/markdownlint-cli2
|
||||
[docker-hub-markdownlint-cli2-rules]: https://hub.docker.com/r/davidanson/markdownlint-cli2-rules
|
||||
[front-matter]: https://jekyllrb.com/docs/frontmatter/
|
||||
[github-action]: https://docs.github.com/actions
|
||||
[globby]: https://www.npmjs.com/package/globby
|
||||
[homebrew]: https://brew.sh
|
||||
[html-comment]: https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Getting_started
|
||||
[json]: https://wikipedia.org/wiki/JSON
|
||||
[json-pointer]: https://datatracker.ietf.org/doc/html/rfc6901
|
||||
[json-schema]: https://json-schema.org
|
||||
[jsonc]: https://code.visualstudio.com/Docs/languages/json#_json-with-comments
|
||||
[license-image]: https://img.shields.io/npm/l/markdownlint-cli2.svg
|
||||
[license-url]: https://opensource.org/licenses/MIT
|
||||
[markdown]: https://wikipedia.org/wiki/Markdown
|
||||
[markdown-it]: https://www.npmjs.com/package/markdown-it
|
||||
[markdown-it-plugins]: https://www.npmjs.com/search?q=keywords:markdown-it-plugin
|
||||
[markdown-it-syntax-extensions]: https://github.com/markdown-it/markdown-it#syntax-extensions
|
||||
[markdownlint]: https://github.com/DavidAnson/markdownlint
|
||||
[markdownlint-config]: https://github.com/DavidAnson/markdownlint/blob/v0.40.0/README.md#optionsconfig
|
||||
[markdownlint-configuration]: https://github.com/DavidAnson/markdownlint/blob/v0.40.0/README.md#configuration
|
||||
[markdownlint-custom-rules]: https://github.com/DavidAnson/markdownlint/blob/v0.40.0/doc/CustomRules.md
|
||||
[markdownlint-options]: https://github.com/DavidAnson/markdownlint/blob/v0.40.0/README.md#options
|
||||
[markdownlint-rules-aliases]: https://github.com/DavidAnson/markdownlint/blob/v0.40.0/README.md#rules--aliases
|
||||
[markdownlint-rules-tags]: https://github.com/DavidAnson/markdownlint/blob/v0.40.0/README.md#tags
|
||||
[markdownlint-cli]: https://github.com/igorshubovych/markdownlint-cli
|
||||
[markdownlint-cli2]: https://github.com/DavidAnson/markdownlint-cli2
|
||||
[markdownlint-cli2-action]: https://github.com/marketplace/actions/markdownlint-cli2-action
|
||||
[markdownlint-cli2-blog]: https://dlaa.me/blog/post/markdownlintcli2
|
||||
[markdownlint-cli2-cjs]: test/markdownlint-cli2-cjs/.markdownlint-cli2.cjs
|
||||
[markdownlint-cli2-config-schema]: schema/markdownlint-cli2-config-schema.json
|
||||
[markdownlint-cli2-formatter]: https://www.npmjs.com/search?q=keywords:markdownlint-cli2-formatter
|
||||
[markdownlint-cli2-jsonc]: test/markdownlint-cli2-jsonc-example/.markdownlint-cli2.jsonc
|
||||
[markdownlint-cli2-mjs]: test/markdownlint-cli2-mjs/.markdownlint-cli2.mjs
|
||||
[markdownlint-cli2-yaml]: test/markdownlint-cli2-yaml-example/.markdownlint-cli2.yaml
|
||||
[markdownlint-cjs]: test/markdownlint-cjs/.markdownlint.cjs
|
||||
[markdownlint-jsonc]: https://github.com/DavidAnson/markdownlint/blob/v0.40.0/schema/.markdownlint.jsonc
|
||||
[markdownlint-mjs]: test/markdownlint-mjs/.markdownlint.mjs
|
||||
[markdownlint-rule]: https://www.npmjs.com/search?q=keywords:markdownlint-rule
|
||||
[markdownlint-yaml]: https://github.com/DavidAnson/markdownlint/blob/v0.40.0/schema/.markdownlint.yaml
|
||||
[nodejs]: https://nodejs.org/
|
||||
[nodejs-docker]: https://github.com/nodejs/docker-node
|
||||
[nodejs-docker-non-root]: https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#non-root-user
|
||||
[nodejs-import-expression]: https://nodejs.org/api/esm.html#import-expressions
|
||||
[nodejs-import-meta-resolve]: https://nodejs.org/api/esm.html#importmetaresolvespecifier
|
||||
[nodejs-require]: https://nodejs.org/api/modules.html#requireid
|
||||
[npm-image]: https://img.shields.io/npm/v/markdownlint-cli2.svg
|
||||
[npm-url]: https://www.npmjs.com/package/markdownlint-cli2
|
||||
[output-formatters]: doc/OutputFormatters.md
|
||||
[pre-commit]: https://pre-commit.com/
|
||||
[pre-commit-version]: https://pre-commit.com/#overriding-language-version
|
||||
[regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
|
||||
[regexp-constructor]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/RegExp
|
||||
[toml]: https://wikipedia.org/wiki/TOML
|
||||
[validating-configuration]: schema/ValidatingConfiguration.md
|
||||
[vscode]: https://code.visualstudio.com/
|
||||
[vscode-markdownlint]: https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint
|
||||
[yaml]: https://wikipedia.org/wiki/YAML
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// @ts-check
|
||||
|
||||
const sliceSize = 1000;
|
||||
|
||||
/**
|
||||
* Efficiently appends the source array to the destination array.
|
||||
* @template T
|
||||
* @param {T[]} destination Destination Array.
|
||||
* @param {T[]} source Source Array.
|
||||
* @returns {void}
|
||||
*/
|
||||
const appendToArray = (destination, source) => {
|
||||
// NOTE: destination.push(...source) throws "RangeError: Maximum call stack
|
||||
// size exceeded" for sufficiently lengthy source arrays
|
||||
let index = 0;
|
||||
let slice = null;
|
||||
while ((slice = source.slice(index, index + sliceSize)).length > 0) {
|
||||
destination.push(...slice);
|
||||
index += sliceSize;
|
||||
}
|
||||
};
|
||||
|
||||
export default appendToArray;
|
||||
export { sliceSize };
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// @ts-check
|
||||
|
||||
const packageName = "markdownlint-cli2";
|
||||
const packageVersion = "0.22.1";
|
||||
|
||||
const libraryName = "markdownlint";
|
||||
|
||||
const cli2SchemaKeys = new Set([
|
||||
"config",
|
||||
"customRules",
|
||||
"fix",
|
||||
"frontMatter",
|
||||
"gitignore",
|
||||
"globs",
|
||||
"ignores",
|
||||
"markdownItPlugins",
|
||||
"modulePaths",
|
||||
"noBanner",
|
||||
"noInlineConfig",
|
||||
"noProgress",
|
||||
"outputFormatters",
|
||||
"showFound"
|
||||
]);
|
||||
|
||||
export {
|
||||
cli2SchemaKeys,
|
||||
libraryName,
|
||||
packageName,
|
||||
packageVersion
|
||||
};
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// @ts-check
|
||||
|
||||
export { default } from "markdownlint/helpers";
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// @ts-check
|
||||
|
||||
export * from "markdownlint/promise";
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// @ts-check
|
||||
|
||||
export * from "markdownlint";
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// @ts-check
|
||||
|
||||
import { "main" as markdownlintCli2 } from "./markdownlint-cli2.mjs";
|
||||
|
||||
const params = {
|
||||
"argv": process.argv.slice(2),
|
||||
"logMessage": console.log,
|
||||
"logError": console.error,
|
||||
"allowStdin": true
|
||||
};
|
||||
try {
|
||||
process.exitCode = await markdownlintCli2(params);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
process.exitCode = 2;
|
||||
}
|
||||
+1165
File diff suppressed because it is too large
Load Diff
+27
@@ -0,0 +1,27 @@
|
||||
// @ts-check
|
||||
|
||||
/** @typedef {import("markdownlint-cli2").Options} Options */
|
||||
|
||||
/**
|
||||
* Merges two options objects by combining config and replacing properties.
|
||||
* @param {Options | null | undefined} first First options object.
|
||||
* @param {Options | null | undefined} second Second options object.
|
||||
* @returns {Options} Merged options object.
|
||||
*/
|
||||
const mergeOptions = (first, second) => {
|
||||
const merged = {
|
||||
...first,
|
||||
...second
|
||||
};
|
||||
const firstConfig = first && first.config;
|
||||
const secondConfig = second && second.config;
|
||||
if (firstConfig || secondConfig) {
|
||||
merged.config = {
|
||||
...firstConfig,
|
||||
...secondConfig
|
||||
};
|
||||
}
|
||||
return merged;
|
||||
};
|
||||
|
||||
export default mergeOptions;
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
{
|
||||
"name": "markdownlint-cli2",
|
||||
"version": "0.22.1",
|
||||
"description": "A fast, flexible, configuration-based command-line interface for linting Markdown/CommonMark files with the `markdownlint` library",
|
||||
"author": {
|
||||
"name": "David Anson",
|
||||
"url": "https://dlaa.me/"
|
||||
},
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./markdownlint-cli2.mjs",
|
||||
"./markdownlint": "./export-markdownlint.mjs",
|
||||
"./markdownlint/helpers": "./export-markdownlint-helpers.mjs",
|
||||
"./markdownlint/promise": "./export-markdownlint-promise.mjs",
|
||||
"./parsers": "./parsers/parsers.mjs",
|
||||
"./parsers/jsonc": "./parsers/jsonc-parse.mjs",
|
||||
"./parsers/toml": "./parsers/toml-parse.mjs",
|
||||
"./parsers/yaml": "./parsers/yaml-parse.mjs"
|
||||
},
|
||||
"bin": {
|
||||
"markdownlint-cli2": "markdownlint-cli2-bin.mjs"
|
||||
},
|
||||
"homepage": "https://github.com/DavidAnson/markdownlint-cli2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/DavidAnson/markdownlint-cli2.git"
|
||||
},
|
||||
"bugs": "https://github.com/DavidAnson/markdownlint-cli2/issues",
|
||||
"funding": "https://github.com/sponsors/DavidAnson",
|
||||
"scripts": {
|
||||
"build-docker-image": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker build -t davidanson/markdownlint-cli2:v$VERSION -f docker/Dockerfile --label org.opencontainers.image.version=v$VERSION .",
|
||||
"build-docker-image-rules": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker build -t davidanson/markdownlint-cli2-rules:v$VERSION -f docker/Dockerfile-rules --build-arg VERSION=v$VERSION --label org.opencontainers.image.version=v$VERSION .",
|
||||
"ci": "npm-run-all --continue-on-error --parallel test-cover lint schema && git diff --exit-code",
|
||||
"lint": "eslint --max-warnings 0",
|
||||
"lint-dockerfile": "docker run --rm -i hadolint/hadolint:latest-alpine < docker/Dockerfile",
|
||||
"lint-watch": "git ls-files | entr npm run lint",
|
||||
"playwright-install-bare": "npm run playwright-install-npm && playwright install",
|
||||
"playwright-install-npm": "npm install --no-save playwright@1.59.1",
|
||||
"playwright-test": "playwright test --config ./webworker/playwright.config.mjs",
|
||||
"playwright-test-docker": "docker run --rm --volume $PWD:/home/workdir --workdir /home/workdir --ipc=host mcr.microsoft.com/playwright:v1.59.1 npm run playwright-test",
|
||||
"schema": "cpy ./node_modules/markdownlint/schema/markdownlint-config-schema.json ./schema --flat",
|
||||
"test": "ava --timeout=1m test/append-to-array-test.mjs test/constants-test.mjs test/fs-virtual-test.mjs test/markdownlint-cli2-test.mjs test/markdownlint-cli2-test-exec.mjs test/markdownlint-cli2-test-exports.mjs test/markdownlint-cli2-test-formatters.mjs test/markdownlint-cli2-test-fs.mjs test/markdownlint-cli2-test-main.mjs test/merge-options-test.mjs",
|
||||
"test-cover": "c8 --100 npm test",
|
||||
"test-docker-hub-image": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker image rm davidanson/markdownlint-cli2:v$VERSION davidanson/markdownlint-cli2:latest || true && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2:v$VERSION \"*.md\" && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2:latest \"*.md\"",
|
||||
"test-docker-hub-image-rules": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker image rm davidanson/markdownlint-cli2-rules:v$VERSION davidanson/markdownlint-cli2-rules:latest || true && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2-rules:v$VERSION \"*.md\" && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2-rules:latest \"*.md\"",
|
||||
"test-docker-image": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2:v$VERSION \"*.md\"",
|
||||
"test-docker-image-rules": "VERSION=$(node -e \"process.stdout.write(require('./package.json').version)\") && docker run --rm -v $PWD:/workdir davidanson/markdownlint-cli2-rules:v$VERSION \"*.md\"",
|
||||
"test-invoke-as-cli": "markdownlint-cli2 CHANGELOG.md",
|
||||
"test-watch": "git ls-files | entr npm run test",
|
||||
"update-snapshots": "ava --timeout=1m --update-snapshots test/markdownlint-cli2-test-exec.mjs test/markdownlint-cli2-test-exports.mjs test/markdownlint-cli2-test-formatters.mjs test/markdownlint-cli2-test-fs.mjs test/markdownlint-cli2-test-main.mjs",
|
||||
"webworker": "cd webworker && webpack --mode none",
|
||||
"webworker-install": "npm install --no-save path-browserify setimmediate stream-browserify util webpack-cli && cpy ./node_modules/setimmediate/setImmediate.js ./webworker --flat --rename=setImmediate.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"files": [
|
||||
"append-to-array.mjs",
|
||||
"CHANGELOG.md",
|
||||
"constants.mjs",
|
||||
"export-markdownlint.mjs",
|
||||
"export-markdownlint-helpers.mjs",
|
||||
"export-markdownlint-promise.mjs",
|
||||
"LICENSE",
|
||||
"markdownlint-cli2.mjs",
|
||||
"markdownlint-cli2-bin.mjs",
|
||||
"merge-options.mjs",
|
||||
"parsers/parsers.mjs",
|
||||
"parsers/jsonc-parse.mjs",
|
||||
"parsers/toml-parse.mjs",
|
||||
"parsers/yaml-parse.mjs",
|
||||
"README.md",
|
||||
"schema/markdownlint-cli2-config-schema.json",
|
||||
"schema/markdownlint-config-schema.json",
|
||||
"schema/ValidatingConfiguration.md"
|
||||
],
|
||||
"dependencies": {
|
||||
"globby": "16.2.0",
|
||||
"js-yaml": "4.1.1",
|
||||
"jsonc-parser": "3.3.1",
|
||||
"jsonpointer": "5.0.1",
|
||||
"markdownlint": "0.40.0",
|
||||
"markdownlint-cli2-formatter-default": "0.0.6",
|
||||
"markdown-it": "14.1.1",
|
||||
"micromatch": "4.0.8",
|
||||
"smol-toml": "1.6.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "10.0.1",
|
||||
"@playwright/test": "1.59.1",
|
||||
"@stylistic/eslint-plugin": "5.10.0",
|
||||
"ajv": "8.18.0",
|
||||
"ava": "7.0.0",
|
||||
"c8": "11.0.0",
|
||||
"cpy": "13.2.1",
|
||||
"cpy-cli": "7.0.0",
|
||||
"eslint": "10.2.1",
|
||||
"eslint-plugin-jsdoc": "62.9.0",
|
||||
"eslint-plugin-n": "17.24.0",
|
||||
"eslint-plugin-unicorn": "64.0.0",
|
||||
"execa": "9.6.1",
|
||||
"markdown-it-emoji": "3.0.0",
|
||||
"markdown-it-for-inline": "2.0.1",
|
||||
"markdownlint-cli2-formatter-codequality": "0.0.7",
|
||||
"markdownlint-cli2-formatter-json": "0.0.9",
|
||||
"markdownlint-cli2-formatter-junit": "0.0.14",
|
||||
"markdownlint-cli2-formatter-pretty": "0.0.10",
|
||||
"markdownlint-cli2-formatter-sarif": "0.0.4",
|
||||
"markdownlint-cli2-formatter-summarize": "0.0.8",
|
||||
"markdownlint-cli2-formatter-template": "0.0.4",
|
||||
"markdownlint-rule-extended-ascii": "0.2.1",
|
||||
"npm-run-all": "4.1.5",
|
||||
"terminal-link": "5.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"markdown",
|
||||
"lint",
|
||||
"cli",
|
||||
"md",
|
||||
"CommonMark",
|
||||
"markdownlint"
|
||||
]
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// @ts-check
|
||||
|
||||
import { parse, printParseErrorCode } from "jsonc-parser";
|
||||
|
||||
/**
|
||||
* Parses a JSONC string, returning the corresponding object.
|
||||
* @type {import("markdownlint").ConfigurationParser}
|
||||
*/
|
||||
const jsoncParse = (text) => {
|
||||
/** @type {import("jsonc-parser").ParseError[]} */
|
||||
const errors = [];
|
||||
const result = parse(text, errors, { "allowTrailingComma": true });
|
||||
if (errors.length > 0) {
|
||||
const aggregate = errors.map(
|
||||
(error) => `${printParseErrorCode(error.error)} (offset ${error.offset}, length ${error.length})`
|
||||
).join(", ");
|
||||
throw new Error(`Unable to parse JSONC content, ${aggregate}`);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
export default jsoncParse;
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// @ts-check
|
||||
|
||||
import jsoncParse from "./jsonc-parse.mjs";
|
||||
import tomlParse from "./toml-parse.mjs";
|
||||
import yamlParse from "./yaml-parse.mjs";
|
||||
|
||||
/**
|
||||
* Array of parser objects ordered by priority.
|
||||
* @type {import("markdownlint").ConfigurationParser[]}
|
||||
*/
|
||||
const parsers = [
|
||||
jsoncParse,
|
||||
tomlParse,
|
||||
yamlParse
|
||||
];
|
||||
|
||||
export default parsers;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// @ts-check
|
||||
|
||||
import { parse } from "smol-toml";
|
||||
|
||||
/**
|
||||
* Parses a TOML string, returning the corresponding object.
|
||||
* @type {import("markdownlint").ConfigurationParser}
|
||||
*/
|
||||
const tomlParse = (text) => parse(text);
|
||||
|
||||
export default tomlParse;
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// @ts-check
|
||||
|
||||
import yaml from "js-yaml";
|
||||
|
||||
/* eslint-disable arrow-body-style */
|
||||
|
||||
/**
|
||||
* Parses a YAML string, returning the corresponding object.
|
||||
* @type {import("markdownlint").ConfigurationParser}
|
||||
*/
|
||||
const yamlParse = (text) => {
|
||||
// @ts-ignore
|
||||
return yaml.load(text);
|
||||
};
|
||||
|
||||
export default yamlParse;
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
# Validating Configuration
|
||||
|
||||
A [JSON Schema][json-schema] is provided to enable validating options objects:
|
||||
[`markdownlint-cli2-config-schema.json`][markdownlint-cli2-config-schema]
|
||||
|
||||
Some editors automatically use a JSON Schema with files that reference it. For
|
||||
example, a `.markdownlint-cli2.jsonc` file with:
|
||||
|
||||
```json
|
||||
"$schema": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/main/schema/markdownlint-cli2-config-schema.json"
|
||||
```
|
||||
|
||||
A JSON Schema validator can be used to check configuration files like so:
|
||||
|
||||
```bash
|
||||
npx ajv-cli validate -s ./markdownlint-cli2/schema/markdownlint-cli2-config-schema.json -r ./markdownlint-cli2/schema/markdownlint-config-schema.json -d "**/.markdownlint-cli2.{jsonc,yaml}" --strict=false
|
||||
```
|
||||
|
||||
A similar process is documented for validating `markdownlint` configuration
|
||||
objects: [Validating Configuration][validating-configuration].
|
||||
|
||||
[json-schema]: https://json-schema.org
|
||||
[markdownlint-cli2-config-schema]: markdownlint-cli2-config-schema.json
|
||||
[validating-configuration]: https://github.com/DavidAnson/markdownlint/blob/main/schema/ValidatingConfiguration.md
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.22.1/schema/markdownlint-cli2-config-schema.json",
|
||||
"title": "markdownlint-cli2 configuration schema",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"$schema": {
|
||||
"description": "JSON Schema URI (expected by some editors)",
|
||||
"type": "string",
|
||||
"default": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.22.1/schema/markdownlint-cli2-config-schema.json"
|
||||
},
|
||||
"config": {
|
||||
"description": "markdownlint configuration schema : https://github.com/DavidAnson/markdownlint/blob/v0.40.0/schema/.markdownlint.jsonc",
|
||||
"$ref": "https://raw.githubusercontent.com/DavidAnson/markdownlint/v0.40.0/schema/markdownlint-config-schema.json",
|
||||
"default": {}
|
||||
},
|
||||
"customRules": {
|
||||
"description": "Module names or paths of custom rules to load and use when linting : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.1/README.md#markdownlint-cli2jsonc",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"description": "Module name or path of a custom rule",
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"fix": {
|
||||
"description": "Whether to enable fixing of linting errors reported by rules that emit fix information : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.1/README.md#markdownlint-cli2jsonc",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"frontMatter": {
|
||||
"description": "Regular expression used to match and ignore any front matter at the beginning of a document : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.1/README.md#markdownlint-cli2jsonc",
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"default": ""
|
||||
},
|
||||
"gitignore": {
|
||||
"description": "Whether to ignore files referenced by .gitignore (or glob expression) (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.1/README.md#markdownlint-cli2jsonc",
|
||||
"type": [
|
||||
"boolean",
|
||||
"string"
|
||||
],
|
||||
"default": false
|
||||
},
|
||||
"globs": {
|
||||
"description": "Glob expressions to include when linting (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.1/README.md#markdownlint-cli2jsonc",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"description": "Glob expression of files to lint",
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"ignores": {
|
||||
"description": "Glob expressions to ignore when linting : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.1/README.md#markdownlint-cli2jsonc",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"description": "Glob expression of files to ignore",
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"markdownItPlugins": {
|
||||
"description": "markdown-it plugins to load and use when linting : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.1/README.md#markdownlint-cli2jsonc",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"description": "Name or path of a markdown-it plugin followed by parameters",
|
||||
"type": "array",
|
||||
"items": [
|
||||
{
|
||||
"description": "Name or path of a markdown-it plugin",
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
{
|
||||
"description": "Parameter(s) to pass to the markdown-it plugin"
|
||||
}
|
||||
],
|
||||
"minItems": 1
|
||||
}
|
||||
},
|
||||
"modulePaths": {
|
||||
"description": "Additional paths to resolve module locations from : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.1/README.md#markdownlint-cli2jsonc",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"description": "Path to resolve module locations from",
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"noBanner": {
|
||||
"description": "Whether to disable the display of the banner message and version numbers on stdout (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.1/README.md#markdownlint-cli2jsonc",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"noInlineConfig": {
|
||||
"description": "Whether to disable support of HTML comments within Markdown content : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.1/README.md#markdownlint-cli2jsonc",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"noProgress": {
|
||||
"description": "Whether to disable the display of progress on stdout (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.1/README.md#markdownlint-cli2jsonc",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"outputFormatters": {
|
||||
"description": "Output formatters to load and use to customize markdownlint-cli2 output (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.1/README.md#markdownlint-cli2jsonc",
|
||||
"type": "array",
|
||||
"default": [],
|
||||
"items": {
|
||||
"description": "Name or path of an output formatter followed by parameters",
|
||||
"type": "array",
|
||||
"items": [
|
||||
{
|
||||
"description": "Name or path of an output formatter",
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
{
|
||||
"description": "Parameter(s) to pass to the output formatter"
|
||||
}
|
||||
],
|
||||
"minItems": 1
|
||||
}
|
||||
},
|
||||
"showFound": {
|
||||
"description": "Whether to show the list of found files on stdout (only valid at the root) : https://github.com/DavidAnson/markdownlint-cli2/blob/v0.22.1/README.md#markdownlint-cli2jsonc",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
+5133
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user