danger-plugin-lint-report
raw JSON → 1.8.1 verified Fri May 01 auth: no javascript
A Danger plugin that reads checkstyle/lint reports and posts issues and violations as inline comments on pull requests. Current version is 1.8.1, released in 2024. It supports multiple report formats (checkstyle, PMD, etc.), customizable violation formatting, deduplication of violations, and configurable project root. Designed for use with Danger JS in CI pipelines. Ships TypeScript definitions.
Common errors
error Error: Module 'danger-plugin-lint-report' does not provide a default export ↓
cause Using import lintReport from 'danger-plugin-lint-report' in a CommonJS environment without a default export set up.
fix
Change to import { lintReport } from 'danger-plugin-lint-report' or use require().
error TypeError: Cannot destructure property 'lintReport' of 'undefined' or 'null' ↓
cause Import statement imports the module incorrectly, e.g., import { lintReport } from 'danger-plugin-lint-report' but the module is not installed or not resolved.
fix
Ensure the package is installed: npm install danger-plugin-lint-report
error Type '{}' is not assignable to type 'Violation' ↓
cause Using a custom ViolationFormatter that does not match the expected signature.
fix
Update the formatter to accept a single argument of type Violation.
Warnings
breaking In v1.5.0, the default export changed from the entire module to just the lintReport function. If you were using import * as DangerLintReport from 'danger-plugin-lint-report', you need to switch to named import. ↓
fix Change import to: import { lintReport } from 'danger-plugin-lint-report'
deprecated The option 'failOnWarning' has been deprecated since v1.3.0; use 'failOnSeverity' instead. ↓
fix Replace failOnWarning with failOnSeverity with appropriate severity level.
gotcha When using the removeDuplicates option (v1.8.0+), be aware that duplicates are determined by file, line, and message. If your tool produces multiple identical violations on the same line, they are considered duplicates. ↓
fix No fix needed, just understand the deduplication logic.
gotcha The 'projectRoot' option (v1.7.0+) expects an absolute path. Relative paths may cause unexpected behavior. ↓
fix Use path.resolve() to ensure absolute path.
breaking In v1.6.0, the signature of ViolationFormatter changed. It now receives a single violation object instead of multiple arguments. ↓
fix Update your custom formatter to accept one argument: (violation) => string
deprecated Support for Node.js versions below 12 has been dropped as of v1.0.0. ↓
fix Upgrade Node.js to v12 or higher.
Install
npm install danger-plugin-lint-report yarn add danger-plugin-lint-report pnpm add danger-plugin-lint-report Imports
- lintReport wrong
const lintReport = require('danger-plugin-lint-report')correctimport { lintReport } from 'danger-plugin-lint-report' - default wrong
import { default as lintReport } from 'danger-plugin-lint-report'correctimport lintReport from 'danger-plugin-lint-report' - ViolationFormatter
import { ViolationFormatter } from 'danger-plugin-lint-report' - CheckstyleConfig wrong
import { CheckstyleConfig } from 'danger-plugin-lint-report'correctimport type { CheckstyleConfig } from 'danger-plugin-lint-report'
Quickstart
// dangerfile.js (CommonJS)
const { lintReport } = require('danger-plugin-lint-report');
schedule(lintReport({
// Path to your lint report file (checkstyle XML or JSON)
reportPath: 'path/to/lint-report.xml',
// Optional: remove duplicate violations across files (since v1.8.0)
removeDuplicates: true,
// Optional: custom violation formatter
// ViolationFormatter: (violation) => `- ${violation.file}:${violation.line}: ${violation.message}`
}));
// dangerfile.ts (ESM)
import { lintReport } from 'danger-plugin-lint-report';
schedule(lintReport({
reportPath: 'path/to/lint-report.xml',
removeDuplicates: true
}));