Permalink
Browse files

chore(project): switch to eslint

Use eslint instead of jshint for linting.

* better linting results
* test files linted, too
* consistent code style checks

Closes #568
  • Loading branch information...
1 parent 7e93759 commit 0ba239bbcea742b52dacdc796e4f2611b8dc44b6 @nikku nikku committed Jun 7, 2016
Showing with 2,263 additions and 2,045 deletions.
  1. +34 −0 .eslintrc
  2. +0 −18 .jshintrc
  3. +1 −1 .travis.yml
  4. +14 −7 Gruntfile.js
  5. +2 −2 lib/draw/BpmnRenderer.js
  6. +2 −2 lib/draw/PathMap.js
  7. +2 −2 lib/features/auto-resize/AutoResize.js
  8. +5 −5 lib/features/context-pad/ContextPadProvider.js
  9. +9 −6 lib/features/copy-paste/BpmnCopyPaste.js
  10. +1 −1 lib/features/modeling/BpmnUpdater.js
  11. +1 −1 lib/features/modeling/behavior/ReplaceConnectionBehavior.js
  12. +2 −2 lib/features/modeling/cmd/IdClaimHandler.js
  13. +3 −3 lib/features/ordering/BpmnOrderingProvider.js
  14. +29 −29 lib/features/popup-menu/ReplaceMenuProvider.js
  15. +7 −7 lib/features/replace/BpmnReplace.js
  16. +3 −3 lib/features/replace/ReplaceOptions.js
  17. +10 −10 lib/features/rules/BpmnRules.js
  18. +1 −1 lib/features/search/BpmnSearchProvider.js
  19. +1 −1 lib/features/snapping/BpmnSnapping.js
  20. +7 −7 lib/import/BpmnImporter.js
  21. +4 −1 package.json
  22. +10 −9 test/config/translation-reporter.js
  23. +1 −1 test/helper/index.js
  24. +54 −50 test/integration/CustomElementsSpec.js
  25. +1 −1 test/integration/custom-elements/CustomElementFactory.js
  26. +1 −1 test/spec/NavigatedViewerSpec.js
  27. +1 −1 test/spec/ViewerSpec.js
  28. +5 −5 test/spec/draw/BpmnRendererSpec.js
  29. +1 −1 test/spec/environment/MockingSpec.js
  30. +89 −86 test/spec/features/auto-resize/AutoResizeSpec.js
  31. +75 −69 test/spec/features/context-pad/ContextPadProviderSpec.js
  32. +214 −201 test/spec/features/copy-paste/BpmnCopyPasteSpec.js
  33. +1 −1 test/spec/features/label-editing/LabelEditingProviderSpec.js
  34. +2 −1 test/spec/features/label-editing/TouchIntegrationSpec.js
  35. +2 −2 test/spec/features/modeling/AppendShapeSpec.js
  36. +1 −1 test/spec/features/modeling/BendpointsSpec.js
  37. +3 −3 test/spec/features/modeling/BpmnFactorySpec.js
  38. +6 −6 test/spec/features/modeling/CreateConnectionSpec.js
  39. +2 −1 test/spec/features/modeling/DeleteConnectionSpec.js
  40. +1 −1 test/spec/features/modeling/DeleteParticipantSpec.js
  41. +2 −1 test/spec/features/modeling/DeleteShapeSpec.js
  42. +8 −8 test/spec/features/modeling/DropSpec.js
  43. +5 −5 test/spec/features/modeling/MoveConnectionSpec.js
  44. +48 −43 test/spec/features/modeling/MoveRulesSpec.js
  45. +1 −1 test/spec/features/modeling/MoveShapeSpec.js
  46. +1 −1 test/spec/features/modeling/ResizeShapeSpec.js
  47. +1 −1 test/spec/features/modeling/SpaceToolSpec.js
  48. +1 −1 test/spec/features/modeling/UpdateAttachmentSpec.js
  49. +29 −27 test/spec/features/modeling/UpdateLabelSpec.js
  50. +1 −1 test/spec/features/modeling/UpdatePropertiesSpec.js
  51. +1 −1 test/spec/features/modeling/append/TextAnnotationSpec.js
  52. +1 −3 test/spec/features/modeling/behavior/CompensationAssociationBehaviorSpec.js
  53. +1 −1 test/spec/features/modeling/behavior/CreateBoundaryEventBehaviorSpec.js
  54. +1 −1 test/spec/features/modeling/behavior/CreateOnFlowBehaviorSpec.js
  55. +7 −7 test/spec/features/modeling/behavior/CreateParticipantBehaviorSpec.js
  56. +1 −1 test/spec/features/modeling/behavior/DataInputAssociationBehaviorSpec.js
  57. +2 −1 test/spec/features/modeling/behavior/DataObjectBehaviorSpec.js
  58. +2 −6 test/spec/features/modeling/behavior/DataStoreBehaviorSpec.js
  59. +3 −3 test/spec/features/modeling/behavior/LabelBehaviorSpec.js
  60. +4 −4 test/spec/features/modeling/behavior/ReconnectConnectionSpec.js
  61. +1 −1 test/spec/features/modeling/behavior/RemoveParticipantBehaviorSpec.js
  62. +46 −31 test/spec/features/modeling/behavior/ReplaceConnectionBehaviorSpec.js
  63. +259 −221 test/spec/features/modeling/behavior/ReplaceElementBehaviourSpec.js
  64. +0 −2 test/spec/features/modeling/behavior/UnsetDefaultFlowBehaviorSpec.js
  65. +1 −1 test/spec/features/modeling/lanes/AddLaneSpec.js
  66. +1 −1 test/spec/features/modeling/lanes/DeleteLaneSpec.js
  67. +1 −1 test/spec/features/modeling/lanes/ResizeLaneSpec.js
  68. +1 −1 test/spec/features/modeling/lanes/SplitLaneSpec.js
  69. +1 −1 test/spec/features/modeling/lanes/UpdateFlowNodeRefsSpec.js
  70. +2 −2 test/spec/features/modeling/layout/LayoutAssociationSpec.js
  71. +1 −1 test/spec/features/modeling/layout/LayoutConnectionSpec.js
  72. +2 −2 test/spec/features/modeling/layout/LayoutDataAssociationSpec.js
  73. +18 −17 test/spec/features/modeling/layout/LayoutMessageFlowSpec.js
  74. +55 −59 test/spec/features/modeling/layout/LayoutSequenceFlowSpec.js
  75. +1 −1 test/spec/features/palette/PaletteProviderSpec.js
  76. +569 −490 test/spec/features/popup-menu/ReplaceMenuProviderSpec.js
  77. +106 −108 test/spec/features/replace-preview/BpmnReplacePreviewSpec.js
  78. +364 −339 test/spec/features/replace/BpmnReplaceSpec.js
  79. +1 −1 test/spec/features/replace/ReplaceRulesSpec.js
  80. +4 −4 test/spec/features/rules/BpmnRulesSpec.js
  81. +12 −12 test/spec/features/search/BpmnSearchProviderSpec.js
  82. +74 −63 test/spec/features/snapping/BpmnSnappingSpec.js
  83. +1 −1 test/spec/features/snapping/BpmnSnappingUtilSpec.js
  84. +3 −5 test/spec/i18n/translateSpec.js
  85. +6 −8 test/spec/import/ImporterSpec.js
  86. +1 −1 test/spec/import/ModelWiringSpec.js
  87. +1 −1 test/spec/import/elements/AssociationSpec.js
  88. +1 −1 test/spec/import/elements/CollapsedSpec.js
  89. +1 −1 test/spec/import/elements/LabelSpec.js
  90. +1 −1 test/util/custom-rules/CustomRules.js
View
@@ -0,0 +1,34 @@
+{
+ "rules": {
+ "keyword-spacing": [ 2 ],
+ "object-curly-spacing": [ 2, "always"],
+ "space-before-blocks": [ 2, "always"],
+ "indent": [ 2, 2, { "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } } ],
+ "no-unused-vars": [ 2, { "args": "none" } ],
+ "space-before-function-paren": [ 2, "never" ],
+ "quotes": [ 2, "single" ],
+ "semi": [ 2, "always" ],
+ "no-console": 0,
+ "mocha/no-exclusive-tests": 2
+ },
+ "env": {
+ "node": true,
+ "browser": true
+ },
+ "extends": "eslint:recommended",
+ "parserOptions": {
+ "sourceType": "module"
+ },
+ "plugins": [
+ "mocha"
+ ],
+ "globals": {
+ "expect": false,
+ "it": false,
+ "describe": false,
+ "beforeEach": true,
+ "afterEach": true,
+ "before": true,
+ "after": true
+ }
+}
View
@@ -1,18 +0,0 @@
-{
- "browser": true,
- "node": true,
- "strict": true,
- "unused": "vars",
- "maxlen": 120,
- "expr": true,
- "globals": {
- "describe": false,
- "it": false,
- "expect": true,
- "beforeEach": true,
- "afterEach": true,
- "console": true,
- "spyOn": true,
- "jasmine": true
- }
-}
View
@@ -2,7 +2,7 @@ language: node_js
node_js: '4.0'
script:
- - grunt jshint test
+ - npm run all
before_install:
- npm install -g wiredeps
View
@@ -22,12 +22,19 @@ module.exports = function(grunt) {
dist: '../bower-bpmn-js/dist'
},
- jshint: {
- src: [
- ['<%=config.sources %>']
- ],
- options: {
- jshintrc: true
+ eslint: {
+ check: {
+ src: [
+ '{lib,test}/**/*.js'
+ ]
+ },
+ fix: {
+ src: [
+ '{lib,test}/**/*.js'
+ ],
+ options: {
+ fix: true
+ }
}
},
@@ -116,5 +123,5 @@ module.exports = function(grunt) {
grunt.registerTask('build', [ 'bundle', 'copy' ]);
- grunt.registerTask('default', [ 'jshint', 'test', 'build' ]);
+ grunt.registerTask('default', [ 'eslint:check', 'test', 'build' ]);
};
@@ -399,7 +399,7 @@ function BpmnRenderer(eventBus, styles, pathMap, priority) {
strokeLinecap: 'square'
});
- for(var i = 0;i < 12;i++) {
+ for (var i = 0;i < 12;i++) {
var linePathData = pathMap.getScaledPath('EVENT_TIMER_LINE', {
xScaleFactor: 0.75,
@@ -946,7 +946,7 @@ function BpmnRenderer(eventBus, styles, pathMap, priority) {
}
});
- if (!!(getDi(element).isMarkerVisible)) {
+ if ((getDi(element).isMarkerVisible)) {
drawPath(p, pathData, {
strokeWidth: 1,
fill: 'black'
View
@@ -411,7 +411,7 @@ function PathMap() {
// compute the start point of the path
var mx, my;
- if(!!param.abspos) {
+ if (param.abspos) {
mx = param.abspos.x;
my = param.abspos.y;
} else {
@@ -420,7 +420,7 @@ function PathMap() {
}
var coordinates = {}; //map for the scaled coordinates
- if(param.position) {
+ if (param.position) {
// path
var heightRatio = (param.containerHeight / rawPath.height) * param.yScaleFactor;
@@ -21,7 +21,7 @@ var PADDING = { top: 2, bottom: 2, left: 15, right: 15 };
* An auto resize component that takes care of expanding parent participants
* and lanes if elements are modeled close to an edge of the parent element.
*/
-function AutoResize(eventBus, canvas, modeling, elementRegistry){
+function AutoResize(eventBus, canvas, modeling, elementRegistry) {
CommandInterceptor.call(this, eventBus);
@@ -74,7 +74,7 @@ function AutoResize(eventBus, canvas, modeling, elementRegistry){
top: bbox.y < target.y + padding.top,
bottom: bbox.y + bbox.height > target.y + target.height - padding.bottom,
left: bbox.x < target.x + padding.left,
- right: bbox.x + bbox.width > target.x + target.width - padding.right,
+ right: bbox.x + bbox.width > target.x + target.width - padding.right
};
}
@@ -216,16 +216,16 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
'append.receive-task': appendAction('bpmn:ReceiveTask', 'bpmn-icon-receive-task'),
'append.message-intermediate-event': appendAction('bpmn:IntermediateCatchEvent',
'bpmn-icon-intermediate-event-catch-message',
- { eventDefinitionType: 'bpmn:MessageEventDefinition'}),
+ { eventDefinitionType: 'bpmn:MessageEventDefinition' }),
'append.timer-intermediate-event': appendAction('bpmn:IntermediateCatchEvent',
'bpmn-icon-intermediate-event-catch-timer',
- { eventDefinitionType: 'bpmn:TimerEventDefinition'}),
+ { eventDefinitionType: 'bpmn:TimerEventDefinition' }),
'append.condtion-intermediate-event': appendAction('bpmn:IntermediateCatchEvent',
'bpmn-icon-intermediate-event-catch-condition',
- { eventDefinitionType: 'bpmn:ConditionalEventDefinition'}),
+ { eventDefinitionType: 'bpmn:ConditionalEventDefinition' }),
'append.signal-intermediate-event': appendAction('bpmn:IntermediateCatchEvent',
'bpmn-icon-intermediate-event-catch-signal',
- { eventDefinitionType: 'bpmn:SignalEventDefinition'})
+ { eventDefinitionType: 'bpmn:SignalEventDefinition' })
});
} else
@@ -318,7 +318,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
}
// delete element entry, only show if allowed by rules
- var deleteAllowed = rules.allowed('elements.delete', { elements: [ element ]});
+ var deleteAllowed = rules.allowed('elements.delete', { elements: [ element ] });
if (isArray(deleteAllowed)) {
// was the element returned as a deletion candidate?
@@ -88,7 +88,6 @@ function BpmnCopyPaste(bpmnFactory, eventBus, copyPaste, clipboard, moddle, canv
parent = descriptor.parent,
rootElement = canvas.getRootElement(),
businessObject,
- eventDefinitions,
newEventDefinition,
conditionExpression,
loopCharacteristics,
@@ -139,7 +138,7 @@ function BpmnCopyPaste(bpmnFactory, eventBus, copyPaste, clipboard, moddle, canv
setProperties(businessObject, descriptor, [
'name',
- 'text',
+ 'text'
]);
if (descriptor.loopCharacteristics) {
@@ -163,8 +162,6 @@ function BpmnCopyPaste(bpmnFactory, eventBus, copyPaste, clipboard, moddle, canv
}
if (descriptor.eventDefinitions) {
- eventDefinitions = businessObject.eventDefinitions;
-
businessObject.eventDefinitions = map(descriptor.eventDefinitions, function(type) {
newEventDefinition = moddle.create(type);
@@ -174,7 +171,13 @@ function BpmnCopyPaste(bpmnFactory, eventBus, copyPaste, clipboard, moddle, canv
});
}
- removeProperties(descriptor, [ 'name', 'text', 'eventDefinitions', 'conditionExpression', 'loopCharacteristics' ]);
+ removeProperties(descriptor, [
+ 'name',
+ 'text',
+ 'eventDefinitions',
+ 'conditionExpression',
+ 'loopCharacteristics'
+ ]);
});
}
@@ -189,4 +192,4 @@ BpmnCopyPaste.$inject = [
'bpmnRules'
];
-module.exports = BpmnCopyPaste;
+module.exports = BpmnCopyPaste;
@@ -439,7 +439,7 @@ BpmnUpdater.prototype.updateSemanticParent = function(businessObject, newParent,
do {
// unwrap Lane -> LaneSet -> (Lane | FlowElementsContainer)
newParent = newParent.$parent.$parent;
- } while(is(newParent, 'bpmn:Lane'));
+ } while (is(newParent, 'bpmn:Lane'));
}
}
@@ -91,7 +91,7 @@ function ReplaceConnectionBehavior(eventBus, modeling, bpmnRules) {
this.postExecuted([
'connection.reconnectStart',
'connection.reconnectEnd'
- ], function(event){
+ ], function(event) {
var connection = event.context.connection;
@@ -16,7 +16,7 @@ IdClaimHandler.prototype.execute = function(context) {
element = context.element,
claiming = context.claiming;
- if (claiming){
+ if (claiming) {
ids.claim(id, element);
} else {
ids.unclaim(id);
@@ -32,7 +32,7 @@ IdClaimHandler.prototype.revert = function(context) {
element = context.element,
claiming = context.claiming;
- if (claiming){
+ if (claiming) {
ids.unclaim(id);
} else {
ids.claim(id, element);
@@ -87,9 +87,9 @@ function BpmnOrderingProvider(eventBus, translate) {
if (!actualParent) {
throw new Error(translate('no parent for {element} in {parent}', {
- element: element.id,
- parent: newParent.id
- }));
+ element: element.id,
+ parent: newParent.id
+ }));
}
return actualParent;
@@ -273,7 +273,7 @@ ReplaceMenuProvider.prototype._createEntries = function(element, replaceOptions)
* @return {Array<Object>} a list of menu items
*/
-ReplaceMenuProvider.prototype._createSequenceFlowEntries = function (element, replaceOptions) {
+ReplaceMenuProvider.prototype._createSequenceFlowEntries = function(element, replaceOptions) {
var businessObject = getBusinessObject(element);
@@ -287,44 +287,44 @@ ReplaceMenuProvider.prototype._createSequenceFlowEntries = function (element, re
forEach(replaceOptions, function(entry) {
switch (entry.actionName) {
- case 'replace-with-default-flow':
- if (businessObject.sourceRef.default !== businessObject &&
+ case 'replace-with-default-flow':
+ if (businessObject.sourceRef.default !== businessObject &&
(is(businessObject.sourceRef, 'bpmn:ExclusiveGateway') ||
is(businessObject.sourceRef, 'bpmn:InclusiveGateway') ||
is(businessObject.sourceRef, 'bpmn:Activity'))) {
- menuEntries.push(self._createMenuEntry(entry, element, function() {
- modeling.updateProperties(element.source, { default: businessObject });
- }));
- }
- break;
- case 'replace-with-conditional-flow':
- if (!businessObject.conditionExpression && is(businessObject.sourceRef, 'bpmn:Activity')) {
-
- menuEntries.push(self._createMenuEntry(entry, element, function() {
- var conditionExpression = moddle.create('bpmn:FormalExpression', { body: '' });
-
- modeling.updateProperties(element, { conditionExpression: conditionExpression });
- }));
- }
- break;
- default:
+ menuEntries.push(self._createMenuEntry(entry, element, function() {
+ modeling.updateProperties(element.source, { default: businessObject });
+ }));
+ }
+ break;
+ case 'replace-with-conditional-flow':
+ if (!businessObject.conditionExpression && is(businessObject.sourceRef, 'bpmn:Activity')) {
+
+ menuEntries.push(self._createMenuEntry(entry, element, function() {
+ var conditionExpression = moddle.create('bpmn:FormalExpression', { body: '' });
+
+ modeling.updateProperties(element, { conditionExpression: conditionExpression });
+ }));
+ }
+ break;
+ default:
// default flows
- if (is(businessObject.sourceRef, 'bpmn:Activity') && businessObject.conditionExpression) {
- return menuEntries.push(self._createMenuEntry(entry, element, function() {
- modeling.updateProperties(element, { conditionExpression: undefined });
- }));
- }
+ if (is(businessObject.sourceRef, 'bpmn:Activity') && businessObject.conditionExpression) {
+ return menuEntries.push(self._createMenuEntry(entry, element, function() {
+ modeling.updateProperties(element, { conditionExpression: undefined });
+ }));
+ }
// conditional flows
- if ((is(businessObject.sourceRef, 'bpmn:ExclusiveGateway') ||
+ if ((is(businessObject.sourceRef, 'bpmn:ExclusiveGateway') ||
is(businessObject.sourceRef, 'bpmn:InclusiveGateway') ||
is(businessObject.sourceRef, 'bpmn:Activity')) &&
businessObject.sourceRef.default === businessObject) {
- return menuEntries.push(self._createMenuEntry(entry, element, function() {
- modeling.updateProperties(element.source, { default: undefined });
- }));
- }
+ return menuEntries.push(self._createMenuEntry(entry, element, function() {
+ modeling.updateProperties(element.source, { default: undefined });
+ }));
+ }
}
});
@@ -83,16 +83,16 @@ function BpmnReplace(bpmnFactory, replace, selection, modeling) {
if (is(oldBusinessObject, 'bpmn:Participant')) {
// create expanded pool
- if (target.isExpanded === true) {
- newBusinessObject.processRef = bpmnFactory.create('bpmn:Process');
- } else {
+ if (target.isExpanded === true) {
+ newBusinessObject.processRef = bpmnFactory.create('bpmn:Process');
+ } else {
// remove children when transforming to collapsed pool
- hints.moveChildren = false;
- }
+ hints.moveChildren = false;
+ }
// apply same size
- newElement.width = element.width;
- newElement.height = element.height;
+ newElement.width = element.width;
+ newElement.height = element.height;
}
newBusinessObject.name = oldBusinessObject.name;
Oops, something went wrong.

0 comments on commit 0ba239b

Please sign in to comment.