dmnlint
raw JSON → 0.2.0 verified Fri May 01 auth: no javascript
A configurable linter for DMN (Decision Model and Notation) diagrams that checks against a set of rules to ensure quality and consistency. Version 0.2.0 is the current stable release, with ongoing development on GitHub. It provides CLI usage and supports integration with dmn-js for visual feedback during modeling. Key differentiators: based on bpmnlint architecture, supports custom rules via plugins and configuration through .dmnlintrc files.
Common errors
error Error: No such file or directory: .dmnlintrc ↓
cause Missing configuration file at working directory.
fix
Create a .dmnlintrc file or use programmatic config.
error Error: Could not find rule: label-required ↓
cause Rule name misspelled or not installed/loaded.
fix
Check rule name; ensure rules are available via extends or plugin.
error TypeError: Linter is not a constructor ↓
cause Using import incorrectly (e.g., destructuring default import).
fix
Use: import Linter from 'dmnlint';
error SyntaxError: Unexpected token } in JSON at position 20 ↓
cause Invalid JSON in .dmnlintrc file.
fix
Fix JSON syntax with a linter or validator.
Warnings
gotcha The linter expects valid DMN XML; any parse error will throw a synchronous exception before the async lint operation. ↓
fix Wrap in try-catch for synchronous parsing errors.
gotcha Configuration file (.dmnlintrc) must be in JSON format; other formats are not supported. ↓
fix Convert configuration to JSON.
gotcha Custom rules must be exported as a function that returns an object with rule definitions; see documentation. ↓
fix Follow the plugin example structure.
deprecated Using 'require' with default import may lead to CommonJS/ESM interop issues. ↓
fix Use import syntax or dynamic import() if needed.
Install
npm install dmnlint yarn add dmnlint pnpm add dmnlint Imports
- default export (linter instance) wrong
const Linter = require('dmnlint');correctimport Linter from 'dmnlint'; - Linter class
import { Linter } from 'dmnlint'; - Configuration type (TypeScript)
import type { DMNLintConfig } from 'dmnlint';
Quickstart
import Linter from 'dmnlint';
import { readFileSync } from 'fs';
const dmnXml = readFileSync('invoice.dmn', 'utf-8');
const linter = new Linter();
// Simple usage with default rules
linter.lint(dmnXml).then(results => {
console.log(JSON.stringify(results, null, 2));
});
// With configuration
const config = {
extends: 'dmnlint:recommended',
rules: {
'label-required': 'off',
},
};
linter.lint(dmnXml, config).then(results => {
if (results.length > 0) {
results.forEach(r => console.error(`${r.id} - ${r.message}`));
}
});