add more linter warnings

master
JFH 2021-05-14 23:28:12 +02:00
parent 1bad5b9037
commit 8b82f1b4d5
9 changed files with 29 additions and 23 deletions

View File

@ -30,6 +30,14 @@ module.exports = {
"array-bracket-spacing": [ "error", "always" ], "array-bracket-spacing": [ "error", "always" ],
"comma-spacing": "error", "comma-spacing": "error",
"object-curly-spacing": [ "error", "always" ], "object-curly-spacing": [ "error", "always" ],
"valid-jsdoc": "warn",
"no-console": [
"warn",
{ "allow": [ "warn", "error", "info", "table" ] }
],
"no-param-reassign": [ "warn", { "props": false } ],
"max-len": [ "warn", { "code": 150 } ],
"arrow-parens": [ "error", "always" ],
}, },
overrides: [ overrides: [
{ {
@ -41,9 +49,7 @@ module.exports = {
mocha: true, mocha: true,
node: true node: true
}, },
globals: { globals: { "assert": true },
"assert": true
},
rules: { rules: {
// with ci, instrumented is not created before linter // with ci, instrumented is not created before linter
"import/no-unresolved": [ 2, { ignore: [ 'instrumented' ] } ], "import/no-unresolved": [ 2, { ignore: [ 'instrumented' ] } ],

View File

@ -331,7 +331,7 @@ class MainMenu {
*/ */
$id("tool_clear").addEventListener("click", this.clickClear.bind(this)); $id("tool_clear").addEventListener("click", this.clickClear.bind(this));
$id("tool_open").addEventListener("click", e => { $id("tool_open").addEventListener("click", (e) => {
e.preventDefault(); e.preventDefault();
this.clickOpen(); this.clickOpen();
window.dispatchEvent(new CustomEvent("openImage")); window.dispatchEvent(new CustomEvent("openImage"));

View File

@ -23,7 +23,7 @@ export function isObject(item) {
export function mergeDeep(target, source) { export function mergeDeep(target, source) {
let output = Object.assign({}, target); let 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])) {
if (!(key in target)) if (!(key in target))
Object.assign(output, { [key]: source[key] }); Object.assign(output, { [key]: source[key] });

View File

@ -136,7 +136,7 @@ export default {
const parentElem = document.querySelector("#overviewMiniView"); const parentElem = document.querySelector("#overviewMiniView");
dragmove(dragElem, dragElem, parentElem, onStart, onEnd, onDrag); dragmove(dragElem, dragElem, parentElem, onStart, onEnd, onDrag);
$id("overviewMiniView").addEventListener("click", evt => { $id("overviewMiniView").addEventListener("click", (evt) => {
// Firefox doesn't support evt.offsetX and evt.offsetY. // Firefox doesn't support evt.offsetX and evt.offsetY.
const mouseX = (evt.offsetX || evt.originalEvent.layerX); const mouseX = (evt.offsetX || evt.originalEvent.layerX);
const mouseY = (evt.offsetY || evt.originalEvent.layerY); const mouseY = (evt.offsetY || evt.originalEvent.layerY);

View File

@ -25,7 +25,7 @@ export default {
* @param {boolean} on * @param {boolean} on
* @returns {void} * @returns {void}
*/ */
const showPanel = on => { const showPanel = (on) => {
$id("polygon_panel").style.display = on ? "block" : "none"; $id("polygon_panel").style.display = on ? "block" : "none";
}; };
@ -43,13 +43,13 @@ export default {
* @param {Float} n * @param {Float} n
* @returns {Float} * @returns {Float}
*/ */
const cot = n => 1 / Math.tan(n); const cot = (n) => 1 / Math.tan(n);
/** /**
* @param {Float} n * @param {Float} n
* @returns {Float} * @returns {Float}
*/ */
const sec = n => 1 / Math.cos(n); const sec = (n) => 1 / Math.cos(n);
return { return {
name: svgEditor.i18next.t(`${name}:name`), name: svgEditor.i18next.t(`${name}:name`),
@ -88,7 +88,7 @@ export default {
`; `;
$id("tools_top").appendChild(panelTemplate.content.cloneNode(true)); $id("tools_top").appendChild(panelTemplate.content.cloneNode(true));
$id("polygon_panel").style.display = "none"; $id("polygon_panel").style.display = "none";
$id("polySides").addEventListener("change", event => { $id("polySides").addEventListener("change", (event) => {
setAttr("sides", event.target.value); setAttr("sides", event.target.value);
}); });
}, },

View File

@ -173,7 +173,7 @@ class LayersPanel {
"change", "change",
this.lmenuFunc.bind(this) this.lmenuFunc.bind(this)
); );
$id("se-cmenu-layers-list").addEventListener("change", e => { $id("se-cmenu-layers-list").addEventListener("change", (e) => {
this.lmenuFunc(e); this.lmenuFunc(e);
}); });
$id("sidepanel_handle").addEventListener( $id("sidepanel_handle").addEventListener(
@ -183,7 +183,7 @@ class LayersPanel {
if (this.editor.configObj.curConfig.showlayers) { if (this.editor.configObj.curConfig.showlayers) {
this.toggleSidePanel(); this.toggleSidePanel();
} }
$id("sidepanel_handle").addEventListener("mousedown", evt => { $id("sidepanel_handle").addEventListener("mousedown", (evt) => {
this.sidedrag = evt.pageX; this.sidedrag = evt.pageX;
window.addEventListener("mousemove", this.resizeSidePanel.bind(this)); window.addEventListener("mousemove", this.resizeSidePanel.bind(this));
this.allowmove = false; this.allowmove = false;
@ -192,14 +192,14 @@ class LayersPanel {
this.allowmove = true; this.allowmove = true;
}, 20); }, 20);
}); });
$id("sidepanel_handle").addEventListener("mouseup", _evt => { $id("sidepanel_handle").addEventListener("mouseup", (_evt) => {
if (!this.sidedragging) { if (!this.sidedragging) {
this.toggleSidePanel(); this.toggleSidePanel();
} }
this.sidedrag = -1; this.sidedrag = -1;
this.sidedragging = false; this.sidedragging = false;
}); });
window.addEventListener("mouseup", _evt => { window.addEventListener("mouseup", (_evt) => {
this.sidedrag = -1; this.sidedrag = -1;
this.sidedragging = false; this.sidedragging = false;
$id("svg_editor").removeEventListener( $id("svg_editor").removeEventListener(
@ -353,7 +353,7 @@ class LayersPanel {
} }
if (layerNameToHighlight) { if (layerNameToHighlight) {
curNames.forEach(curName => { curNames.forEach((curName) => {
if (curName !== layerNameToHighlight) { if (curName !== layerNameToHighlight) {
this.editor.svgCanvas this.editor.svgCanvas
.getCurrentDrawing() .getCurrentDrawing()
@ -361,7 +361,7 @@ class LayersPanel {
} }
}); });
} else { } else {
curNames.forEach(curName => { curNames.forEach((curName) => {
this.editor.svgCanvas.getCurrentDrawing().setLayerOpacity(curName, 1.0); this.editor.svgCanvas.getCurrentDrawing().setLayerOpacity(curName, 1.0);
}); });
} }

View File

@ -28,7 +28,7 @@ class LeftPanel {
updateLeftPanel(button) { updateLeftPanel(button) {
if (button.disabled) return false; if (button.disabled) return false;
// remove the pressed state on other(s) button(s) // remove the pressed state on other(s) button(s)
$qa("#tools_left *[pressed]").forEach(b => { $qa("#tools_left *[pressed]").forEach((b) => {
b.pressed = false; b.pressed = false;
}); });
// pressed state for the clicked button // pressed state for the clicked button

View File

@ -152,7 +152,7 @@ class TopPanel {
* @returns {void} * @returns {void}
*/ */
updateContextPanel() { updateContextPanel() {
const setInputWidth = elem => { const setInputWidth = (elem) => {
const w = Math.min(Math.max(12 + elem.value.length * 6, 50), 300); const w = Math.min(Math.max(12 + elem.value.length * 6, 50), 300);
elem.style.width = w + 'px'; elem.style.width = w + 'px';
}; };
@ -313,7 +313,7 @@ class TopPanel {
const curPanel = panels[tagName]; const curPanel = panels[tagName];
$id(tagName + "_panel").style.display = 'block'; $id(tagName + "_panel").style.display = 'block';
curPanel.forEach(item => { curPanel.forEach((item) => {
let attrVal = elem.getAttribute(item); let attrVal = elem.getAttribute(item);
if (this.editor.configObj.curConfig.baseUnit !== "px" && elem[item]) { if (this.editor.configObj.curConfig.baseUnit !== "px" && elem[item]) {
const bv = elem[item].baseVal.value; const bv = elem[item].baseVal.value;
@ -1040,7 +1040,7 @@ class TopPanel {
"click", "click",
this.clickGroup.bind(this) this.clickGroup.bind(this)
); );
$id("tool_position").addEventListener("change", evt => $id("tool_position").addEventListener("change", (evt) =>
this.clickAlignEle.bind(this)(evt) this.clickAlignEle.bind(this)(evt)
); );
$id("tool_align_left").addEventListener("click", () => $id("tool_align_left").addEventListener("click", () =>
@ -1130,7 +1130,7 @@ class TopPanel {
"image_height", "image_height",
"path_node_x", "path_node_x",
"path_node_y" "path_node_y"
].forEach(attrId => ].forEach((attrId) =>
$id(attrId).addEventListener("change", this.attrChanger.bind(this)) $id(attrId).addEventListener("change", this.attrChanger.bind(this))
); );
} }