diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..57a9206cf --- /dev/null +++ b/.eslintignore @@ -0,0 +1,4 @@ +**/node_modules +/scripts +/dist +/build diff --git a/.travis.yml b/.travis.yml index 11021b803..5939ac8e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,3 +9,7 @@ install: npm install before_script: - grunt install + +script: + - npm run test + - npm run lint diff --git a/README.md b/README.md index b7d4daff3..146b9e291 100644 --- a/README.md +++ b/README.md @@ -98,10 +98,6 @@ To run only the client-side tests: grunt test:client ``` -To run code style checks: -``` -grunt test:code-style -``` ### Lint diff --git a/demo/.eslintrc.js b/demo/.eslintrc.js new file mode 100644 index 000000000..e5f55e224 --- /dev/null +++ b/demo/.eslintrc.js @@ -0,0 +1,49 @@ +module.exports = { + 'extends': [ + '../.eslintrc.js', + ], + 'parserOptions': { + // 2018 allows use of async and spread syntax + 'ecmaVersion': '2018' + }, + 'globals': { + 'joint': true, + 'g': true, + 'V': true, + '$': true, + 'Backbone': true, + 'Vue': true + }, + 'ignorePatterns': ['/ts-demo/vendor/**'], + 'overrides': [{ + 'files': [ + 'rough/src/rough.js', + 'ports/port-z-index.js', + 'ports/port-layouts-defaults.js', + 'expand/expand.paper.js', + 'chess/src/garbochess.js', + 'vuejs/demo.js', + 'petri nets/src/pn.js', + 'org/src/org.js', + 'custom-router.js', + 'archive/links.js', + 'embedding/nested-clone.js', + 'expand/index.js', + 'expand/shapes.js', + 'vectorizer/vectorizer.js' + ], + // Globals contained in HTML script, etc + 'globals': { + 'rough': true, + 'createPaper': true, + 'paper': true + }, + 'rules': { + // Exceptions currently used in demo directory + 'no-redeclare': ['off'], + 'no-unused-vars': ['off'], + 'no-console': ['off'] + } + }] +}; + diff --git a/demo/chess/src/garbochess.js b/demo/chess/src/garbochess.js index cf5f8b9eb..3efc2f704 100644 --- a/demo/chess/src/garbochess.js +++ b/demo/chess/src/garbochess.js @@ -1657,7 +1657,7 @@ function MakeMove(move){ if (flags) { if (flags & moveflagCastleKing) { if (IsSquareAttackable(from + 1, otherColor) || - IsSquareAttackable(from + 2, otherColor)) { + IsSquareAttackable(from + 2, otherColor)) { g_moveCount--; return false; } @@ -1680,7 +1680,7 @@ function MakeMove(move){ g_pieceList[((rook & 0xF) << 4) | rookIndex] = to - 1; } else if (flags & moveflagCastleQueen) { if (IsSquareAttackable(from - 1, otherColor) || - IsSquareAttackable(from - 2, otherColor)) { + IsSquareAttackable(from - 2, otherColor)) { g_moveCount--; return false; } diff --git a/demo/elk/src/app.js b/demo/elk/src/app.js index 7cb25d1f5..2148ec79f 100644 --- a/demo/elk/src/app.js +++ b/demo/elk/src/app.js @@ -1,7 +1,7 @@ import * as joint from '../../../build/joint'; import ELK from 'elkjs/lib/elk-api.js'; import elkWorker from 'elkjs/lib/elk-worker.js'; -import { Child, Label, Edge } from "./shapes"; +import { Child, Label, Edge } from './shapes'; import elkGraph from '../elkGraph.json'; export const init = () => { @@ -142,7 +142,7 @@ export const init = () => { addEdges(edges); paper.unfreeze(); - paper.fitToContent({ useModelGeometry: true, padding: 100, allowNewOrigin: 'any' }) + paper.fitToContent({ useModelGeometry: true, padding: 100, allowNewOrigin: 'any' }); }); canvas.appendChild(paper.el); @@ -155,8 +155,8 @@ const addZoomListeners = paper => { const zoom = zoomLevel => { paper.scale(zoomLevel); - paper.fitToContent({ useModelGeometry: true, padding: 100 * zoomLevel, allowNewOrigin: 'any' }) - } + paper.fitToContent({ useModelGeometry: true, padding: 100 * zoomLevel, allowNewOrigin: 'any' }); + }; document.getElementById('zoom-in').addEventListener('click', () => { zoomLevel = Math.min(3, zoomLevel + 0.2); @@ -167,7 +167,7 @@ const addZoomListeners = paper => { zoomLevel = Math.max(0.2, zoomLevel - 0.2); zoom(zoomLevel); }); -} +}; const placementsOptions = { H_RIGHT: 'H_RIGHT', @@ -176,7 +176,7 @@ const placementsOptions = { V_TOP: 'V_TOP', V_BOTTOM: 'V_BOTTOM', V_CENTER: 'V_CENTER', -} +}; const getLabelPlacement = label => { const placement = {}; @@ -203,4 +203,4 @@ const getLabelPlacement = label => { } return placement; -} +}; diff --git a/demo/expand/index.js b/demo/expand/index.js index 72943f2a5..bd75a9703 100644 --- a/demo/expand/index.js +++ b/demo/expand/index.js @@ -207,7 +207,7 @@ var isCollapsed = function(cell, portId) { var runTests = function() { -///////////// + ///////////// a.hide(); console.assert(aa.portProp('in1', 'collapsed'), 'aa in1 is collapsed'); diff --git a/demo/interpreter.js b/demo/interpreter.js index 5843720d6..c8771741e 100644 --- a/demo/interpreter.js +++ b/demo/interpreter.js @@ -52,7 +52,7 @@ graph.on('signal', function(cell) { var token = V('circle', { r: 7, fill: 'green' }); cell.findView(paper).sendToken(token, 1000, function() { - targetCell.trigger('signal', targetCell); + targetCell.trigger('signal', targetCell); }); } else { diff --git a/demo/links/src/custom-router.js b/demo/links/src/custom-router.js index 8264e4419..f17cbc7a2 100644 --- a/demo/links/src/custom-router.js +++ b/demo/links/src/custom-router.js @@ -12,7 +12,7 @@ var paper = new joint.dia.Paper({ // define the router inside joint.routers // allows passing custom arguments // can be serialized with `toJSON()` -joint.routers.randomWalk = function (vertices, args, linkView) { +joint.routers.randomWalk = function(vertices, args, linkView) { var NUM_BOUNCES = args.numBounces || 20; @@ -24,11 +24,11 @@ joint.routers.randomWalk = function (vertices, args, linkView) { var targetCorner = linkView.targetBBox.center(); var randomPoint = g.Point.random(sourceCorner.x, targetCorner.x, sourceCorner.y, targetCorner.y); - vertices.push(randomPoint) + vertices.push(randomPoint); } return vertices; -} +}; var source = new joint.shapes.standard.Rectangle(); source.position(50, 50); @@ -36,7 +36,7 @@ source.resize(140, 70); source.attr('label/text', 'Source'); var target = source.clone(); -target.translate(700, 400) +target.translate(700, 400); target.attr('label/text', 'Target'); var link = new joint.shapes.standard.Link(); @@ -47,7 +47,7 @@ link.target(target); // pass by name under which it was saved in joint.routers namespace link.router('randomWalk', { numBounces: 10, -}) +}); // APPROACH 2: // pass a function diff --git a/demo/org/src/org.js b/demo/org/src/org.js index 84b633956..67b686ac7 100644 --- a/demo/org/src/org.js +++ b/demo/org/src/org.js @@ -12,14 +12,14 @@ var paper = new joint.dia.Paper({ var member = function(x, y, rank, name, image, background, textColor) { - textColor = textColor || "#000"; + textColor = textColor || '#000'; var cell = new joint.shapes.org.Member({ position: { x: x, y: y }, attrs: { - '.card': { fill: background, stroke: 'none'}, - image: { 'xlink:href': 'images/'+ image, opacity: 0.7 }, - '.rank': { text: rank, fill: textColor, 'word-spacing': '-5px', 'letter-spacing': 0}, + '.card': { fill: background, stroke: 'none' }, + image: { 'xlink:href': 'images/'+ image, opacity: 0.7 }, + '.rank': { text: rank, fill: textColor, 'word-spacing': '-5px', 'letter-spacing': 0 }, '.name': { text: name, fill: textColor, 'font-size': 13, 'font-family': 'Arial', 'letter-spacing': 0 } } }); @@ -57,9 +57,9 @@ var carl = member(190, 500, 'Manager', 'Carl Carlson', 'male.png', '#feb563'); -link(bart, marge, [{x: 385, y: 180}]); -link(bart, homer, [{x: 385, y: 180}, {x: 175, y: 180}]); -link(bart, lisa, [{x: 385, y: 180}, {x: 585, y: 180}]); -link(homer, lenny, [{x:175 , y: 380}]); -link(homer, carl, [{x:175 , y: 530}]); -link(marge, maggie, [{x:385 , y: 380}]); +link(bart, marge, [{ x: 385, y: 180 }]); +link(bart, homer, [{ x: 385, y: 180 }, { x: 175, y: 180 }]); +link(bart, lisa, [{ x: 385, y: 180 }, { x: 585, y: 180 }]); +link(homer, lenny, [{ x:175 , y: 380 }]); +link(homer, carl, [{ x:175 , y: 530 }]); +link(marge, maggie, [{ x:385 , y: 380 }]); diff --git a/demo/ports/port-layouts-defaults.js b/demo/ports/port-layouts-defaults.js index 9d078265a..5bf99dd33 100644 --- a/demo/ports/port-layouts-defaults.js +++ b/demo/ports/port-layouts-defaults.js @@ -2,7 +2,7 @@ $('
').text('Default settings').appendTo('body'); var graph1 = createPaper().model; $('').text('add port').appendTo('body').on('click', function() { - g1.addPort({ attrs: { circle: { magnet: true, stroke: '#31d0c6', 'stroke-width': 2, fill: '#ffffff' } } }); + g1.addPort({ attrs: { circle: { magnet: true, stroke: '#31d0c6', 'stroke-width': 2, fill: '#ffffff' }}}); }); $('').text('remove port').appendTo('body').on('click', function() { g1.removePort(g1.getPorts()[0]); @@ -15,9 +15,9 @@ var g1 = new joint.shapes.basic.Rect({ } }); graph1.addCell(g1); -g1.addPort({ attrs: { circle: { magnet: true, stroke: '#31d0c6', 'stroke-width': 2, fill: '#ffffff' } } }); -g1.addPort({ attrs: { circle: { magnet: true, stroke: '#31d0c6', 'stroke-width': 2, fill: '#ffffff' } } }); -g1.addPort({ attrs: { circle: { magnet: true, stroke: '#31d0c6', 'stroke-width': 2, fill: '#ffffff' } } }); +g1.addPort({ attrs: { circle: { magnet: true, stroke: '#31d0c6', 'stroke-width': 2, fill: '#ffffff' }}}); +g1.addPort({ attrs: { circle: { magnet: true, stroke: '#31d0c6', 'stroke-width': 2, fill: '#ffffff' }}}); +g1.addPort({ attrs: { circle: { magnet: true, stroke: '#31d0c6', 'stroke-width': 2, fill: '#ffffff' }}}); new joint.shapes.basic.Circle({ position: { x: 20, y: 150 }, id: 'target', @@ -27,6 +27,6 @@ new joint.shapes.basic.Circle({ } }).addTo(graph1); -new joint.dia.Link({ source: { id: 'target' }, target: { id: g1.id, port: g1.getPorts()[0].id } }).addTo(graph1); -new joint.dia.Link({ source: { id: 'target' }, target: { id: g1.id, port: g1.getPorts()[1].id } }).addTo(graph1); -new joint.dia.Link({ source: { id: 'target' }, target: { id: g1.id, port: g1.getPorts()[2].id } }).addTo(graph1); +new joint.dia.Link({ source: { id: 'target' }, target: { id: g1.id, port: g1.getPorts()[0].id }}).addTo(graph1); +new joint.dia.Link({ source: { id: 'target' }, target: { id: g1.id, port: g1.getPorts()[1].id }}).addTo(graph1); +new joint.dia.Link({ source: { id: 'target' }, target: { id: g1.id, port: g1.getPorts()[2].id }}).addTo(graph1); diff --git a/demo/vectorizer/vectorizer.js b/demo/vectorizer/vectorizer.js index 663db7766..962baab34 100644 --- a/demo/vectorizer/vectorizer.js +++ b/demo/vectorizer/vectorizer.js @@ -115,9 +115,9 @@ svg.append(curvePath); var text = V('text', { x: 250, y: 30, fill: 'black' }); text.text('This is a rich text.\nThis text goes to multiple lines.', { lineHeight: 'auto', annotations: [ - { start: 5, end: 10, attrs: { fill: 'red', 'font-size': 30, rotate: '20' } }, - { start: 7, end: 15, attrs: { fill: 'blue' } }, - { start: 20, end: 30, attrs: { fill: 'blue', 'class': 'text-link', style: 'text-decoration: underline' } } + { start: 5, end: 10, attrs: { fill: 'red', 'font-size': 30, rotate: '20' }}, + { start: 7, end: 15, attrs: { fill: 'blue' }}, + { start: 20, end: 30, attrs: { fill: 'blue', 'class': 'text-link', style: 'text-decoration: underline' }} ], includeAnnotationIndices: true }); svg.append(text); diff --git a/demo/vuejs/demo.js b/demo/vuejs/demo.js index 383eec664..d6d0d3309 100644 --- a/demo/vuejs/demo.js +++ b/demo/vuejs/demo.js @@ -62,13 +62,13 @@ var TaskComponent = { var taskElement = Vue.ref(null); var taskElementPosition = Vue.shallowRef({ x: 0, y: 0 }); - var taskElementStyle = Vue.computed(function () { + var taskElementStyle = Vue.computed(function() { return { top: (taskElementPosition.value.y || 0) + 'px', left: (taskElementPosition.value.x || 0) + 'px', transform: 'scale(' + props.scale + ')', transformOrigin: '0 0', - } + }; }); // Update task element position to match the graph Element View @@ -80,7 +80,7 @@ var TaskComponent = { } } - Vue.onMounted(function () { + Vue.onMounted(function() { // Resize the graph Element to match the task element ... graph.getCell(props.id).resize(taskElement.value.offsetWidth, taskElement.value.offsetHeight); // ... and update task element position afterwards @@ -89,13 +89,13 @@ var TaskComponent = { // React to changes of position/scale Vue.watch( - function () { + function() { return { position: props.position, scale: props.scale, }; }, - updateTaskElementPosition, + updateTaskElementPosition ); return { @@ -133,7 +133,7 @@ var JointPaperComponent = { Vue.provide('paperContext', paperContext); // Create JointJS Paper (after the paper element is available) - Vue.onMounted(function () { + Vue.onMounted(function() { paperContext.paper = new joint.dia.Paper({ el: paperElement.value, model: graph, @@ -151,13 +151,13 @@ var JointPaperComponent = { * too many updates and cause performance issues. */ var htmlElements = Vue.shallowRef( - graph.getElements().map(function (cell) { - return { id: cell.get('id'), position: cell.get('position')}; + graph.getElements().map(function(cell) { + return { id: cell.get('id'), position: cell.get('position') }; }) ); // Track positions of graph elements - graph.on('change:position', function (cell) { + graph.on('change:position', function(cell) { for (var i = 0; i < htmlElements.value.length; i += 1) { if (htmlElements.value[i].id === cell.get('id')) { htmlElements.value[i].position = cell.get('position'); @@ -169,8 +169,8 @@ var JointPaperComponent = { // React to changes of scale Vue.watch( - function () { return scale.value; }, - function (value) { + function() { return scale.value; }, + function(value) { var size = paperContext.paper.getComputedSize(); paperContext.paper.translate(0, 0); paperContext.paper.scale(value, value, size.width / 2, size.height / 2); @@ -224,8 +224,8 @@ var app = Vue.createApp({ graph.getCell('taskB').position(297, 100); graph.getCell('taskC').position(576, 100); - Object.entries(DATA.tasks).forEach(function ([taskId, task]) { - Object.entries(task).forEach(function ([key, value]) { + Object.entries(DATA.tasks).forEach(function([taskId, task]) { + Object.entries(task).forEach(function([key, value]) { handleTaskChange(taskId, key, value); }); }); diff --git a/docs/.eslintrc.js b/docs/.eslintrc.js new file mode 100644 index 000000000..d7d8f0117 --- /dev/null +++ b/docs/.eslintrc.js @@ -0,0 +1,33 @@ +module.exports = { + 'extends': [ + '../.eslintrc.js', + ], + 'globals': { + 'joint': true, + 'g': true, + 'V': true, + '$': true, + '_': true + }, + 'overrides': [{ + 'files': [ + 'demo/dia/Element/js/portZIndex.js', + 'demo/layout/DirectedGraph/js/clusters.js', + 'demo/layout/DirectedGraph/js/index.js', + 'demo/layout/Port/js/port.js', + 'demo/layout/Port/js/portRotationComp.js', + 'demo/layout/PortLabel/js/portLabel.js', + 'demo/shapes/shapes.devs.js' + ], + // Globals contained in HTML script, etc + 'globals': { + 'createPaper': true, + }, + 'rules': { + // Exceptions currently used in docs directory + 'no-redeclare': ['off'], + 'no-unused-vars': ['off'], + 'no-console': ['off'] + } + }] +}; diff --git a/docs/demo/layout/DirectedGraph/js/clusters.js b/docs/demo/layout/DirectedGraph/js/clusters.js index 7d1c5ad65..6e068dba5 100644 --- a/docs/demo/layout/DirectedGraph/js/clusters.js +++ b/docs/demo/layout/DirectedGraph/js/clusters.js @@ -25,7 +25,7 @@ function makeElement(attrs) { var el = new joint.shapes.basic.Rect({ size: { width: 30, height: 30 }, - attrs: { rect: { rx: 2, ry: 2, fill: '#31D0C6', stroke: '#4B4A67', 'stroke-width': 2 }, text: { text: 'rect', fill: 'white' } } + attrs: { rect: { rx: 2, ry: 2, fill: '#31D0C6', stroke: '#4B4A67', 'stroke-width': 2 }, text: { text: 'rect', fill: 'white' }} }); el.attr(attrs); return el; diff --git a/docs/demo/layout/Port/js/port.js b/docs/demo/layout/Port/js/port.js index 47a514dc2..0faf748c8 100644 --- a/docs/demo/layout/Port/js/port.js +++ b/docs/demo/layout/Port/js/port.js @@ -24,7 +24,7 @@ var g2Rect = new joint.shapes.basic.Rect({ return g.point({ x: index * 12, y: y + elBBox.height }); }); }, - label: { position: { name: 'manual', args: { attrs: { '.': { y: 40, 'text-anchor': 'middle' } } } } }, + label: { position: { name: 'manual', args: { attrs: { '.': { y: 40, 'text-anchor': 'middle' }}}}}, attrs: { rect: { fill: '#fe854f', width: 11 }, @@ -83,7 +83,7 @@ _.times(4, function() { _.times(24, function() { g2Rect.addPort({ group: 'reds' }); }); -g2Rect.addPort({ group: 'reds', attrs: { text: { text: 'fn: sin(x)' } } }); +g2Rect.addPort({ group: 'reds', attrs: { text: { text: 'fn: sin(x)' }}}); g2Rect.addPort({ group: 'greens', diff --git a/docs/demo/layout/Port/js/portRotationComp.js b/docs/demo/layout/Port/js/portRotationComp.js index 841dc50a9..92c26c240 100644 --- a/docs/demo/layout/Port/js/portRotationComp.js +++ b/docs/demo/layout/Port/js/portRotationComp.js @@ -41,7 +41,7 @@ var g6 = new joint.shapes.basic.Circle({ }); _.times(36, function(index) { - g6.addPort({ group: 'a', id: index + '', attrs: { text: { text: index } } }); + g6.addPort({ group: 'a', id: index + '', attrs: { text: { text: index }}}); }); paper6.model.addCell(g6); diff --git a/docs/demo/layout/PortLabel/js/portLabel.js b/docs/demo/layout/PortLabel/js/portLabel.js index 30fae2c7c..b11e0c77c 100644 --- a/docs/demo/layout/PortLabel/js/portLabel.js +++ b/docs/demo/layout/PortLabel/js/portLabel.js @@ -40,7 +40,7 @@ var g3 = new joint.shapes.basic.Circle({ _.times(10, function(index) { - g3.addPort({ attrs: { text: { text: 'L ' + index } }, group: 'a' }); + g3.addPort({ attrs: { text: { text: 'L ' + index }}, group: 'a' }); }); g3.addPort({ @@ -74,7 +74,7 @@ var g33 = new joint.shapes.basic.Rect({ name: 'top', args: { dr: 0, dx: 0, dy: -9 } }, - label: { position: { name: 'left', args: { offset: 12 } } }, + label: { position: { name: 'left', args: { offset: 12 }}}, attrs: { circle: { fill: '#ffffff', stroke: '#31d0c6', 'stroke-width': 2, r: 10 }, text: { fill: '#6a6c8a' } @@ -85,7 +85,7 @@ var g33 = new joint.shapes.basic.Rect({ }); _.times(3, function(index) { - g33.addPort({ attrs: { text: { text: 'L' + index }, circle: { magnet: true } }, group: 'a' }); + g33.addPort({ attrs: { text: { text: 'L' + index }, circle: { magnet: true }}, group: 'a' }); }); g33.addPort({ diff --git a/grunt/config/aliases.js b/grunt/config/aliases.js index 0f6f0c98c..eae8c3dad 100644 --- a/grunt/config/aliases.js +++ b/grunt/config/aliases.js @@ -58,7 +58,6 @@ module.exports = function(grunt) { 'shell:rollup-test-bundle', 'test:server', 'test:client', - 'test:code-style', 'ts:test' ], 'test:server': ['mochaTest:server'], @@ -77,7 +76,6 @@ module.exports = function(grunt) { 'qunit:vectorizer', 'qunit:geometry' ], - 'test:code-style': ['eslint'], 'test:coverage': ['test:src'], 'test:e2e': ['mochaTest:e2e'], 'test:e2e:all': [ diff --git a/grunt/config/compileDocs.js b/grunt/config/compileDocs.js index 24a7c47c9..2070017a4 100644 --- a/grunt/config/compileDocs.js +++ b/grunt/config/compileDocs.js @@ -81,4 +81,4 @@ module.exports = function(grunt) { ] } }; -} +}; diff --git a/grunt/config/concat.js b/grunt/config/concat.js index 5df831fec..1d8ee99d9 100644 --- a/grunt/config/concat.js +++ b/grunt/config/concat.js @@ -25,5 +25,5 @@ module.exports = function(grunt) { ) } } - } + }; }; diff --git a/grunt/config/copy.js b/grunt/config/copy.js index 183981944..6fe2b7ce6 100644 --- a/grunt/config/copy.js +++ b/grunt/config/copy.js @@ -94,5 +94,5 @@ module.exports = function(grunt) { { nonull: true, src: 'build/joint.css', dest: 'demo/ts-demo/vendor/joint.css' } ] } - } + }; }; diff --git a/grunt/config/eslint.js b/grunt/config/eslint.js deleted file mode 100644 index ed07592ad..000000000 --- a/grunt/config/eslint.js +++ /dev/null @@ -1,22 +0,0 @@ -module.exports = { - joint: { - src: [ - 'src/**/*.js', - 'src/**/*.mjs' - ], - options: { - configFile: '.eslintrc.js' - } - }, - test: { - src: [ - 'test/**/*.js', - '!test/ts/*.js', - '!test/**/lodash3/**' - ], - options: { - configFile: 'test/.eslintrc.js' - } - } -}; - diff --git a/grunt/config/karma.js b/grunt/config/karma.js index 0cd20f5a7..4481e116a 100644 --- a/grunt/config/karma.js +++ b/grunt/config/karma.js @@ -91,6 +91,6 @@ module.exports = function(grunt) { coverageReporter: karmaCoverageReporters('joint') } } - } + }; }; diff --git a/test/.eslintrc.js b/test/.eslintrc.js index 4b4dcadb1..2728aa1d1 100644 --- a/test/.eslintrc.js +++ b/test/.eslintrc.js @@ -1,5 +1,11 @@ module.exports = { - 'extends': '../.eslintrc.js', + 'extends': [ + '../.eslintrc.js', + ], + 'plugins': [ + '@typescript-eslint', + ], + 'parser': '@typescript-eslint/parser', 'env': { 'mocha': true }, @@ -14,5 +20,17 @@ module.exports = { 'sinon': true, 'blanket': true, 'simulate': true - } + }, + 'overrides': [{ + 'files': ['ts/*.ts'], + 'extends': [ + 'plugin:@typescript-eslint/recommended' + ], + 'rules': { + // Exceptions currently used test/ts + 'prefer-const': 'off', + 'no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': 'off' + } + }] }; diff --git a/tutorials/.eslintrc.js b/tutorials/.eslintrc.js new file mode 100644 index 000000000..d84835800 --- /dev/null +++ b/tutorials/.eslintrc.js @@ -0,0 +1,21 @@ +module.exports = { + 'extends': [ + '../.eslintrc.js', + ], + 'globals': { + 'joint': true, + 'g': true, + 'V': true, + '$': true, + '_': true + }, + 'overrides': [{ + 'files': [ + 'js/pipes.js' + ], + 'rules': { + // Exceptions currently used in tutorial directory + 'no-unused-vars': ['off'] + } + }] +}; diff --git a/tutorials/js/circle-constraint.js b/tutorials/js/circle-constraint.js index e6f8fc728..e781af038 100644 --- a/tutorials/js/circle-constraint.js +++ b/tutorials/js/circle-constraint.js @@ -42,10 +42,10 @@ position: constraint.intersectionWithLineFromCenterToPoint(g.point(100, 100)).offset(-20, -20), size: { width: 40, height: 40 }, attrs: { - text: { text: 'earth', 'font-size': 12, fill: 'white', style: { 'text-shadow': '1px 1px 1px black' } }, + text: { text: 'earth', 'font-size': 12, fill: 'white', style: { 'text-shadow': '1px 1px 1px black' }}, circle: { fill: '#2ECC71', stroke: '#27AE60', 'stroke-width': 1 } }, name: 'earth' }); graph.addCell(earth); -}()) +}()); diff --git a/tutorials/js/hierarchy-reparenting.js b/tutorials/js/hierarchy-reparenting.js index fb207abd3..29c0708db 100644 --- a/tutorials/js/hierarchy-reparenting.js +++ b/tutorials/js/hierarchy-reparenting.js @@ -1,53 +1,53 @@ (function() { -var graph = new joint.dia.Graph; -var paper = new joint.dia.Paper({ el: $('#paper-reparenting'), width: 650, height: 250, gridSize: 1, model: graph }); + var graph = new joint.dia.Graph; + var paper = new joint.dia.Paper({ el: $('#paper-reparenting'), width: 650, height: 250, gridSize: 1, model: graph }); -var r1 = new joint.shapes.basic.Rect({ - position: { x: 20, y: 20 }, - size: { width: 200, height: 200 }, - attrs: { rect: { fill: '#E74C3C' }, text: { text: 'El A' } } -}); -var r2 = new joint.shapes.basic.Rect({ - position: { x: 270, y: 30 }, - size: { width: 100, height: 80 }, - attrs: { rect: { fill: '#F1C40F' }, text: { text: 'El B' } } -}); + var r1 = new joint.shapes.basic.Rect({ + position: { x: 20, y: 20 }, + size: { width: 200, height: 200 }, + attrs: { rect: { fill: '#E74C3C' }, text: { text: 'El A' }} + }); + var r2 = new joint.shapes.basic.Rect({ + position: { x: 270, y: 30 }, + size: { width: 100, height: 80 }, + attrs: { rect: { fill: '#F1C40F' }, text: { text: 'El B' }} + }); -graph.addCells([r1, r2]); + graph.addCells([r1, r2]); -// First, unembed the cell that has just been grabbed by the user. -paper.on('cell:pointerdown', function(cellView, evt, x, y) { + // First, unembed the cell that has just been grabbed by the user. + paper.on('cell:pointerdown', function(cellView, evt, x, y) { - var cell = cellView.model; + var cell = cellView.model; - if (!cell.get('embeds') || cell.get('embeds').length === 0) { + if (!cell.get('embeds') || cell.get('embeds').length === 0) { // Show the dragged element above all the other cells (except when the // element is a parent). - cell.toFront(); - } + cell.toFront(); + } - if (cell.get('parent')) { - graph.getCell(cell.get('parent')).unembed(cell); - } -}); + if (cell.get('parent')) { + graph.getCell(cell.get('parent')).unembed(cell); + } + }); -// When the dragged cell is dropped over another cell, let it become a child of the -// element below. -paper.on('cell:pointerup', function(cellView, evt, x, y) { + // When the dragged cell is dropped over another cell, let it become a child of the + // element below. + paper.on('cell:pointerup', function(cellView, evt, x, y) { - var cell = cellView.model; - var cellViewsBelow = paper.findViewsFromPoint(cell.getBBox().center()); + var cell = cellView.model; + var cellViewsBelow = paper.findViewsFromPoint(cell.getBBox().center()); - if (cellViewsBelow.length) { + if (cellViewsBelow.length) { // Note that the findViewsFromPoint() returns the view for the `cell` itself. - var cellViewBelow = _.find(cellViewsBelow, function(c) { return c.model.id !== cell.id }); + var cellViewBelow = _.find(cellViewsBelow, function(c) { return c.model.id !== cell.id; }); - // Prevent recursive embedding. - if (cellViewBelow && cellViewBelow.model.get('parent') !== cell.id) { - cellViewBelow.model.embed(cell); + // Prevent recursive embedding. + if (cellViewBelow && cellViewBelow.model.get('parent') !== cell.id) { + cellViewBelow.model.embed(cell); + } } - } -}); + }); }()); \ No newline at end of file diff --git a/tutorials/js/pipes.js b/tutorials/js/pipes.js index 59321956f..6b7d4c3b8 100644 --- a/tutorials/js/pipes.js +++ b/tutorials/js/pipes.js @@ -103,8 +103,8 @@ var PatternLinkView = joint.dia.LinkView.extend({ var ctx = canvas.getContext('2d'); ctx.lineWidth = strokeWidth; - ctx.lineJoin = "round"; - ctx.lineCap = "round"; + ctx.lineJoin = 'round'; + ctx.lineCap = 'round'; // iterate over the points and execute the drawing function // for each segment @@ -169,7 +169,7 @@ var PatternLinkView = joint.dia.LinkView.extend({ ctx.stroke(); ctx.closePath(); - ctx.lineCap = "square"; + ctx.lineCap = 'square'; ctx.beginPath(); ctx.lineWidth = innerWidth;