remove some non standard lint rules

This commit is contained in:
JFH
2021-01-31 23:16:43 +01:00
parent e02fddb224
commit 47c365bf2a
298 changed files with 2110 additions and 29712 deletions

View File

@@ -49,7 +49,7 @@ const seg = path.createSVGPathSegLinetoAbs(5, 5);
try {
seglist.replaceItem(seg, 1);
return true;
} catch (err) {}
}catch (err) {/* empty */}
return false;
}());
@@ -61,7 +61,7 @@ const seg = path.createSVGPathSegLinetoAbs(5, 5);
try {
seglist.insertItemBefore(seg, 1);
return true;
} catch (err) {}
}catch (err) {/* empty */}
return false;
}());

View File

@@ -55,7 +55,6 @@ let typeMap_ = {};
* @returns {Integer} The number of digits number should be rounded to
*/
/* eslint-disable jsdoc/valid-types */
/**
* @typedef {PlainObject} module:units.TypeMap
* @property {Float} em
@@ -68,7 +67,6 @@ let typeMap_ = {};
* @property {Integer} px
* @property {0} %
*/
/* eslint-enable jsdoc/valid-types */
/**
* Initializes this module.
@@ -301,7 +299,7 @@ export const isValidUnit = function (attr, val, selectedElement) {
try {
const elem = elementContainer_.getElement(val);
result = (!elem || elem === selectedElement);
} catch (e) {}
} catch (e) {/* empty fn */}
return result;
}
return true;

View File

@@ -1,6 +1,5 @@
/* globals $ */
// eslint-disable-next-line node/no-unpublished-import
import deparam from 'deparam';
/**
@@ -259,7 +258,7 @@ export default class ConfigObj {
if (this.urldata.extensions) {
// For security reasons, disallow cross-domain or cross-folder
// extensions via URL
this.urldata.extensions = this.urldata.extensions.match(/[:/\\]/)
this.urldata.extensions = (/[:/\\]/).test(this.urldata.extensions)
? ''
: this.urldata.extensions.split(',');
}
@@ -326,7 +325,7 @@ export default class ConfigObj {
loadContentAndPrefs () {
if (!this.curConfig.forceStorage &&
(this.curConfig.noStorageOnLoad ||
!document.cookie.match(/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/)
!(/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/).test(document.cookie)
)
) {
return;
@@ -336,7 +335,7 @@ export default class ConfigObj {
if (this.editor.storage && // Cookies do not have enough available memory to hold large documents
(this.curConfig.forceStorage ||
(!this.curConfig.noStorageOnLoad &&
document.cookie.match(/(?:^|;\s*)svgeditstore=prefsAndContent/))
(/(?:^|;\s*)svgeditstore=prefsAndContent/).test(document.cookie))
)
) {
const name = 'svgedit-' + this.curConfig.canvasName;

View File

@@ -38,7 +38,7 @@ const readySignal = () => {
cancelable: true
});
w.document.documentElement.dispatchEvent(svgEditorReadyEvent);
} catch (e) {}
} catch (e) {/* empty fn */}
}
};
@@ -91,7 +91,6 @@ class EditorStartup {
exportDialog.setAttribute('id', 'se-export-dialog');
document.body.append(exportDialog);
} catch (err) {
// eslint-disable-next-line no-console
console.error(err);
}
@@ -758,7 +757,7 @@ class EditorStartup {
return this.addExtension(name, (initfn && initfn.bind(this)), {$, langParam});
} catch (err) {
// Todo: Add config to alert any errors
console.error('Extension failed to load: ' + extname + '; ', err); // eslint-disable-line no-console
console.error('Extension failed to load: ' + extname + '; ', err);
return undefined;
}
})
@@ -781,7 +780,7 @@ class EditorStartup {
return this.addExtension(name, (initfn && initfn.bind(this)), {$, langParam});
} catch (err) {
// Todo: Add config to alert any errors
console.error('Extension failed to load: ' + extPathName + '; ', err); // eslint-disable-line no-console
console.error('Extension failed to load: ' + extPathName + '; ', err);
return undefined;
}
})
@@ -817,7 +816,7 @@ class EditorStartup {
this.svgCanvas.call('extensions_added');
} catch (err) {
// Todo: Report errors through the UI
console.log(err); // eslint-disable-line no-console
console.log(err);
}
}
@@ -828,7 +827,7 @@ class EditorStartup {
* @fires module:svgcanvas.SvgCanvas#event:message
* @returns {void}
*/
messageListener ({data, origin}) { // eslint-disable-line no-shadow
messageListener ({data, origin}) {
// console.log('data, origin, extensionsAdded', data, origin, extensionsAdded);
const messageObj = {data, origin};
if (!this.extensionsAdded) {

View File

@@ -1,4 +1,3 @@
/* eslint-disable unicorn/prefer-dom-node-append */
/**
* @file jGraduate 0.4
*
@@ -23,7 +22,6 @@
* We have to rewrite it as a pure webcomponent.
*/
/* eslint-disable jsdoc/require-property */
/**
* The jQuery namespace.
* @external jQuery
@@ -34,7 +32,6 @@
* @memberof external:jQuery
* @see {@link http://learn.jquery.com/plugins/|jQuery Plugins}
*/
/* eslint-enable jsdoc/require-property */
const ns = {
svg: 'http://www.w3.org/2000/svg',
@@ -145,13 +142,11 @@ export default function jQueryPluginJGraduate ($) {
}
}
/* eslint-disable jsdoc/require-property */
/**
* @namespace {PlainObject} jGraduate
* @memberof external:jQuery
*/
$.jGraduate = /** @lends external:jQuery.jGraduate */ {
/* eslint-enable jsdoc/require-property */
/**
* @class external:jQuery.jGraduate.Paint
* @see module:jGraduate~Paint

View File

@@ -1,4 +1,4 @@
/* eslint-disable no-bitwise, max-len, unicorn/prefer-math-trunc, unicorn/prefer-ternary */
/* eslint-disable max-len */
/**
* @file jPicker (Adapted from version 1.1.6)
*
@@ -327,14 +327,14 @@ const jPicker = function ($) {
* @param {GenericCallback} callback
* @returns {void}
*/
function bind (callback) { // eslint-disable-line promise/prefer-await-to-callbacks
function bind (callback) {
if (typeof callback === 'function') changeEvents.push(callback);
}
/**
* @param {GenericCallback} callback
* @returns {void}
*/
function unbind (callback) { // eslint-disable-line promise/prefer-await-to-callbacks
function unbind (callback) {
if (typeof callback !== 'function') return;
let i;
while ((i = changeEvents.includes(callback))) changeEvents.splice(i, 1);
@@ -681,13 +681,11 @@ const jPicker = function ($) {
* @property {string} [ahex]
*/
/* eslint-disable jsdoc/require-property */
/**
* @namespace {PlainObject} jPicker
* @memberof external:jQuery
*/
$.jPicker = /** @lends external:jQuery.jPicker */ {
/* eslint-enable jsdoc/require-property */
/**
* Array holding references to each active instance of the jPicker control.
* @type {external:jQuery.fn.$.fn.jPicker[]}
@@ -949,14 +947,14 @@ const jPicker = function ($) {
* @param {GenericCallback} callback
* @returns {void}
*/
function bind (callback) { // eslint-disable-line promise/prefer-await-to-callbacks
function bind (callback) {
if (typeof callback === 'function') changeEvents.push(callback);
}
/**
* @param {GenericCallback} callback
* @returns {void}
*/
function unbind (callback) { // eslint-disable-line promise/prefer-await-to-callbacks
function unbind (callback) {
if (typeof callback !== 'function') return;
let i;
while ((i = changeEvents.includes(callback))) {
@@ -1176,12 +1174,10 @@ const jPicker = function ($) {
}
};
const {Color, List, ColorMethods} = $.jPicker; // local copies for YUI compressor
/* eslint-disable jsdoc/require-returns */
/**
* @function external:jQuery.fn.jPicker
* @see {@link external:jQuery.fn.$.fn.jPicker}
*/
/* eslint-enable jsdoc/require-returns */
/**
* Will be bound to active {@link jQuery.jPicker.Color}.
@@ -1556,7 +1552,7 @@ const jPicker = function ($) {
const all = ui.val('all');
activePreview.css({backgroundColor: (all && '#' + all.hex) || 'transparent'});
setAlpha.call(that, activePreview, (all && toFixedNumeric((all.a * 100) / 255, 4)) || 0);
} catch (e) {}
} catch (e) {/* empty fn */}
}
/**
* @param {external:jQuery} ui

View File

@@ -1,4 +1,3 @@
/* eslint-disable node/no-unpublished-import */
import ListComboBox from 'elix/define/ListComboBox.js';
import {defaultState} from 'elix/src/base/internal.js';
import {templateFrom, fragmentFrom} from 'elix/src/core/htmlLiterals.js';

View File

@@ -160,7 +160,6 @@ export class ExplorerButton extends HTMLElement {
const response = await fetch(`${newValue}index.json`);
const json = await response.json();
const {lib} = json;
// eslint-disable-next-line no-unsanitized/property
this.$menu.innerHTML = lib.map((menu, i) => (
`<div data-menu="${menu}" class="menu-item ${(i === 0) ? 'pressed' : ''} ">${menu}</div>`
)).join('');
@@ -297,7 +296,6 @@ export class ExplorerButton extends HTMLElement {
const off = size * 0.05;
const vb = [-off, -off, size + off * 2, size + off * 2].join(' ');
const stroke = json.fill ? 0 : (size / 30);
// eslint-disable-next-line no-unsanitized/property
this.$lib.innerHTML = Object.entries(this.data).map(([key, path]) => {
const encoded = btoa(`
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24">

View File

@@ -1,4 +1,3 @@
/* eslint-disable node/no-unpublished-import */
import 'elix/define/Input.js';
const template = document.createElement('template');

View File

@@ -1,4 +1,3 @@
/* eslint-disable node/no-unpublished-import */
import 'elix/define/DropdownList.js';
const template = document.createElement('template');

View File

@@ -1,4 +1,3 @@
/* eslint-disable node/no-unpublished-import */
import 'elix/define/Option.js';
const template = document.createElement('template');

View File

@@ -1,4 +1,3 @@
/* eslint-disable node/no-unpublished-import */
import 'elix/define/MenuItem.js';
import './sePlainMenuButton.js';

View File

@@ -1,4 +1,3 @@
/* eslint-disable node/no-unpublished-import */
import 'elix/define/Menu.js';
import 'elix/define/MenuItem.js';

View File

@@ -1,4 +1,3 @@
/* eslint-disable node/no-unpublished-import */
import 'elix/define/CenteredStrip.js';
const palette = [

View File

@@ -1,4 +1,3 @@
/* eslint-disable node/no-unpublished-import */
import {template} from 'elix/src/base/internal.js';
import {fragmentFrom} from 'elix/src/core/htmlLiterals.js';
import PlainButton from 'elix/src/plain/PlainButton.js';

View File

@@ -1,4 +1,3 @@
/* eslint-disable node/no-unpublished-import */
import PlainMenuButton from 'elix/src/plain/PlainMenuButton.js';
import {defaultState} from 'elix/src/base/internal.js';
import sePlainBorderButton from './sePlainBorderButton.js';

View File

@@ -1,4 +1,3 @@
/* eslint-disable node/no-unpublished-import */
import ListComboBox from 'elix/define/ListComboBox.js';
import * as internal from 'elix/src/base/internal.js';
import {templateFrom, fragmentFrom} from 'elix/src/core/htmlLiterals.js';

View File

@@ -48,7 +48,7 @@ export const add = function (menuItem) {
throw new Error('Cannot add extension "' + menuItem.id + '", an extension by that name already exists"');
}
// Register menuItem action, see below for deferred menu dom injection
console.log('Registered contextmenu item: {id:' + menuItem.id + ', label:' + menuItem.label + '}'); // eslint-disable-line no-console
console.log('Registered contextmenu item: {id:' + menuItem.id + ', label:' + menuItem.label + '}');
contextMenuExtensions[menuItem.id] = menuItem;
// TODO: Need to consider how to handle custom enable/disable behavior
};

View File

@@ -1,4 +1,3 @@
/* eslint-disable node/no-unpublished-import */
import PlainAlertDialog from 'elix/src/plain/PlainAlertDialog.js';
import {template} from 'elix/src/base/internal.js';
import {fragmentFrom} from 'elix/src/core/htmlLiterals.js';

View File

@@ -1,4 +1,3 @@
/* eslint-disable node/no-unpublished-import */
import 'elix/define/Dialog.js';
const template = document.createElement('template');

View File

@@ -1,4 +1,3 @@
/* eslint-disable node/no-unpublished-import */
import 'elix/define/Dialog.js';
import './se-elix/define/NumberSpinBox.js';

View File

@@ -1,4 +1,3 @@
/* eslint-disable node/no-unpublished-import */
import 'elix/define/Dialog.js';
import {isValidUnit} from '../../common/units.js';

View File

@@ -1,5 +1,4 @@
/* eslint-disable class-methods-use-this */
/* eslint-disable node/no-unpublished-import */
import {
defaultState,
setState,

View File

@@ -1,4 +1,3 @@
/* eslint-disable node/no-unpublished-import */
import PlainSpinBoxMixin from 'elix/src/plain/PlainSpinBoxMixin.js';
import NumberSpinBox from '../base/NumberSpinBox.js';

View File

@@ -1,4 +1,3 @@
/* eslint-disable node/no-unpublished-import */
import 'elix/define/Dialog.js';
const template = document.createElement('template');

View File

@@ -18,10 +18,10 @@ let svgCanvas = null;
function handleSvgData (data, error) {
if (error) {
// Todo: This should be replaced with a general purpose dialog alert library call
alert('error ' + error); // eslint-disable-line no-alert
alert('error ' + error);
} else {
// Todo: This should be replaced with a general purpose dialog alert library call
alert('Congratulations. Your SVG string is back in the host page, do with it what you will\n\n' + data); // eslint-disable-line no-alert
alert('Congratulations. Your SVG string is back in the host page, do with it what you will\n\n' + data);
}
}
@@ -112,7 +112,7 @@ iframe[0].addEventListener('load', function () {
try {
doc = frame.contentDocument || frame.contentWindow.document;
} catch (err) {
console.log('Blocked from accessing document', err); // eslint-disable-line no-console
console.log('Blocked from accessing document', err);
}
if (doc) {
// Todo: Provide a way to get this to occur by `postMessage`

View File

@@ -24,7 +24,7 @@ let cbid = 0;
function getCallbackSetter (funcName) {
return function (...args) {
const that = this, // New callback
callbackID = this.send(funcName, args, function () { /* empty */ }); // The callback (currently it's nothing, but will be set later)
callbackID = this.send(funcName, args, function () { /* empty fn */ }); // The callback (currently it's nothing, but will be set later)
return function (newCallback) {
that.callbacks[callbackID] = newCallback; // Set callback
@@ -71,7 +71,6 @@ function messageListener (e) {
e.source !== this.frame.contentWindow ||
(!allowedOrigins.includes('*') && !allowedOrigins.includes(e.origin))
) {
// eslint-disable-next-line no-console -- Info for developers
console.error(
`The origin ${e.origin} was not whitelisted as an origin from ` +
`which responses may be received by this ${window.origin} script.`
@@ -344,7 +343,7 @@ class EmbeddedSVGEdit {
* @param {GenericCallback} callback (This may be better than a promise in case adding an event.)
* @returns {Integer}
*/
send (name, args, callback) { // eslint-disable-line promise/prefer-await-to-callbacks
send (name, args, callback) {
const that = this;
cbid++;
@@ -363,7 +362,7 @@ class EmbeddedSVGEdit {
try {
sameOriginWithGlobal = window.location.origin === that.frame.contentWindow.location.origin &&
that.frame.contentWindow.svgEditor.svgCanvas;
} catch (err) {}
}catch (err) {/* empty */}
if (sameOriginWithGlobal) {
// Although we do not really need this API if we are working same

View File

@@ -83,7 +83,7 @@ export default {
svgCanvas.clearSelection();
} catch (e) {
// Todo: Surface error to user
console.log(e); // eslint-disable-line no-console
console.log(e);
return false;
}

View File

@@ -78,7 +78,7 @@ export default {
});
// Show the text using the custom alert function
alert(text); // eslint-disable-line no-alert
alert(text);
}
}
};

View File

@@ -109,7 +109,7 @@ export default {
* @param {ImageLibMetaMessage|ImageLibMessage|string} cfg.data String is deprecated when parsed to JSON `ImageLibMessage`
* @returns {void}
*/
async function onMessage ({origin, data: response}) { // eslint-disable-line no-shadow
async function onMessage ({origin, data: response}) {
if (!response || !['string', 'object'].includes(typeof response)) {
// Do nothing
return;
@@ -126,7 +126,7 @@ export default {
}
if (!allowedImageLibOrigins.includes('*') && !allowedImageLibOrigins.includes(origin)) {
// Todo: Surface this error to user?
console.log(`Origin ${origin} not whitelisted for posting to ${window.origin}`); // eslint-disable-line no-console
console.log(`Origin ${origin} not whitelisted for posting to ${window.origin}`);
return;
}
const hasName = 'name' in response;

View File

@@ -33,7 +33,7 @@ $('a').click(function () {
} catch (err) {
// This fails in Firefox with `file:///` URLs :(
// Todo: This could use a generic alert library instead
alert('Data URL conversion failed: ' + err); // eslint-disable-line no-alert
alert('Data URL conversion failed: ' + err);
data = '';
}
post({href, data});

View File

@@ -1,8 +1,5 @@
// eslint-disable-next-line node/no-unpublished-import
import {jml, body, nbsp} from 'jamilih';
// eslint-disable-next-line node/no-unpublished-import
import $ from 'query-result';
// eslint-disable-next-line node/no-unpublished-import
import {manipulation} from 'qr-manipulation';
manipulation($, jml);
@@ -40,7 +37,7 @@ async function processResults (url) {
if (!json || json.msg !== 'success') {
// Todo: This could use a generic alert library instead
alert('There was a problem downloading the results'); // eslint-disable-line no-alert
alert('There was a problem downloading the results');
return;
}
const {payload, info: {

View File

@@ -196,12 +196,12 @@ export default {
// When MathJax is loaded get the div where the math will be rendered.
MathJax.Hub.queue.Push(function () {
math = MathJax.Hub.getAllJax('#mathjax_creator')[0];
console.log(math); // eslint-disable-line no-console
console.log(math);
mathjaxLoaded = true;
console.log('MathJax Loaded'); // eslint-disable-line no-console
console.log('MathJax Loaded');
});
} catch (e) {
console.log('Failed loading MathJax.'); // eslint-disable-line no-console
console.log('Failed loading MathJax.');
// eslint-disable-next-line no-alert
alert('Failed loading MathJax. You will not be able to change the mathematics.');
}

View File

@@ -151,10 +151,10 @@ export default {
function setupBeforeUnloadListener () {
window.addEventListener('beforeunload', function (e) {
// Don't save anything unless the user opted in to storage
if (!document.cookie.match(/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/)) {
if (!(/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/).test(document.cookie)) {
return;
}
if (document.cookie.match(/(?:^|;\s*)svgeditstore=prefsAndContent/)) {
if ((/(?:^|;\s*)svgeditstore=prefsAndContent/).test(document.cookie)) {
setSVGContentStorage(svgCanvas.getSvgString());
}
@@ -209,7 +209,7 @@ export default {
// continual prompts about it)...
storagePrompt !== 'false' &&
// ...and this user hasn't previously indicated a desire for storage
!document.cookie.match(/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/)
!(/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/).test(document.cookie)
)
// ...then show the storage prompt.
)) {

View File

@@ -1,5 +1,4 @@
/* eslint-disable max-len */
/* eslint-disable node/no-unpublished-import */
import 'elix/define/Dialog.js';
const template = document.createElement('template');

View File

@@ -39,7 +39,7 @@ export default {
* @throws {Error} Unexpected event type
* @returns {void}
*/
(win, {data, origin}) => { // eslint-disable-line no-shadow
(win, {data, origin}) => {
// console.log('data, origin', data, origin);
let type, content;
try {

View File

@@ -24,7 +24,7 @@ export default {
// to configure
const {allowedOrigins} = svgEditor.configObj.curConfig;
if (!allowedOrigins.includes('*') && !allowedOrigins.includes(e.origin)) {
console.log(`Origin ${e.origin} not whitelisted for posting to ${window.origin}`); // eslint-disable-line no-console
console.log(`Origin ${e.origin} not whitelisted for posting to ${window.origin}`);
return;
}
const cbid = data.id;
@@ -43,7 +43,7 @@ export default {
e.source.postMessage(JSON.stringify(message), '*');
});
} catch (err) {
console.log('Error with xdomain message listener: ' + err); // eslint-disable-line no-console
console.log('Error with xdomain message listener: ' + err);
}
}
};

View File

@@ -139,7 +139,6 @@ try { // try clause to avoid js to complain if XDOMAIN undefined
canvasName: 'xdomain', // Namespace this
allowedOrigins: ['*']
});
// eslint-disable-next-line no-console
console.info('xdomain config activated');
}
} catch (error) {}
} catch (error) {/* empty fn */}

View File

@@ -50,7 +50,7 @@ export const setStrings = function (type, obj, ids) {
const parent = document.getElementById('svg_editor').parentNode;
Object.entries(obj).forEach(([sel, val]) => {
if (!val) {
console.log(sel); // eslint-disable-line no-console
console.log(sel);
return; // keep old text when has no translation
}
@@ -80,7 +80,7 @@ export const setStrings = function (type, obj, ids) {
break;
}
} else {
console.log('Missing element for localization: ' + sel); // eslint-disable-line no-console
console.log('Missing element for localization: ' + sel);
}
});
};
@@ -355,7 +355,7 @@ export const putLocale = async function (givenParam, goodLangs) {
langParam = navigator.language;
}
console.log('Lang: ' + langParam); // eslint-disable-line no-console
console.log('Lang: ' + langParam);
// Set to English if language is not in list of good langs
if (!goodLangs.includes(langParam) && langParam !== 'test') {

View File

@@ -498,8 +498,8 @@ class Editor extends EditorStartup {
const ratio = newCanX / oldCanX;
const scrollX = w / 2 - wOrig / 2; // eslint-disable-line no-shadow
const scrollY = h / 2 - hOrig / 2; // eslint-disable-line no-shadow
const scrollX = w / 2 - wOrig / 2;
const scrollY = h / 2 - hOrig / 2;
if (!newCtr) {
const oldDistX = oldCtr.x - oldCanX;
@@ -1028,7 +1028,7 @@ class Editor extends EditorStartup {
const icon = (typeof iconId === 'string') ? $('<img src="' + this.configObj.curConfig.imgPath + iconId + '">') : iconId.clone();
if (!icon) {
// Todo: Investigate why this still occurs in some cases
console.log('NOTE: Icon image missing: ' + iconId); // eslint-disable-line no-console
console.log('NOTE: Icon image missing: ' + iconId);
return;
}
$(elem).empty().append(icon);
@@ -1046,7 +1046,6 @@ class Editor extends EditorStartup {
* @returns {void}
*/
addAltDropDown (elemSel, listSel, callback, opts) {
// eslint-disable-next-line no-shadow
const self = this;
const button = $(elemSel);
const {dropUp} = opts;
@@ -1112,7 +1111,7 @@ class Editor extends EditorStartup {
* @returns {Promise<void>|void} Resolves to `undefined`
*/
async extAdded (win, ext) {
// eslint-disable-next-line no-shadow
const self = this;
const btnSelects = [];
if (!ext) {
@@ -1482,7 +1481,7 @@ class Editor extends EditorStartup {
self.addAltDropDown(this.elem, this.list, this.callback, {seticon: true});
});
/* if (svgicons) {
return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new
return new Promise((resolve, reject) => {
$.svgIcons(`${this.configObj.curConfig.imgPath}${svgicons}`, {
w: 24, h: 24,
id_match: false,
@@ -1649,6 +1648,7 @@ class Editor extends EditorStartup {
/**
*
* @param e
* @returns {Promise<void>} Resolves to `undefined`
*/
async clickExport (e) {
@@ -1930,7 +1930,7 @@ class Editor extends EditorStartup {
let svgeditClipboard;
try {
svgeditClipboard = this.localStorage.getItem('svgedit_clipboard');
} catch (err) {}
} catch (err) {/* empty fn */}
this.canvMenu.setAttribute((svgeditClipboard ? 'en' : 'dis') + 'ablemenuitems', '#paste,#paste_in_place');
}
@@ -2051,10 +2051,10 @@ class Editor extends EditorStartup {
* @param {module:SVGthis.ReadyCallback} cb Callback to be queued to invoke
* @returns {Promise<ArbitraryCallbackResult>} Resolves when all callbacks, including the supplied have resolved
*/
ready (cb) { // eslint-disable-line promise/prefer-await-to-callbacks
return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new
ready (cb) {
return new Promise((resolve, reject) => {
if (this.isReady) {
resolve(cb()); // eslint-disable-line node/callback-return, promise/prefer-await-to-callbacks
resolve(cb());
return;
}
this.callbacks.push([cb, resolve, reject]);
@@ -2069,7 +2069,7 @@ class Editor extends EditorStartup {
async runCallbacks () {
try {
await Promise.all(this.callbacks.map(([cb]) => {
return cb(); // eslint-disable-line promise/prefer-await-to-callbacks
return cb();
}));
} catch (err) {
this.callbacks.forEach(([, , reject]) => {
@@ -2119,7 +2119,7 @@ class Editor extends EditorStartup {
*/
loadFromURL (url, {cache, noAlert} = {}) {
return this.ready(() => {
return new Promise((resolve, reject) => { // eslint-disable-line promise/avoid-new
return new Promise((resolve, reject) => {
$.ajax({
url,
dataType: 'text',

View File

@@ -16,7 +16,7 @@ function touchHandler (ev) {
default: return;
}
const {screenX, screenY, clientX, clientY} = first; // eslint-disable-line no-shadow
const {screenX, screenY, clientX, clientY} = first;
const simulatedEvent = new MouseEvent(type, {
// Event interface
bubbles: true,

View File

@@ -22,7 +22,6 @@
* @returns {ArbitraryCallbackResult} Return dependent on the function
*/
/* eslint-disable jsdoc/require-property */
/**
* This should only be used for objects known to be potentially arbitrary in form.
* For those whose determination has not yet been made, simply use type `object`
@@ -32,7 +31,6 @@
/**
* @typedef {object} ArbitraryModule
*/
/* eslint-enable jsdoc/require-property */
/**
* This should only be used for objects known to be potentially arbitrary in form,
@@ -41,13 +39,11 @@
* @typedef {ArbitraryObject} PlainObject
*/
/* eslint-disable jsdoc/check-types */
/**
* This should only be used for arrays known to be potentially arbitrary in form.
* For those whose determination has not yet been made, simply use type `Array`.
* @typedef {Array} GenericArray
*/
/* eslint-enable jsdoc/check-types */
/**
* This should only be used for arrays known to be potentially arbitrary in form and

View File

@@ -44,7 +44,7 @@ export const setBlurNoUndo = function (val) {
blurContext_.changeSelectedAttributeNoUndoMethod('filter', 'url(#' + elem.id + '_blur)');
}
if (blurContext_.isWebkit()) {
// console.log('e', elem); // eslint-disable-line no-console
// console.log('e', elem);
elem.removeAttribute('filter');
elem.setAttribute('filter', 'url(#' + elem.id + '_blur)');
}

View File

@@ -169,7 +169,7 @@ export const setResolutionMethod = function (x, y) {
const visEls = getVisibleElements();
elemContext_.getCanvas().addToSelection(visEls);
const dx = [], dy = [];
$.each(visEls, function (i, item) {
$.each(visEls, function (_i, _item) {
dx.push(bbox.x * -1);
dy.push(bbox.y * -1);
});
@@ -239,7 +239,7 @@ export const setBBoxZoomMethod = function (val, editorW, editorH) {
const selectedElements = elemContext_.getSelectedElements();
let spacer = 0.85;
let bb;
const calcZoom = function (bb) { // eslint-disable-line no-shadow
const calcZoom = function (bb) {
if (!bb) { return false; }
const wZoom = Math.round((editorW / bb.width) * 100 * spacer) / 100;
const hZoom = Math.round((editorH / bb.height) * 100 * spacer) / 100;

View File

@@ -835,7 +835,7 @@ t.id !== 'svgcanvas' && t.id !== 'svgroot'
try {
// Fails in FF4 on foreignObject
cAni[0].beginElement();
} catch (e) {}
} catch (e) {/* empty fn */}
} else {
aniDur = 0;
}

View File

@@ -165,7 +165,6 @@ export const convertPath = function (pth, toRel) {
}
d += pathDSegment(letter, [[x1, y1], [x, y]]);
break;
// eslint-disable-next-line sonarjs/no-duplicated-branches
case 10: // absolute elliptical arc (A)
x -= curx;
y -= cury;
@@ -230,7 +229,6 @@ function pathDSegment (letter, points, morePoints, lastPoint) {
return segment;
}
/* eslint-disable jsdoc/require-property */
/**
* Group: Path edit functions.
* Functions relating to editing path elements.
@@ -238,7 +236,6 @@ function pathDSegment (letter, points, morePoints, lastPoint) {
* @memberof module:path
*/
export const pathActionsMethod = (function () {
/* eslint-enable jsdoc/require-property */
let subpath = false;
let newPoint, firstCtrl;
@@ -675,7 +672,7 @@ export const pathActionsMethod = (function () {
}
} else {
path.selected_pts = [];
path.eachSeg(function (i) {
path.eachSeg(function (_i) {
const seg = this;
if (!seg.next && !seg.prev) { return; }
@@ -708,11 +705,11 @@ export const pathActionsMethod = (function () {
/**
* @param {Event} evt
* @param {Element} element
* @param {Float} mouseX
* @param {Float} mouseY
* @param {Float} _mouseX
* @param {Float} _mouseY
* @returns {module:path.keepElement|void}
*/
mouseUp (evt, element, mouseX, mouseY) {
mouseUp (evt, element, _mouseX, _mouseY) {
editorContext_ = pathActionsContext_.getEditorContext();
const drawnPath = editorContext_.getDrawnPath();
// Create mode
@@ -1173,7 +1170,6 @@ export const pathActionsMethod = (function () {
}
path.endChanges('Delete path node(s)');
},
/* eslint-disable jsdoc/require-returns */
// Can't seem to use `@borrows` here, so using `@see`
/**
* Smooth polyline into path.
@@ -1181,7 +1177,7 @@ export const pathActionsMethod = (function () {
* @see module:path~smoothPolylineIntoPath
*/
smoothPolylineIntoPath,
/* eslint-enable jsdoc/require-returns */
/* eslint-enable */
/**
* @param {?Integer} v See {@link https://www.w3.org/TR/SVG/single-page.html#paths-InterfaceSVGPathSeg}
* @returns {void}
@@ -1240,7 +1236,6 @@ export const pathActionsMethod = (function () {
editorContext_ = pathActionsContext_.getEditorContext();
if (isWebkit()) { editorContext_.resetD(elem); }
},
/* eslint-disable jsdoc/require-returns */
// Can't seem to use `@borrows` here, so using `@see`
/**
* Convert a path to one with only absolute or relative values.
@@ -1248,7 +1243,6 @@ export const pathActionsMethod = (function () {
* @see module:path.convertPath
*/
convertPath
/* eslint-enable jsdoc/require-returns */
});
})();
// end pathActions

View File

@@ -77,7 +77,7 @@ export const setLinkControlPoints = function (lcp) {
* @type {null|module:path.Path}
* @memberof module:path
*/
export let path = null; // eslint-disable-line import/no-mutable-exports
export let path = null;
let editorContext_ = null;
@@ -725,7 +725,6 @@ export const convertPath = function (pth, toRel) {
}
d += pathDSegment(letter, [[x1, y1], [x, y]]);
break;
// eslint-disable-next-line sonarjs/no-duplicated-branches
case 10: // absolute elliptical arc (A)
x -= curx;
y -= cury;

View File

@@ -94,7 +94,7 @@ const svgWhiteList_ = {
const svgWhiteListNS_ = {};
Object.entries(svgWhiteList_).forEach(function ([elt, atts]) {
const attNS = {};
Object.entries(atts).forEach(function ([i, att]) {
Object.entries(atts).forEach(function ([_i, att]) {
if (att.includes(':')) {
const v = att.split(':');
attNS[v[1]] = NS[(v[0]).toUpperCase()];

View File

@@ -452,7 +452,7 @@ export class SelectorManager {
sel = this.selectorMap[elem.id];
if (sel && !sel.locked) {
// TODO(codedread): Ensure this exists in this module.
console.log('WARNING! selector was released but was already unlocked'); // eslint-disable-line no-console
console.log('WARNING! selector was released but was already unlocked');
}
for (let i = 0; i < N; ++i) {
if (this.selectors[i] && this.selectors[i] === sel) {
@@ -464,7 +464,7 @@ export class SelectorManager {
// remove from DOM and store reference in JS but only if it exists in the DOM
try {
sel.selectorGroup.setAttribute('display', 'none');
} catch (e) {}
} catch (e) {/* empty fn */}
break;
}

View File

@@ -787,7 +787,7 @@ export const convertToGroup = function (elem) {
try {
recalculateDimensions(n);
} catch (e) {
console.log(e); // eslint-disable-line no-console
console.log(e);
}
});
@@ -805,7 +805,7 @@ export const convertToGroup = function (elem) {
elementContext_.addCommandToHistory(batchCmd);
} else {
console.log('Unexpected element to ungroup:', elem); // eslint-disable-line no-console
console.log('Unexpected element to ungroup:', elem);
}
};

View File

@@ -456,7 +456,7 @@ export const setSvgString = function (xmlString, preventUndo) {
if (!preventUndo) svgContext_.addCommandToHistory(batchCmd);
svgContext_.call('changed', [svgContext_.getSVGContent()]);
} catch (e) {
console.log(e); // eslint-disable-line no-console
console.log(e);
return false;
}
@@ -577,7 +577,7 @@ export const importSvgString = function (xmlString) {
svgContext_.addCommandToHistory(batchCmd);
svgContext_.call('changed', [svgContext_.getSVGContent()]);
} catch (e) {
console.log(e); // eslint-disable-line no-console
console.log(e);
return null;
}
@@ -598,7 +598,6 @@ export const importSvgString = function (xmlString) {
*/
export const embedImage = function (src) {
// Todo: Remove this Promise in favor of making an async/await `Image.load` utility
// eslint-disable-next-line promise/avoid-new
return new Promise(function (resolve, reject) {
// load in the image and once it's loaded, get the dimensions
$(new Image()).load(function (response, status, xhr) {
@@ -679,7 +678,6 @@ function getIssues () {
}
$.each(issueList, function (sel, descr) {
// eslint-disable-next-line unicorn/no-array-callback-reference
if (content.find(sel).length) {
issueCodes.push(sel);
issues.push(descr);
@@ -732,7 +730,6 @@ export const rasterExport = async function (imgType, quality, exportWindowName,
// Render only first frame, ignoring animations.
await v.render();
// Todo: Make async/await utility in place of `toBlob`, so we can remove this constructor
// eslint-disable-next-line promise/avoid-new
return new Promise((resolve, reject) => {
const dataURLType = type.toLowerCase();
const datauri = quality

View File

@@ -127,8 +127,8 @@ const refAttrs = ['clip-path', 'fill', 'filter', 'marker-end', 'marker-mid', 'ma
if (!window.console) {
window.console = {};
window.console.log = function (str) { /* empty fn */ };
window.console.dir = function (str) { /* empty fn */ };
window.console.log = function (_str) { /* empty fn */ };
window.console.dir = function (_str) { /* empty fn */ };
}
if (window.opera) {
@@ -1072,7 +1072,7 @@ class SvgCanvas {
* @returns {void}
*/
const logMatrix = function (m) {
console.log([m.a, m.b, m.c, m.d, m.e, m.f]); // eslint-disable-line no-console
console.log([m.a, m.b, m.c, m.d, m.e, m.f]);
};
// Root Current Transformation Matrix in user units

View File

@@ -116,7 +116,7 @@ let listMap_ = {};
* implementing as much of SVGTransformList that we need to get the job done.
* @implements {module:SVGTransformList.SVGEditTransformList}
*/
export class SVGTransformList { // eslint-disable-line no-shadow
export class SVGTransformList {
/**
* @param {Element} elem
* @returns {SVGTransformList}
@@ -339,7 +339,7 @@ export const resetListMap = function () {
* @param {Element} elem - a DOM Element
* @returns {void}
*/
export let removeElementFromListMap = function (elem) { // eslint-disable-line import/no-mutable-exports
export let removeElementFromListMap = function (elem) {
if (elem.id && listMap_[elem.id]) {
delete listMap_[elem.id];
}
@@ -388,6 +388,6 @@ export const getTransformList = function (elem) {
* @returns {void}
*/
export const changeRemoveElementFromListMap = function (cb) { // eslint-disable-line promise/prefer-await-to-callbacks
export const changeRemoveElementFromListMap = function (cb) {
removeElementFromListMap = cb;
};

View File

@@ -31,7 +31,6 @@ export const init = function (textActionsContext) {
textActionsContext_ = textActionsContext;
};
/* eslint-disable jsdoc/require-property */
/**
* Group: Text edit functions
* Functions relating to editing text elements.
@@ -39,7 +38,6 @@ export const init = function (textActionsContext) {
* @memberof module:svgcanvas.SvgCanvas#
*/
export const textActionsMethod = (function () {
/* eslint-enable jsdoc/require-property */
let curtext;
let textinput;
let cursor;
@@ -461,10 +459,10 @@ export const textActionsMethod = (function () {
}
},
/**
* @param {Element} inputElem Not in use
* @param {Element} _inputElem Not in use
* @returns {void}
*/
init (inputElem) {
init (_inputElem) {
if (!curtext) { return; }
let i, end;
// if (supportsEditableText()) {

View File

@@ -441,7 +441,7 @@ export const getUrlFromAttr = function (attrVal) {
* @param {Element} elem
* @returns {string} The given element's `xlink:href` value
*/
export let getHref = function (elem) { // eslint-disable-line import/no-mutable-exports
export let getHref = function (elem) {
return elem.getAttributeNS(NS.XLINK, 'href');
};
@@ -452,7 +452,7 @@ export let getHref = function (elem) { // eslint-disable-line import/no-mutable-
* @param {string} val
* @returns {void}
*/
export let setHref = function (elem, val) { // eslint-disable-line import/no-mutable-exports
export let setHref = function (elem, val) {
elem.setAttributeNS(NS.XLINK, 'xlink:href', val);
};
@@ -569,7 +569,7 @@ export const getPathBBox = function (path) {
*/
function groupBBFix (selected) {
if (supportsHVLineContainerBBox()) {
try { return selected.getBBox(); } catch (e) {}
try { return selected.getBBox(); } catch (e) {/* empty */}
}
const ref = $.data(selected, 'ref');
let matched = null;
@@ -1172,7 +1172,7 @@ export const getRotationAngleFromTransformList = function (tlist, toRad) {
* @param {boolean} [toRad=false] - When true returns the value in radians rather than degrees
* @returns {Float} The angle in degrees or radians
*/
export let getRotationAngle = function (elem, toRad) { // eslint-disable-line import/no-mutable-exports
export let getRotationAngle = function (elem, toRad) {
const selected = elem || editorContext_.getSelectedElements()[0];
// find the rotation transform (if any) and set it
const tlist = getTransformList(selected);