Detalhes do pacote

markdownlint-cli2-formatter-template

DavidAnson27.9kMIT0.0.3

An output formatter for markdownlint-cli2 that displays results using a template

markdownlint-cli2-formatter

readme (leia-me)

markdownlint-cli2-formatter-template

An output formatter for markdownlint-cli2 that displays results using a template.

npm version License

Install

npm install markdownlint-cli2-formatter-template --save-dev

Use

This output formatter makes it easy to custom-format linting violations. To specify an output format, set the template parameter to a string with text and one or more tokens representing any of the following elements. The specified template will be applied once for each violation.

These tokens are always defined:

Token Meaning
fileName File name
lineNumber Line number (1-based)
ruleName Rule name (full)
ruleDescription Rule description
ruleInformation Informational URL

These tokens are sometimes defined (depending on the rule/violation):

Token Meaning
columnNumber Column number (1-based)
errorContext Context information
errorDetail Additional detail

In the simplest case, tokens are specified with the syntax ${token}. This is all that's needed for tokens that are always defined. To support scenarios where a token may not be defined, the syntaxes ${token:text if present} and ${token!text if not present} are also supported. This allows for templates to accommodate missing data. Only one level of token nesting is supported.

A few examples demonstrate the concept:

Template Output if defined Output if not defined
Column=${columnNumber} Column=10 Column=
${columnNumber:Column=${columnNumber}} Column=10
${columnNumber!No column number} No column number
${columnNumber:Column=${columnNumber}}${columnNumber!No column number} Column=10 No column number

Examples

To output in the GitHub Actions workflow commands format, use something like the following .markdownlint-cli2.jsonc:

{
  "outputFormatters": [
    [
      "markdownlint-cli2-formatter-template",
      {
        "template": "::error file=${fileName},line=${lineNumber},${columnNumber:col=${columnNumber},}title=${ruleName}::${ruleDescription}"
      }
    ]
  ]
}

Which produces output like:

::error file=viewme.md,line=3,col=10,title=MD009/no-trailing-spaces::Trailing spaces
::error file=viewme.md,line=5,title=MD012/no-multiple-blanks::Multiple consecutive blank lines
::error file=viewme.md,line=6,title=MD025/single-title/single-h1::Multiple top-level headings in the same document
::error file=viewme.md,line=12,col=4,title=MD019/no-multiple-space-atx::Multiple spaces after hash on atx style heading
::error file=viewme.md,line=14,col=14,title=MD047/single-trailing-newline::Files should end with a single newline character

To output in the Azure Pipelines Task command LogIssue format, use something like the following .markdownlint-cli2.jsonc:

{
  "outputFormatters": [
    [
      "markdownlint-cli2-formatter-template",
      {
        "template": "##vso[task.logissue type=error;sourcepath=${fileName};linenumber=${lineNumber};${columnNumber:columnumber=${columnNumber};}code=${ruleName}]${ruleDescription}"
      }
    ]
  ]
}

Which produces output like:

##vso[task.logissue type=error;sourcepath=viewme.md;linenumber=3;columnumber=10;code=MD009/no-trailing-spaces]Trailing spaces
##vso[task.logissue type=error;sourcepath=viewme.md;linenumber=5;code=MD012/no-multiple-blanks]Multiple consecutive blank lines
##vso[task.logissue type=error;sourcepath=viewme.md;linenumber=6;code=MD025/single-title/single-h1]Multiple top-level headings in the same document
##vso[task.logissue type=error;sourcepath=viewme.md;linenumber=12;columnumber=4;code=MD019/no-multiple-space-atx]Multiple spaces after hash on atx style heading
##vso[task.logissue type=error;sourcepath=viewme.md;linenumber=14;columnumber=14;code=MD047/single-trailing-newline]Files should end with a single newline character

changelog (log de mudanças)

Changelog

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