eslint: enforce use of const when variable not modified
parent
a4ef206050
commit
074df9cdec
10
.eslintrc.js
10
.eslintrc.js
|
@ -32,12 +32,17 @@ module.exports = {
|
||||||
/** @todo cognitive complexity should be much lower (25-50?) */
|
/** @todo cognitive complexity should be much lower (25-50?) */
|
||||||
"sonarjs/cognitive-complexity": [ "warn", 200 ],
|
"sonarjs/cognitive-complexity": [ "warn", 200 ],
|
||||||
/** @todo no param reassign creates too many warnings but should be a warning */
|
/** @todo no param reassign creates too many warnings but should be a warning */
|
||||||
"comma-dangle": [ "error" ],
|
|
||||||
"no-param-reassign": "off",
|
"no-param-reassign": "off",
|
||||||
|
/** @todo no use before define creates too many warnings but should be a warning */
|
||||||
|
"no-use-before-define": "off",
|
||||||
|
/** @todo camel case creates too many warnings but should be a warning */
|
||||||
|
"camelcase": "off",
|
||||||
|
"comma-dangle": [ "error" ],
|
||||||
"node/no-unsupported-features/es-syntax": 0,
|
"node/no-unsupported-features/es-syntax": 0,
|
||||||
"no-unused-vars": [ "error", { "argsIgnorePattern": "^_" } ],
|
"no-unused-vars": [ "error", { "argsIgnorePattern": "^_" } ],
|
||||||
"sonarjs/no-duplicate-string": 0,
|
"sonarjs/no-duplicate-string": 0,
|
||||||
"semi" : "error",
|
"semi" : "error",
|
||||||
|
"prefer-const": "error",
|
||||||
"no-trailing-spaces": "error",
|
"no-trailing-spaces": "error",
|
||||||
"array-bracket-spacing": [ "error", "always" ],
|
"array-bracket-spacing": [ "error", "always" ],
|
||||||
"comma-spacing": "error",
|
"comma-spacing": "error",
|
||||||
|
@ -85,7 +90,8 @@ module.exports = {
|
||||||
{
|
{
|
||||||
files: [ 'src/editor/locale/*.js' ],
|
files: [ 'src/editor/locale/*.js' ],
|
||||||
rules: { // lang files may have long length
|
rules: { // lang files may have long length
|
||||||
"max-len": "off"
|
"max-len": "off",
|
||||||
|
"camelcase": "off"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -33,7 +33,7 @@ describe('recalculate', function () {
|
||||||
return this._storage.has(element) && this._storage.get(element).has(key);
|
return this._storage.has(element) && this._storage.get(element).has(key);
|
||||||
},
|
},
|
||||||
remove: function (element, key) {
|
remove: function (element, key) {
|
||||||
let ret = this._storage.get(element).delete(key);
|
const ret = this._storage.get(element).delete(key);
|
||||||
if (!this._storage.get(element).size === 0) {
|
if (!this._storage.get(element).size === 0) {
|
||||||
this._storage.delete(element);
|
this._storage.delete(element);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ describe('select', function () {
|
||||||
return this._storage.has(element) && this._storage.get(element).has(key);
|
return this._storage.has(element) && this._storage.get(element).has(key);
|
||||||
},
|
},
|
||||||
remove: function (element, key) {
|
remove: function (element, key) {
|
||||||
let ret = this._storage.get(element).delete(key);
|
const ret = this._storage.get(element).delete(key);
|
||||||
if (!this._storage.get(element).size === 0) {
|
if (!this._storage.get(element).size === 0) {
|
||||||
this._storage.delete(element);
|
this._storage.delete(element);
|
||||||
}
|
}
|
||||||
|
|
|
@ -281,11 +281,11 @@ class Editor extends EditorStartup {
|
||||||
parentSelector = document;
|
parentSelector = document;
|
||||||
}
|
}
|
||||||
|
|
||||||
let parents = [];
|
const parents = [];
|
||||||
let p = el.parentNode;
|
let p = el.parentNode;
|
||||||
|
|
||||||
while (p !== parentSelector) {
|
while (p !== parentSelector) {
|
||||||
let o = p;
|
const o = p;
|
||||||
parents.push(o);
|
parents.push(o);
|
||||||
p = o.parentNode;
|
p = o.parentNode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,7 +255,7 @@ class EditorStartup {
|
||||||
});
|
});
|
||||||
|
|
||||||
function addListenerMulti(element, eventNames, listener) {
|
function addListenerMulti(element, eventNames, listener) {
|
||||||
let events = eventNames.split(' ');
|
const events = eventNames.split(' ');
|
||||||
for (let i=0, iLen=events.length; i<iLen; i++) {
|
for (let i=0, iLen=events.length; i<iLen; i++) {
|
||||||
element.addEventListener(events[i], listener, false);
|
element.addEventListener(events[i], listener, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ export function isObject(item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mergeDeep(target, source) {
|
export function mergeDeep(target, source) {
|
||||||
let output = Object.assign({}, target);
|
const output = Object.assign({}, target);
|
||||||
if (isObject(target) && isObject(source)) {
|
if (isObject(target) && isObject(source)) {
|
||||||
Object.keys(source).forEach((key) => {
|
Object.keys(source).forEach((key) => {
|
||||||
if (isObject(source[key])) {
|
if (isObject(source[key])) {
|
||||||
|
@ -146,7 +146,7 @@ export function getParents(elem, selector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getParentsUntil(elem, parent, selector) {
|
export function getParentsUntil(elem, parent, selector) {
|
||||||
let parents = [];
|
const parents = [];
|
||||||
let parentType;
|
let parentType;
|
||||||
let selectorType;
|
let selectorType;
|
||||||
if ( parent ) {
|
if ( parent ) {
|
||||||
|
|
|
@ -1652,7 +1652,7 @@ export function jPickerMethod (elem, options, commitCallback, liveCallback, canc
|
||||||
let iconColor = null; // iconColor for popup icon
|
let iconColor = null; // iconColor for popup icon
|
||||||
let iconAlpha = null; // iconAlpha for popup icon
|
let iconAlpha = null; // iconAlpha for popup icon
|
||||||
let iconImage = null; // iconImage popup icon
|
let iconImage = null; // iconImage popup icon
|
||||||
let moveBar = null; // drag bar
|
const moveBar = null; // drag bar
|
||||||
Object.assign(that, {
|
Object.assign(that, {
|
||||||
// public properties, methods, and callbacks
|
// public properties, methods, and callbacks
|
||||||
commitCallback, // commitCallback function can be overridden to return the selected color to a method you specify when the user clicks "OK"
|
commitCallback, // commitCallback function can be overridden to return the selected color to a method you specify when the user clicks "OK"
|
||||||
|
|
|
@ -221,7 +221,7 @@ export default {
|
||||||
// setSelectMode();
|
// setSelectMode();
|
||||||
});
|
});
|
||||||
|
|
||||||
let oldToolSourceCancel = $id('tool_source_cancel');
|
const oldToolSourceCancel = $id('tool_source_cancel');
|
||||||
const toolSourceCancel = oldToolSourceCancel.cloneNode(true);
|
const toolSourceCancel = oldToolSourceCancel.cloneNode(true);
|
||||||
toolSourceCancel.style.display = 'none';
|
toolSourceCancel.style.display = 'none';
|
||||||
toolSourceCancel.id = 'foreign_cancel';
|
toolSourceCancel.id = 'foreign_cancel';
|
||||||
|
|
|
@ -76,7 +76,7 @@ export default {
|
||||||
const y = opts.mouse_y / zoom;
|
const y = opts.mouse_y / zoom;
|
||||||
|
|
||||||
// We do our own formatting
|
// We do our own formatting
|
||||||
let text = svgEditor.i18next.t(`${name}:text`, { x, y });
|
const text = svgEditor.i18next.t(`${name}:text`, { x, y });
|
||||||
// Show the text using the custom alert function
|
// Show the text using the custom alert function
|
||||||
alert(text);
|
alert(text);
|
||||||
}
|
}
|
||||||
|
|
|
@ -507,7 +507,7 @@ export default {
|
||||||
libOpts.style.display = 'none';
|
libOpts.style.display = 'none';
|
||||||
back.style.display = 'block';
|
back.style.display = 'block';
|
||||||
});
|
});
|
||||||
let span = document.createElement("span");
|
const span = document.createElement("span");
|
||||||
span.textContent = description;
|
span.textContent = description;
|
||||||
li.appendChild(span);
|
li.appendChild(span);
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
// can't use npm version as the dragmove is different.
|
// can't use npm version as the dragmove is different.
|
||||||
|
|
||||||
let _loaded = false;
|
let _loaded = false;
|
||||||
let _callbacks = [];
|
const _callbacks = [];
|
||||||
const _isTouch = window.ontouchstart !== undefined;
|
const _isTouch = window.ontouchstart !== undefined;
|
||||||
|
|
||||||
export const dragmove = function(target, handler, parent, onStart, onEnd, onDrag) {
|
export const dragmove = function(target, handler, parent, onStart, onEnd, onDrag) {
|
||||||
|
|
|
@ -104,7 +104,7 @@ export default {
|
||||||
const items = txt.split(';');
|
const items = txt.split(';');
|
||||||
selElems.forEach((elem) => {
|
selElems.forEach((elem) => {
|
||||||
if (elem && elem.getAttribute('class').includes('placemark')) {
|
if (elem && elem.getAttribute('class').includes('placemark')) {
|
||||||
let elements = elem.children;
|
const elements = elem.children;
|
||||||
Array.prototype.forEach.call(elements, function(i, _){
|
Array.prototype.forEach.call(elements, function(i, _){
|
||||||
const [ , , type, n ] = i.id.split('_');
|
const [ , , type, n ] = i.id.split('_');
|
||||||
if (type === 'txt') {
|
if (type === 'txt') {
|
||||||
|
@ -125,7 +125,7 @@ export default {
|
||||||
font = font.join(' ');
|
font = font.join(' ');
|
||||||
selElems.forEach((elem) => {
|
selElems.forEach((elem) => {
|
||||||
if (elem && elem.getAttribute('class').includes('placemark')) {
|
if (elem && elem.getAttribute('class').includes('placemark')) {
|
||||||
let elements = elem.children;
|
const elements = elem.children;
|
||||||
Array.prototype.forEach.call(elements, function(i, _){
|
Array.prototype.forEach.call(elements, function(i, _){
|
||||||
const [ , , type ] = i.id.split('_');
|
const [ , , type ] = i.id.split('_');
|
||||||
if (type === 'txt') {
|
if (type === 'txt') {
|
||||||
|
|
|
@ -23,7 +23,7 @@ export default {
|
||||||
const filename = getFileNameFromTitle();
|
const filename = getFileNameFromTitle();
|
||||||
|
|
||||||
// $.post(saveSvgAction, { output_svg: svg, filename });
|
// $.post(saveSvgAction, { output_svg: svg, filename });
|
||||||
let postData = { output_svg: svg, filename };
|
const postData = { output_svg: svg, filename };
|
||||||
fetch(saveSvgAction, {
|
fetch(saveSvgAction, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify(postData)
|
body: JSON.stringify(postData)
|
||||||
|
|
|
@ -1020,7 +1020,7 @@ export const setContext = function (elem) {
|
||||||
|
|
||||||
// Disable other elements
|
// Disable other elements
|
||||||
const parentsUntil = getParentsUntil(elem, '#svgcontent');
|
const parentsUntil = getParentsUntil(elem, '#svgcontent');
|
||||||
let siblings = [];
|
const siblings = [];
|
||||||
parentsUntil.forEach(function (parent) {
|
parentsUntil.forEach(function (parent) {
|
||||||
const elements = Array.prototype.filter.call(parent.parentNode.children, function(child){
|
const elements = Array.prototype.filter.call(parent.parentNode.children, function(child){
|
||||||
return child !== parent;
|
return child !== parent;
|
||||||
|
|
|
@ -209,7 +209,7 @@ class SvgCanvas {
|
||||||
return this._storage.has(element) && this._storage.get(element).has(key);
|
return this._storage.has(element) && this._storage.get(element).has(key);
|
||||||
},
|
},
|
||||||
remove: function (element, key) {
|
remove: function (element, key) {
|
||||||
let ret = this._storage.get(element).delete(key);
|
const ret = this._storage.get(element).delete(key);
|
||||||
if (!this._storage.get(element).size === 0) {
|
if (!this._storage.get(element).size === 0) {
|
||||||
this._storage.delete(element);
|
this._storage.delete(element);
|
||||||
}
|
}
|
||||||
|
@ -555,7 +555,7 @@ class SvgCanvas {
|
||||||
|
|
||||||
const restoreRefElems = function (elem) {
|
const restoreRefElems = function (elem) {
|
||||||
// Look for missing reference elements, restore any found
|
// Look for missing reference elements, restore any found
|
||||||
let attrs = {};
|
const attrs = {};
|
||||||
refAttrs.forEach(function (item, _) {
|
refAttrs.forEach(function (item, _) {
|
||||||
attrs[item] = elem.getAttribute(item);
|
attrs[item] = elem.getAttribute(item);
|
||||||
});
|
});
|
||||||
|
|
|
@ -576,7 +576,7 @@ function groupBBFix(selected) {
|
||||||
let ret; let copy;
|
let ret; let copy;
|
||||||
|
|
||||||
if (ref) {
|
if (ref) {
|
||||||
let elements = [];
|
const elements = [];
|
||||||
Array.prototype.forEach.call(ref.children, function (el) {
|
Array.prototype.forEach.call(ref.children, function (el) {
|
||||||
const elem = el.cloneNode(true);
|
const elem = el.cloneNode(true);
|
||||||
elem.setAttribute('visibility', 'hidden');
|
elem.setAttribute('visibility', 'hidden');
|
||||||
|
|
Loading…
Reference in New Issue