From 8a8e921c17f92440392d47532bda51efcf5e43db Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sun, 19 Dec 2021 09:07:01 -0800 Subject: [PATCH] Fix eslint errors --- package.json | 2 +- packages/mindplot/package.json | 1 - .../src/components/ActionDispatcher.js | 2 +- .../mindplot/src/components/ControlPoint.js | 8 ++--- .../src/components/DesignerKeyboard.js | 6 ++-- .../src/components/LocalStorageManager.js | 2 +- packages/mindplot/src/components/MainTopic.js | 3 +- .../src/components/MultilineTextEditor.js | 8 +++-- .../src/components/PersistenceManager.js | 7 +++-- .../persistence/XMLSerializer_Beta.js | 2 ++ .../persistence/XMLSerializer_Pela.js | 1 + .../persistence/XMLSerializer_Tango.js | 7 +++-- .../src/components/widget/LinkEditor.js | 30 +++++++++---------- packages/mindplot/src/index.js | 1 - packages/web2d/.eslintrc.json | 6 +--- packages/web2d/babel.config.json | 1 - 16 files changed, 42 insertions(+), 45 deletions(-) diff --git a/package.json b/package.json index 78cd7640..0a90c48a 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "test:unit": "lerna run test:unit --stream", "test:integration": "lerna run test:integration --stream" }, - "private": true, + "private": false, "devDependencies": { "cypress": "^8.4.1", "husky": "4", diff --git a/packages/mindplot/package.json b/packages/mindplot/package.json index 36648cd6..8458495d 100644 --- a/packages/mindplot/package.json +++ b/packages/mindplot/package.json @@ -3,7 +3,6 @@ "version": "0.0.1", "description": "WiseMapping - Mindplot Canvas Library", "homepage": "http://www.wisemapping.org/", - "license": "ISC", "main": "dist/main.js", "directories": { "lib": "src", diff --git a/packages/mindplot/src/components/ActionDispatcher.js b/packages/mindplot/src/components/ActionDispatcher.js index f33917de..bb166439 100644 --- a/packages/mindplot/src/components/ActionDispatcher.js +++ b/packages/mindplot/src/components/ActionDispatcher.js @@ -1,4 +1,4 @@ -/* eslint-disable class-methods-use-this */ +/* eslint-disable no-unused-vars */ /* * Copyright [2015] [wisemapping] * diff --git a/packages/mindplot/src/components/ControlPoint.js b/packages/mindplot/src/components/ControlPoint.js index d0c7fbc5..9da65cdc 100644 --- a/packages/mindplot/src/components/ControlPoint.js +++ b/packages/mindplot/src/components/ControlPoint.js @@ -117,13 +117,13 @@ class ControlPoint { _mouseDown(event, point, me) { if (!this._isBinded) { this._isBinded = true; - this._mouseMoveFunction = function mouseMoveFunction(event) { - me._mouseMoveEvent(event, point, me); + this._mouseMoveFunction = (e) => { + me._mouseMoveEvent(e, point, me); }; this._workspace.getScreenManager().addEvent('mousemove', this._mouseMoveFunction); - this._mouseUpFunction = function mouseUpFunction(event) { - me._mouseUp(event, point, me); + this._mouseUpFunction = (e) => { + me._mouseUp(e, point, me); }; this._workspace.getScreenManager().addEvent('mouseup', this._mouseUpFunction); } diff --git a/packages/mindplot/src/components/DesignerKeyboard.js b/packages/mindplot/src/components/DesignerKeyboard.js index 7da8173a..3b8c45c0 100644 --- a/packages/mindplot/src/components/DesignerKeyboard.js +++ b/packages/mindplot/src/components/DesignerKeyboard.js @@ -244,14 +244,14 @@ class DesignerKeyboard extends Keyboard { return; } // Sometimes Firefox doesn't contain keyCode value - if (event.key && event.keyCode == 0) { + if (event.key && event.keyCode === 0) { keyCode = event.charCode; } else { keyCode = event.keyCode; } - const specialKey = jQuery.hotkeys.specialKeys[keyCode]; - if (['enter', 'capslock'].indexOf(specialKey) == -1 && !jQuery.hotkeys.shiftNums[keyCode]) { + const specialKey = $.hotkeys.specialKeys[keyCode]; + if (['enter', 'capslock'].indexOf(specialKey) === -1 && !$.hotkeys.shiftNums[keyCode]) { const nodes = designer.getModel().filterSelectedTopics(); if (nodes.length > 0) { // If a modifier is press, the key selected must be ignored. diff --git a/packages/mindplot/src/components/LocalStorageManager.js b/packages/mindplot/src/components/LocalStorageManager.js index 13a1998e..ce8b28bb 100644 --- a/packages/mindplot/src/components/LocalStorageManager.js +++ b/packages/mindplot/src/components/LocalStorageManager.js @@ -52,7 +52,7 @@ class LocalStorageManager extends PersistenceManager { } } - return jQuery.parseXML(xml); + return $.parseXML(xml); } unlockMap(mindmap) { diff --git a/packages/mindplot/src/components/MainTopic.js b/packages/mindplot/src/components/MainTopic.js index 02df9a37..12c3f37c 100644 --- a/packages/mindplot/src/components/MainTopic.js +++ b/packages/mindplot/src/components/MainTopic.js @@ -71,6 +71,7 @@ class MainTopic extends Topic { } /** */ + // eslint-disable-next-line no-unused-vars updateTopicShape(targetTopic, workspace) { // Change figure based on the connected topic ... const model = this.getModel(); @@ -87,8 +88,6 @@ class MainTopic extends Topic { /** */ disconnect(workspace) { super.disconnect(workspace); - const size = this.getSize(); - const model = this.getModel(); let shapeType = model.getShapeType(); if (!$defined(shapeType)) { diff --git a/packages/mindplot/src/components/MultilineTextEditor.js b/packages/mindplot/src/components/MultilineTextEditor.js index f135c43a..2008d765 100644 --- a/packages/mindplot/src/components/MultilineTextEditor.js +++ b/packages/mindplot/src/components/MultilineTextEditor.js @@ -57,7 +57,7 @@ class MultilineTextEditor extends Events { const textareaElem = this._getTextareaElem(); const me = this; textareaElem.on('keydown', function keydown(event) { - switch (jQuery.hotkeys.specialKeys[event.keyCode]) { + switch ($.hotkeys.specialKeys[event.keyCode]) { case 'esc': me.close(false); break; @@ -90,7 +90,7 @@ class MultilineTextEditor extends Events { me.close(true); } break; - case 'tab': + case 'tab': { event.preventDefault(); const start = $(this).get(0).selectionStart; const end = $(this).get(0).selectionEnd; @@ -99,8 +99,10 @@ class MultilineTextEditor extends Events { $(this).val(`${$(this).val().substring(0, start)}\t${$(this).val().substring(end)}`); // put caret at right position again - $(this).get(0).selectionStart = $(this).get(0).selectionEnd = start + 1; + $(this).get(0).selectionEnd = start + 1; + $(this).get(0).selectionStart = $(this).get(0).selectionEnd; break; + } default: // No actions... break; diff --git a/packages/mindplot/src/components/PersistenceManager.js b/packages/mindplot/src/components/PersistenceManager.js index b5d70635..4e356333 100644 --- a/packages/mindplot/src/components/PersistenceManager.js +++ b/packages/mindplot/src/components/PersistenceManager.js @@ -1,3 +1,4 @@ +/* eslint-disable no-unused-vars */ /* * Copyright [2015] [wisemapping] * @@ -34,7 +35,7 @@ class PersistenceManager { try { this.saveMapXml(mapId, mapXml, pref, saveHistory, events, sync); } catch (e) { - console.log(e); + console.error(e); events.onError(this._buildError()); } } @@ -62,11 +63,11 @@ class PersistenceManager { } } -PersistenceManager.init = function (instance) { +PersistenceManager.init = function init(instance) { PersistenceManager._instance = instance; }; -PersistenceManager.getInstance = function () { +PersistenceManager.getInstance = function getInstance() { return PersistenceManager._instance; }; diff --git a/packages/mindplot/src/components/persistence/XMLSerializer_Beta.js b/packages/mindplot/src/components/persistence/XMLSerializer_Beta.js index ee292851..186d2ccf 100644 --- a/packages/mindplot/src/components/persistence/XMLSerializer_Beta.js +++ b/packages/mindplot/src/components/persistence/XMLSerializer_Beta.js @@ -22,6 +22,7 @@ import Mindmap from '../model/Mindmap'; import INodeModel from '../model/INodeModel'; import TopicFeature from '../TopicFeature'; +// eslint-disable-next-line camelcase class XMLSerializer_Beta { toXML(mindmap) { $assert(mindmap, 'Can not save a null mindmap'); @@ -321,4 +322,5 @@ class XMLSerializer_Beta { XMLSerializer_Beta.MAP_ROOT_NODE = 'map'; +// eslint-disable-next-line camelcase export default XMLSerializer_Beta; diff --git a/packages/mindplot/src/components/persistence/XMLSerializer_Pela.js b/packages/mindplot/src/components/persistence/XMLSerializer_Pela.js index bc05a2b4..bd67e74e 100644 --- a/packages/mindplot/src/components/persistence/XMLSerializer_Pela.js +++ b/packages/mindplot/src/components/persistence/XMLSerializer_Pela.js @@ -507,4 +507,5 @@ class XMLSerializer_Pela { */ XMLSerializer_Pela.MAP_ROOT_NODE = 'map'; +// eslint-disable-next-line camelcase export default XMLSerializer_Pela; diff --git a/packages/mindplot/src/components/persistence/XMLSerializer_Tango.js b/packages/mindplot/src/components/persistence/XMLSerializer_Tango.js index caad150f..9884732f 100644 --- a/packages/mindplot/src/components/persistence/XMLSerializer_Tango.js +++ b/packages/mindplot/src/components/persistence/XMLSerializer_Tango.js @@ -15,15 +15,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import XMLSerializer_Pela from './XMLSerializer_Pela'; +import XMLSerializer from './XMLSerializer_Pela'; /** * This serializer works exactly the same way as for the former version Pela * {@link mindplot.persistence.XMLSerializer_Pela} * @class - * @extends mindplot.persistence.XMLSerializer_Pela */ -class XMLSerializer_Tango extends XMLSerializer_Pela { +// eslint-disable-next-line camelcase +class XMLSerializer_Tango extends XMLSerializer { } +// eslint-disable-next-line camelcase export default XMLSerializer_Tango; diff --git a/packages/mindplot/src/components/widget/LinkEditor.js b/packages/mindplot/src/components/widget/LinkEditor.js index f11000bc..8a4c2fa7 100644 --- a/packages/mindplot/src/components/widget/LinkEditor.js +++ b/packages/mindplot/src/components/widget/LinkEditor.js @@ -90,23 +90,21 @@ class LinkEditor extends BootstrapDialog { this.form.append(section); const me = this; - this.form.unbind('submit').submit( - function (event) { - event.preventDefault(); - if (me.checkURL(input.val())) { - me.cleanError(); - const inputValue = input.val(); - if (inputValue != null && $.trim(inputValue) != '') { - model.setValue(inputValue); - } - me.close(); - this.formSubmitted = true; - } else { - me.alertError($msg('URL_ERROR')); - event.stopPropagation(); + this.form.unbind('submit').submit((event) => { + event.preventDefault(); + if (me.checkURL(input.val())) { + me.cleanError(); + const inputValue = input.val(); + if (inputValue != null && $.trim(inputValue) !== '') { + model.setValue(inputValue); } - }, - ); + me.close(); + this.formSubmitted = true; + } else { + me.alertError($msg('URL_ERROR')); + event.stopPropagation(); + } + }); result.append(this.form); return result; diff --git a/packages/mindplot/src/index.js b/packages/mindplot/src/index.js index 3536d7a7..25cc1074 100644 --- a/packages/mindplot/src/index.js +++ b/packages/mindplot/src/index.js @@ -1,4 +1,3 @@ -/* eslint-disable no-unused-vars */ import Mindmap from './components/model/Mindmap'; import PersistenceManager from './components/PersistenceManager'; import Designer from './components/Designer'; diff --git a/packages/web2d/.eslintrc.json b/packages/web2d/.eslintrc.json index a56a0f62..b1715361 100644 --- a/packages/web2d/.eslintrc.json +++ b/packages/web2d/.eslintrc.json @@ -1,17 +1,13 @@ { "env": { "browser": true, - "commonjs": true + "es6": true }, "extends": [ "airbnb-base", "plugin:cypress/recommended" ], - "globals":{ - "Class": "readonly" - }, "rules": { - "no-underscore-dangle": "off", "no-restricted-syntax": "off", "no-underscore-dangle": "off", "no-plusplus": "off", diff --git a/packages/web2d/babel.config.json b/packages/web2d/babel.config.json index 8dfc163a..e79d68f4 100644 --- a/packages/web2d/babel.config.json +++ b/packages/web2d/babel.config.json @@ -11,6 +11,5 @@ } ] ], - "plugins": ["@babel/plugin-transform-modules-commonjs"], "sourceType": "unambiguous" }