Apply eslint --fix

This commit is contained in:
Paulo Gustavo Veiga 2021-12-19 08:06:42 -08:00
parent 6cb88b9303
commit 38f4144c67
40 changed files with 2275 additions and 2001 deletions

View File

@ -18,7 +18,6 @@
import Icon from './Icon';
class ActionIcon extends Icon {
constructor(topic, url) {
super(url);
this._node = topic;

View File

@ -172,12 +172,6 @@ class Designer extends Events {
this._actionDispatcher.addTopics([model], [centralTopic.getId()]);
}
});
// Register mouse drag and drop event ...
function noopHandler(evt) {
evt.stopPropagation();
evt.preventDefault();
}
}
/**

View File

@ -16,8 +16,8 @@
* limitations under the License.
*/
import { $assert } from '@wisemapping/core-js';
import Keyboard from './Keyboard';
import $ from 'jquery';
import Keyboard from './Keyboard';
class DesignerKeyboard extends Keyboard {
constructor(designer) {

View File

@ -103,7 +103,6 @@ class DragConnector {
_isVerticallyAligned(targetSize, targetPosition, sourcePosition) {
return Math.abs(sourcePosition.y - targetPosition.y) < targetSize.height / 2;
}
}
DragConnector.MAX_VERTICAL_CONNECTION_TOLERANCE = 80;

View File

@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $assert } from "@wisemapping/core-js";
import { $assert } from '@wisemapping/core-js';
import * as web2d from '@wisemapping/web2d';
class Icon {

View File

@ -31,7 +31,7 @@ class ImageIcon extends Icon {
this._topicId = topic.getId();
this._featureModel = iconModel;
if (!readOnly) {
// Icon
const image = this.getImage();

View File

@ -19,7 +19,6 @@ import { $assert, innerXML } from '@wisemapping/core-js';
import XMLSerializerFactory from './persistence/XMLSerializerFactory';
class PersistenceManager {
save(mindmap, editorProperties, saveHistory, events, sync) {
$assert(mindmap, 'mindmap can not be null');
$assert(editorProperties, 'editorProperties can not be null');
@ -38,29 +37,29 @@ class PersistenceManager {
console.log(e);
events.onError(this._buildError());
}
}
}
load(mapId) {
$assert(mapId, 'mapId can not be null');
const domDocument = this.loadMapDom(mapId);
return PersistenceManager.loadFromDom(mapId, domDocument);
}
}
discardChanges(mapId) {
throw new Error('Method must be implemented');
}
}
loadMapDom(mapId) {
throw new Error('Method must be implemented');
}
}
saveMapXml(mapId, mapXml, pref, saveHistory, events, sync) {
throw new Error('Method must be implemented');
}
}
unlockMap(mindmap) {
throw new Error('Method must be implemented');
}
}
}
PersistenceManager.init = function (instance) {

View File

@ -262,6 +262,4 @@ class StandaloneActionDispatcher extends ActionDispatcher {
}
}
export default StandaloneActionDispatcher ;
export default StandaloneActionDispatcher;

View File

@ -26,8 +26,7 @@ const TopicEvent = {
};
class TopicEventDispatcher extends Events {
constructor(readOnly)
{
constructor(readOnly) {
super();
this._readOnly = readOnly;
this._activeEditor = null;

View File

@ -67,6 +67,7 @@ const TopicFeature = {
$assert(attributes, 'attributes can not be null');
const { model } = TopicFeature._featuresMetadataById.filter((elem) => elem.id === type)[0];
// eslint-disable-next-line new-cap
return new model(attributes);
},
@ -83,6 +84,7 @@ const TopicFeature = {
$assert(model, 'model can not be null');
const { icon } = TopicFeature._featuresMetadataById.filter((elem) => elem.id === model.getType())[0];
// eslint-disable-next-line new-cap
return new icon(topic, model, readOnly);
},
};

View File

@ -80,9 +80,9 @@ class GenericFunctionCommand extends Command {
if (this.applied) {
const topics = commandContext.findTopics(this._topicsId);
topics.forEach( ((topic, index) => {
topics.forEach(((topic, index) => {
this._commandFunc(topic, this._oldValues[index]);
}).bind(this));
}));
this.applied = false;
this._oldValues = [];

View File

@ -86,7 +86,7 @@ class BalancedSorter extends AbstractBasicSorter {
: right.length - left.length > 0
? 1
: 0;
var direction = order % 2 == 0 ? 1 : -1;
const direction = order % 2 == 0 ? 1 : -1;
// Exclude the dragged node (if set)
const children = this._getChildrenForOrder(parent, graph, order).filter((child) => child !== node);

View File

@ -100,7 +100,7 @@ class RootedTreeSet {
const node = this.find(nodeId);
$assert(node._parent, 'Node is not connected');
node._parent._children = node._parent._children.filter((n)=> node !== n);
node._parent._children = node._parent._children.filter((n) => node !== n);
this._rootNodes.push(node);
node._parent = null;
}
@ -429,9 +429,7 @@ class RootedTreeSet {
// direct descendants of the root that do not contain the node and are on the same side
// and on the direction of the offset
const rootNode = this.getRootNode(node);
const branches = this.getChildren(rootNode).filter(((child) => {
return this._find(node.getId(), child);
}).bind(this));
const branches = this.getChildren(rootNode).filter(((child) => this._find(node.getId(), child)));
const branch = branches[0];
const rootDescendants = this.getSiblings(branch).filter((sibling) => {

View File

@ -229,7 +229,7 @@ class SymmetricSorter extends AbstractBasicSorter {
position: child.getPosition(),
width: child.getSize().width,
height: this._computeChildrenHeight(treeSet, child),
})).bind(this)).reverse();
}))).reverse();
// Compute the center of the branch ...
let totalHeight = 0;

View File

@ -1,9 +1,8 @@
import $ from 'jquery';
import Options from '../../Options';
import { $msg } from '../../Messages';
import $ from 'jquery';
class BootstrapDialog extends Options {
constructor(title, options) {
super();
this.options = {
@ -14,7 +13,7 @@ class BootstrapDialog extends Options {
errorMessage: false,
onEventData: {},
};
this.setOptions(options);
this.options.onEventData.dialog = this;
this._native = $('<div class="modal fade" tabindex="-1"></div>').append('<div class="modal-dialog"></div>');
@ -84,6 +83,7 @@ class BootstrapDialog extends Options {
}
onDialogShown() {}
onRemoveClick(event) {
throw 'Unsupported operation';
}

View File

@ -1,5 +1,5 @@
import BootstrapDialog from './BootstrapDialog';
import { $assert, $defined } from '@wisemapping/core-js';
import BootstrapDialog from './BootstrapDialog';
class BootstrapDialogRequest extends BootstrapDialog {
constructor(url, title, options) {
@ -46,4 +46,4 @@ class BootstrapDialogRequest extends BootstrapDialog {
}
}
export default BootstrapDialogRequest;
export default BootstrapDialogRequest;

View File

@ -46,7 +46,6 @@ class FeatureModel {
/** */
setAttributes(attributes) {
Object.keys(attributes).forEach((attr) => {
const funName = `set${FeatureModel.capitalize(attr)}`;
const value = attributes[attr];

View File

@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $assert } from "@wisemapping/core-js";
import { $assert } from '@wisemapping/core-js';
import FeatureModel from './FeatureModel';
class NoteModel extends FeatureModel {

View File

@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $assert, $defined } from '@wisemapping/core-js';
import ConnectionLine from '../ConnectionLine';
import { $assert, $defined } from "@wisemapping/core-js";
class RelationshipModel {
constructor(sourceTopicId, targetTopicId) {

View File

@ -17,12 +17,12 @@
*/
import { $assert, $defined } from '@wisemapping/core-js';
import ModelCodeName from './ModelCodeName';
import XMLSerializer_Pela from './XMLSerializer_Pela';
import XMLSerializer from './XMLSerializer_Pela';
class Beta2PelaMigrator {
constructor(betaSerializer) {
this._betaSerializer = betaSerializer;
this._pelaSerializer = new XMLSerializer_Pela();
this._pelaSerializer = new XMLSerializer();
}
toXML(mindmap) {

View File

@ -16,13 +16,13 @@
* limitations under the License.
*/
import { $assert, $defined } from '@wisemapping/core-js';
import XMLSerializer_Tango from './XMLSerializer_Tango';
import XMLSerializer from './XMLSerializer_Tango';
import ModelCodeName from './ModelCodeName';
class Pela2TangoMigrator {
constructor(pelaSerializer) {
this._pelaSerializer = pelaSerializer;
this._tangoSerializer = new XMLSerializer_Tango();
this._tangoSerializer = new XMLSerializer();
}
toXML(mindmap) {

View File

@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $defined } from "@wisemapping/core-js";
import { $defined } from '@wisemapping/core-js';
import ModelCodeName from './ModelCodeName';
import Beta2PelaMigrator from './Beta2PelaMigrator';
import Pela2TangoMigrator from './Pela2TangoMigrator';

View File

@ -14,7 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $defined, $assert, createDocument, innerXML } from '@wisemapping/core-js';
import {
$defined, $assert, createDocument, innerXML,
} from '@wisemapping/core-js';
import ModelCodeName from './ModelCodeName';
import Mindmap from '../model/Mindmap';
import INodeModel from '../model/INodeModel';

View File

@ -23,7 +23,7 @@ import XMLSerializer_Pela from './XMLSerializer_Pela';
* @class
* @extends mindplot.persistence.XMLSerializer_Pela
*/
class XMLSerializer_Tango extends XMLSerializer_Pela{
};
class XMLSerializer_Tango extends XMLSerializer_Pela {
}
export default XMLSerializer_Tango;

View File

@ -69,7 +69,7 @@ class FloatingTip extends Events {
if (this.addEvent) {
for (const option in options) {
if (typeof (options[option]) != 'function' || !(/^on[A-Z]/).test(option)) {
if (typeof (options[option]) !== 'function' || !(/^on[A-Z]/).test(option)) {
continue;
}
this.addEvent(option, options[option]);

View File

@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import ListToolbarPanel from './ListToolbarPanel';
import $ from 'jquery';
import ListToolbarPanel from './ListToolbarPanel';
class FontSizePanel extends ListToolbarPanel {
// eslint-disable-next-line class-methods-use-this

View File

@ -34,8 +34,6 @@ class IconPanel extends ToolbarPaneItem {
for (let i = 0; i < ImageIcon.prototype.ICON_FAMILIES.length; i += 1) {
const familyIcons = ImageIcon.prototype.ICON_FAMILIES[i].icons;
for (let j = 0; j < familyIcons.length; j += 1) {
// @TODO: This is a bug, for some reason is working because is a var. This must change to let.
var familyContent;
if ((count % 12) == 0) {

View File

@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { $assert } from "@wisemapping/core-js";
import { $assert } from '@wisemapping/core-js';
import $ from 'jquery';
import { $msg } from '../Messages';
import FloatingTip from './FloatingTip';

View File

@ -225,8 +225,8 @@ class Menu extends IMenu {
this._addButton('print', false, false, () => {
me.save(saveElem, designer, false);
const baseUrl = window.location.href.substring(0, window.location.href.lastIndexOf('c/maps/'));
window.open(`${baseUrl}c/maps/${mapId}/print`);
const url = window.location.href.substring(0, window.location.href.lastIndexOf('c/maps/'));
window.open(`${url}c/maps/${mapId}/print`);
});
Menu._registerTooltip('print', $msg('PRINT'));
@ -479,7 +479,7 @@ class Menu extends IMenu {
shortcut = navigator.appVersion.indexOf('Mac') !== -1 ? shortcut.replace('meta+', '⌘') : shortcut.replace('meta+', 'ctrl+');
tooltip = `${tooltip} (${shortcut})`;
}
new KeyboardShortcutTooltip($(`#${buttonId}`), tooltip);
return new KeyboardShortcutTooltip($(`#${buttonId}`), tooltip);
}
}
}

View File

@ -16,8 +16,8 @@
* limitations under the License.
*/
import { $assert } from '@wisemapping/core-js';
import BootstrapDialog from '../libraries/bootstrap/BootstrapDialog';
import $ from 'jquery';
import BootstrapDialog from '../libraries/bootstrap/BootstrapDialog';
import { $msg } from '../Messages';
class NoteEditor extends BootstrapDialog {

View File

@ -513,12 +513,11 @@ class FreeTestSuite extends TestSuite {
siblings.forEach((sibling) => {
this._branchesOverlap(child, sibling, heightById);
});
});
children.forEach(((child) => {
OriginalLayout._assertBranchCollision(treeSet, child, heightById);
}).bind(this));
}));
}
static _branchesOverlap(branchA, branchB, heightById) {

View File

@ -20,6 +20,7 @@ import $ from 'jquery';
import { $assert } from '@wisemapping/core-js';
import LayoutManager from '../../../src/components/layout/LayoutManager';
import ChildrenSorterStrategy from '../../../src/components/layout/ChildrenSorterStrategy';
class TestSuite extends ChildrenSorterStrategy {
constructor() {
super();
@ -91,7 +92,7 @@ class TestSuite extends ChildrenSorterStrategy {
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
manager.addNode(3, TestSuite.NODE_SIZE, position).connectNode(1, 3, 0);
manager.addNode(5, TestSuite.NODE_SIZE, position).connectNode(3, 5, 0);
manager.addNode(6, { width: 140, height: 130 } , position).connectNode(3, 6, 1);
manager.addNode(6, { width: 140, height: 130 }, position).connectNode(3, 6, 1);
manager.addNode(7, TestSuite.NODE_SIZE, position).connectNode(6, 7, 0);
manager.addNode(8, TestSuite.NODE_SIZE, position).connectNode(7, 8, 0);
manager.addNode(9, TestSuite.NODE_SIZE, position).connectNode(7, 9, 1);
@ -105,10 +106,10 @@ class TestSuite extends ChildrenSorterStrategy {
manager.addNode(17, TestSuite.NODE_SIZE, position).connectNode(7, 17, 9);
manager.addNode(29, TestSuite.NODE_SIZE, position).connectNode(6, 29, 1);
manager.addNode(30, TestSuite.NODE_SIZE, position).connectNode(6, 30, 2);
manager.addNode(31, { width: 100, height: 50 } , position).connectNode(6, 31, 3);
manager.addNode(31, { width: 100, height: 50 }, position).connectNode(6, 31, 3);
manager.addNode(4, TestSuite.NODE_SIZE, position).connectNode(1, 4, 1);
manager.addNode(18, { width: 80, height: 70 } , position).connectNode(4, 18, 0);
manager.addNode(18, { width: 80, height: 70 }, position).connectNode(4, 18, 0);
manager.addNode(19, TestSuite.NODE_SIZE, position).connectNode(18, 19, 0);
manager.addNode(20, TestSuite.NODE_SIZE, position).connectNode(19, 20, 0);
manager.addNode(21, TestSuite.NODE_SIZE, position).connectNode(20, 21, 0);
@ -117,11 +118,11 @@ class TestSuite extends ChildrenSorterStrategy {
manager.addNode(22, TestSuite.NODE_SIZE, position).connectNode(2, 22, 0);
manager.addNode(24, TestSuite.NODE_SIZE, position).connectNode(22, 24, 0);
manager.addNode(23, { width: 80, height: 50 } , position).connectNode(2, 23, 1);
manager.addNode(25, { width: 80, height: 40 } , position).connectNode(23, 25, 0);
manager.addNode(26, { width: 80, height: 80 } , position).connectNode(25, 26, 0);
manager.addNode(23, { width: 80, height: 50 }, position).connectNode(2, 23, 1);
manager.addNode(25, { width: 80, height: 40 }, position).connectNode(23, 25, 0);
manager.addNode(26, { width: 80, height: 80 }, position).connectNode(25, 26, 0);
manager.addNode(27, TestSuite.NODE_SIZE, position).connectNode(26, 27, 0);
manager.addNode(28, { width: 80, height: 80 } , position).connectNode(27, 28, 0);
manager.addNode(28, { width: 80, height: 80 }, position).connectNode(27, 28, 0);
// manager.layout();
// manager.plot("testBaselineAligned1", {width:1600,height:800});
@ -135,7 +136,7 @@ class TestSuite extends ChildrenSorterStrategy {
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
manager.addNode(1, TestSuite.NODE_SIZE, position).connectNode(0, 1, 0);
manager.addNode(2, { width: 130, height: 200 } , position).connectNode(1, 2, 0);
manager.addNode(2, { width: 130, height: 200 }, position).connectNode(1, 2, 0);
manager.addNode(3, TestSuite.NODE_SIZE, position).connectNode(2, 3, 0);
manager.addNode(4, TestSuite.NODE_SIZE, position).connectNode(2, 4, 1);
manager.addNode(5, TestSuite.NODE_SIZE, position).connectNode(2, 5, 2);
@ -431,17 +432,17 @@ class TestSuite extends ChildrenSorterStrategy {
const position = { x: 0, y: 0 };
const manager = new LayoutManager(0, TestSuite.ROOT_NODE_SIZE);
manager.addNode(1, { width: 60, height: 60 } ,position);
manager.addNode(1, { width: 60, height: 60 }, position);
manager.addNode(2, TestSuite.NODE_SIZE, position);
manager.addNode(3, { width: 260, height: 30 } ,position);
manager.addNode(3, { width: 260, height: 30 }, position);
manager.addNode(4, TestSuite.NODE_SIZE, position);
manager.addNode(5, TestSuite.NODE_SIZE, position);
manager.addNode(7, { width: 80, height: 80 } ,position);
manager.addNode(7, { width: 80, height: 80 }, position);
manager.addNode(8, TestSuite.NODE_SIZE, position);
manager.addNode(9, { width: 30, height: 30 } ,position);
manager.addNode(9, { width: 30, height: 30 }, position);
manager.addNode(10, TestSuite.NODE_SIZE, position);
manager.addNode(11, TestSuite.NODE_SIZE, position);
manager.addNode(12, { width: 100, height: 70 } ,position);
manager.addNode(12, { width: 100, height: 70 }, position);
manager.addNode(13, TestSuite.NODE_SIZE, position);
manager.addNode(14, TestSuite.NODE_SIZE, position);
manager.addNode(15, TestSuite.NODE_SIZE, position);

View File

@ -10,8 +10,8 @@ global.Raphael = Raphael;
global.Raphael.fn.drawGrid = drawGrid;
window.addEventListener('DOMContentLoaded', () => {
new TestSuite();
new BalancedTestSuite();
new SymmetricTestSuite();
new FreeTestSuite();
new TestSuite();
new BalancedTestSuite();
new SymmetricTestSuite();
new FreeTestSuite();
});

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
export function drawGrid (x, y, w, h, wv, hv, color) {
export function drawGrid(x, y, w, h, wv, hv, color) {
color = color || '#999';
let path = ['M', x, y, 'L', x + w, y, x + w, y + h, x, y + h, x, y];
const rowHeight = h / hv;
@ -26,4 +26,4 @@ export function drawGrid (x, y, w, h, wv, hv, color) {
}
}
return this.path;
};
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,6 @@ import Events from '../../src/components/Events';
describe('Events class suite', () => {
class TestClass extends Events {
getEvents() {
return this.$events;
}