diff --git a/lib/Linter.js b/lib/Linter.js index 41c2413..602162a 100644 --- a/lib/Linter.js +++ b/lib/Linter.js @@ -20,6 +20,8 @@ import { toSemverMinor } from './utils/version'; import { getDocumentationUrl } from './utils/documentation'; +import defaultPlugins from './plugins'; + const NoopResolver = new StaticResolver({}); /** @@ -47,7 +49,7 @@ export class Linter { }); this._modeler = modeler; - this._plugins = plugins; + this._plugins = [ ...defaultPlugins, ...plugins ]; } async lint(contents) { diff --git a/lib/plugins/bpmnLintPlugin.js b/lib/plugins/bpmnLintPlugin.js new file mode 100644 index 0000000..ef1e4ab --- /dev/null +++ b/lib/plugins/bpmnLintPlugin.js @@ -0,0 +1,11 @@ +import StaticResolver from 'bpmnlint/lib/resolver/static-resolver'; +import rule from 'bpmnlint/rules/no-bpmndi'; + +export default { + config: { + rules: { + 'bpmnlint/no-bpmndi': 'warn' + } + }, + resolver: new StaticResolver({ 'rule:bpmnlint/no-bpmndi': rule }) +}; \ No newline at end of file diff --git a/lib/plugins/index.js b/lib/plugins/index.js new file mode 100644 index 0000000..7f791e1 --- /dev/null +++ b/lib/plugins/index.js @@ -0,0 +1,5 @@ +import bpmnLintPlugin from './bpmnLintPlugin'; + +export default [ + bpmnLintPlugin +]; \ No newline at end of file diff --git a/test/spec/Linter.spec.js b/test/spec/Linter.spec.js index 3774889..9a477c2 100644 --- a/test/spec/Linter.spec.js +++ b/test/spec/Linter.spec.js @@ -10,6 +10,7 @@ import { import { Linter } from '../..'; import simpleXML from './simple.bpmn'; +import missingDiXML from './simple-no-di.bpmn'; import noExecutionPlatformXML from './no-execution-platform.bpmn'; import camundaCloud10XML from './camunda-cloud-1-0.bpmn'; import camundaCloud10ErrorsXML from './camunda-cloud-1-0-errors.bpmn'; @@ -386,13 +387,32 @@ describe('Linter', function() { const BazPlugin = { config: { rules: { - 'foo/superfluous-gateway': 'off' + 'foo/superfluous-gateway': 'off', + 'bpmnlint/no-bpmndi': 'off' } }, resolver: new StaticResolver({}) }; + it('should have default plugins', async function() { + + // given + const linter = new Linter(); + + const { root } = await createModdle(missingDiXML); + + // when + const reports = await linter.lint(root); + + // then + expect(reports).to.have.length(2); + + expect(reports.find(({ message }) => message === 'Element is missing bpmndi')).to.exist; + + }); + + it('should add rules (rules)', async function() { // given @@ -447,7 +467,7 @@ describe('Linter', function() { ] }); - const { root } = await createModdle(simpleXML); + const { root } = await createModdle(missingDiXML); // when const reports = await linter.lint(root); @@ -456,6 +476,7 @@ describe('Linter', function() { expect(reports).to.have.length(2); expect(reports.find(({ message }) => message === 'Gateway is superfluous. It only has one source and target.')).not.to.exist; + expect(reports.find(({ message }) => message === 'Element is missing bpmndi')).not.to.exist; expect(reports.find(({ message }) => message === 'Element is an implicit end')).to.exist; }); diff --git a/test/spec/simple-no-di.bpmn b/test/spec/simple-no-di.bpmn new file mode 100644 index 0000000..9978349 --- /dev/null +++ b/test/spec/simple-no-di.bpmn @@ -0,0 +1,34 @@ + + + + + SequenceFlow_1 + + + SequenceFlow_1 + SequenceFlow_2 + + + + SequenceFlow_2 + + + + + + + + + + + + + + + + + + + + +