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?) */
|
||||
"sonarjs/cognitive-complexity": [ "warn", 200 ],
|
||||
/** @todo no param reassign creates too many warnings but should be a warning */
|
||||
"comma-dangle": [ "error" ],
|
||||
"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,
|
||||
"no-unused-vars": [ "error", { "argsIgnorePattern": "^_" } ],
|
||||
"sonarjs/no-duplicate-string": 0,
|
||||
"semi" : "error",
|
||||
"prefer-const": "error",
|
||||
"no-trailing-spaces": "error",
|
||||
"array-bracket-spacing": [ "error", "always" ],
|
||||
"comma-spacing": "error",
|
||||
|
@ -85,7 +90,8 @@ module.exports = {
|
|||
{
|
||||
files: [ 'src/editor/locale/*.js' ],
|
||||
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);
|
||||
},
|
||||
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) {
|
||||
this._storage.delete(element);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ describe('select', function () {
|
|||
return this._storage.has(element) && this._storage.get(element).has(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) {
|
||||
this._storage.delete(element);
|
||||
}
|
||||
|
|
|
@ -281,11 +281,11 @@ class Editor extends EditorStartup {
|
|||
parentSelector = document;
|
||||
}
|
||||
|
||||
let parents = [];
|
||||
const parents = [];
|
||||
let p = el.parentNode;
|
||||
|
||||
while (p !== parentSelector) {
|
||||
let o = p;
|
||||
const o = p;
|
||||
parents.push(o);
|
||||
p = o.parentNode;
|
||||
}
|
||||
|
|
|
@ -255,7 +255,7 @@ class EditorStartup {
|
|||
});
|
||||
|
||||
function addListenerMulti(element, eventNames, listener) {
|
||||
let events = eventNames.split(' ');
|
||||
const events = eventNames.split(' ');
|
||||
for (let i=0, iLen=events.length; i<iLen; i++) {
|
||||
element.addEventListener(events[i], listener, false);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ export function isObject(item) {
|
|||
}
|
||||
|
||||
export function mergeDeep(target, source) {
|
||||
let output = Object.assign({}, target);
|
||||
const output = Object.assign({}, target);
|
||||
if (isObject(target) && isObject(source)) {
|
||||
Object.keys(source).forEach((key) => {
|
||||
if (isObject(source[key])) {
|
||||
|
@ -146,7 +146,7 @@ export function getParents(elem, selector) {
|
|||
}
|
||||
|
||||
export function getParentsUntil(elem, parent, selector) {
|
||||
let parents = [];
|
||||
const parents = [];
|
||||
let parentType;
|
||||
let selectorType;
|
||||
if ( parent ) {
|
||||
|
|
|
@ -1652,7 +1652,7 @@ export function jPickerMethod (elem, options, commitCallback, liveCallback, canc
|
|||
let iconColor = null; // iconColor for popup icon
|
||||
let iconAlpha = null; // iconAlpha for popup icon
|
||||
let iconImage = null; // iconImage popup icon
|
||||
let moveBar = null; // drag bar
|
||||
const moveBar = null; // drag bar
|
||||
Object.assign(that, {
|
||||
// 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"
|
||||
|
|
|
@ -221,7 +221,7 @@ export default {
|
|||
// setSelectMode();
|
||||
});
|
||||
|
||||
let oldToolSourceCancel = $id('tool_source_cancel');
|
||||
const oldToolSourceCancel = $id('tool_source_cancel');
|
||||
const toolSourceCancel = oldToolSourceCancel.cloneNode(true);
|
||||
toolSourceCancel.style.display = 'none';
|
||||
toolSourceCancel.id = 'foreign_cancel';
|
||||
|
|
|
@ -76,7 +76,7 @@ export default {
|
|||
const y = opts.mouse_y / zoom;
|
||||
|
||||
// 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
|
||||
alert(text);
|
||||
}
|
||||
|
|
|
@ -507,7 +507,7 @@ export default {
|
|||
libOpts.style.display = 'none';
|
||||
back.style.display = 'block';
|
||||
});
|
||||
let span = document.createElement("span");
|
||||
const span = document.createElement("span");
|
||||
span.textContent = description;
|
||||
li.appendChild(span);
|
||||
});
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// can't use npm version as the dragmove is different.
|
||||
|
||||
let _loaded = false;
|
||||
let _callbacks = [];
|
||||
const _callbacks = [];
|
||||
const _isTouch = window.ontouchstart !== undefined;
|
||||
|
||||
export const dragmove = function(target, handler, parent, onStart, onEnd, onDrag) {
|
||||
|
|
|
@ -104,7 +104,7 @@ export default {
|
|||
const items = txt.split(';');
|
||||
selElems.forEach((elem) => {
|
||||
if (elem && elem.getAttribute('class').includes('placemark')) {
|
||||
let elements = elem.children;
|
||||
const elements = elem.children;
|
||||
Array.prototype.forEach.call(elements, function(i, _){
|
||||
const [ , , type, n ] = i.id.split('_');
|
||||
if (type === 'txt') {
|
||||
|
@ -125,7 +125,7 @@ export default {
|
|||
font = font.join(' ');
|
||||
selElems.forEach((elem) => {
|
||||
if (elem && elem.getAttribute('class').includes('placemark')) {
|
||||
let elements = elem.children;
|
||||
const elements = elem.children;
|
||||
Array.prototype.forEach.call(elements, function(i, _){
|
||||
const [ , , type ] = i.id.split('_');
|
||||
if (type === 'txt') {
|
||||
|
|
|
@ -23,7 +23,7 @@ export default {
|
|||
const filename = getFileNameFromTitle();
|
||||
|
||||
// $.post(saveSvgAction, { output_svg: svg, filename });
|
||||
let postData = { output_svg: svg, filename };
|
||||
const postData = { output_svg: svg, filename };
|
||||
fetch(saveSvgAction, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(postData)
|
||||
|
|
|
@ -1020,7 +1020,7 @@ export const setContext = function (elem) {
|
|||
|
||||
// Disable other elements
|
||||
const parentsUntil = getParentsUntil(elem, '#svgcontent');
|
||||
let siblings = [];
|
||||
const siblings = [];
|
||||
parentsUntil.forEach(function (parent) {
|
||||
const elements = Array.prototype.filter.call(parent.parentNode.children, function(child){
|
||||
return child !== parent;
|
||||
|
|
|
@ -209,7 +209,7 @@ class SvgCanvas {
|
|||
return this._storage.has(element) && this._storage.get(element).has(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) {
|
||||
this._storage.delete(element);
|
||||
}
|
||||
|
@ -555,7 +555,7 @@ class SvgCanvas {
|
|||
|
||||
const restoreRefElems = function (elem) {
|
||||
// Look for missing reference elements, restore any found
|
||||
let attrs = {};
|
||||
const attrs = {};
|
||||
refAttrs.forEach(function (item, _) {
|
||||
attrs[item] = elem.getAttribute(item);
|
||||
});
|
||||
|
|
|
@ -576,7 +576,7 @@ function groupBBFix(selected) {
|
|||
let ret; let copy;
|
||||
|
||||
if (ref) {
|
||||
let elements = [];
|
||||
const elements = [];
|
||||
Array.prototype.forEach.call(ref.children, function (el) {
|
||||
const elem = el.cloneNode(true);
|
||||
elem.setAttribute('visibility', 'hidden');
|
||||
|
|
Loading…
Reference in New Issue