From de16068ef502e27fe6ff9b634c2a3246329effb6 Mon Sep 17 00:00:00 2001 From: Lennart Brinkmann Date: Thu, 5 Sep 2024 21:17:45 +0200 Subject: [PATCH 1/5] fix linter errors. --- README.md | 5 +++++ admin/adapter-settings.js | 2 +- admin/admin.js | 8 ++++---- eslint.config.cjs | 3 +-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 31ef0c37..6133f79e 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,11 @@ You can thank the authors by these links: * to Arthur Rupp https://paypal.me/ArthurRupp ----------------------------------------------------------------------------------------------------- +## Changelog + +### UNRELEASED +* (lebrinkma) fix linter errors + ### 1.10.9 (2024-09-05) * (arteck) typo admin settings * (arteck) eslint config diff --git a/admin/adapter-settings.js b/admin/adapter-settings.js index e8beaf3b..f649cf36 100644 --- a/admin/adapter-settings.js +++ b/admin/adapter-settings.js @@ -152,7 +152,7 @@ function prepareTooltips() { link = 'https://github.com/ioBroker/ioBroker.' + common.name + '#' + id; } } - if (!link.match('^https?:\/\/')) { + if (!link.match('^https?:\/\/')) { //eslint-disable-line no-useless-escape if (common.readme) { link = common.readme + '#' + link; } else { diff --git a/admin/admin.js b/admin/admin.js index eb4286ba..8b5482e2 100644 --- a/admin/admin.js +++ b/admin/admin.js @@ -396,7 +396,7 @@ function editName(id, name) { if (d.hasOwnProperty('memberinfo')) { for (const member of d.memberinfo) { const epid = EndPointIDfromEndPoint(member.ep); - for (var i = 0; i < groupables.length; i++) { + for (let i = 0; i < groupables.length; i++) { if (groupables[i].epid == epid) { groupables[i].memberOf.push(d.native.id.replace('group_', '')); } @@ -406,7 +406,7 @@ function editName(id, name) { } } console.log('groupables: ' + JSON.stringify(groupables)); - for (var i = 0; i < groupables.length; i++) { + for (let i = 0; i < groupables.length; i++) { if (i > 1) { $('#modaledit').find('translate.device_with_endpoint').innerHtml = name + ' ' + groupables[i].epid; } @@ -419,7 +419,7 @@ function editName(id, name) { const newName = $('#modaledit').find('input[id=\'d_name\']').val(); const groupsbyid = {}; if (groupables.length > 0) { - for (var i = 0; i < groupables.length; i++) { + for (let i = 0; i < groupables.length; i++) { const ng = $('#d_groups_ep' + i).val(); if (ng.toString() != groupables[i].memberOf.toString()) groupsbyid[groupables[i].ep.ID] = GenerateGroupChange(groupables[i].memberOf, ng); @@ -2794,7 +2794,7 @@ function doFilter(inputText) { break; default: valid = true; } - } + } return valid; }); } else { diff --git a/eslint.config.cjs b/eslint.config.cjs index 2c911fa6..f3d4f495 100644 --- a/eslint.config.cjs +++ b/eslint.config.cjs @@ -11,7 +11,7 @@ const compat = new FlatCompat({ module.exports = [ { - ignores: ['.dev-server/**'], + ignores: ['.dev-server/**', 'admin/*.min.js'], }, ...compat.extends('eslint:recommended', 'plugin:prettier/recommended'), { @@ -38,7 +38,6 @@ module.exports = [ 'no-fallthrough': 'off', 'no-console': 'off', 'no-prototype-builtins': 'off', - 'no-useless-escape': 'off', 'no-undef': 'warn', 'no-empty': 'warn', 'no-var': 'warn', From 067bdd08b0978998c895274dfa239dec9760dee3 Mon Sep 17 00:00:00 2001 From: Lennart Brinkmann Date: Thu, 5 Sep 2024 21:18:15 +0200 Subject: [PATCH 2/5] fix indentations, no more linter errors. --- admin/adapter-settings.js | 22 +++++++++++----------- admin/admin.js | 28 ++++++++++++++-------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/admin/adapter-settings.js b/admin/adapter-settings.js index f649cf36..aaf6045b 100644 --- a/admin/adapter-settings.js +++ b/admin/adapter-settings.js @@ -96,23 +96,23 @@ function loadSettings(callback) { if (typeof load === 'undefined') { alert('Please implement save function in your admin/index.html'); } else { - const _query = query.split('&'); - for (var q = 0; q < _query.length; q++) { - if (_query[q].indexOf('react=') !== -1) { - $('.adapter-container').addClass('react-' + _query[q].substring(6)); - theme = 'react-' + _query[q].substring(6); + const _query = query.split('&'); + for (var q = 0; q < _query.length; q++) { + if (_query[q].indexOf('react=') !== -1) { + $('.adapter-container').addClass('react-' + _query[q].substring(6)); + theme = 'react-' + _query[q].substring(6); + } } - } - load(res.native, onChange); + load(res.native, onChange); } if (typeof callback === 'function') { callback(); } } else { - if (typeof callback === 'function') { - callback(); - } - alert('error loading settings for ' + _adapterInstance + '\n\n' + err); + if (typeof callback === 'function') { + callback(); + } + alert('error loading settings for ' + _adapterInstance + '\n\n' + err); } }); } diff --git a/admin/admin.js b/admin/admin.js index 8b5482e2..ab27b267 100644 --- a/admin/admin.js +++ b/admin/admin.js @@ -422,7 +422,7 @@ function editName(id, name) { for (let i = 0; i < groupables.length; i++) { const ng = $('#d_groups_ep' + i).val(); if (ng.toString() != groupables[i].memberOf.toString()) - groupsbyid[groupables[i].ep.ID] = GenerateGroupChange(groupables[i].memberOf, ng); + groupsbyid[groupables[i].ep.ID] = GenerateGroupChange(groupables[i].memberOf, ng); } } console.log('grpid ' + JSON.stringify(groupsbyid)); @@ -529,7 +529,7 @@ function showDevices() { } else { //if (d.groups && d.info && d.info.device._type == "Router") { if (d.groups) { -// devGroups[d._id] = d.groups; + //devGroups[d._id] = d.groups; if (typeof d.groups.map == 'function') { d.groupNames = d.groups.map(item => { return groups[item] || ''; @@ -557,10 +557,10 @@ function showDevices() { roomSelector.empty(); roomSelector.append(`
  • All
  • `); Array.from(allRooms) - .sort() - .forEach((item) => { - roomSelector.append(`
  • ${item}
  • `); - }); + .sort() + .forEach((item) => { + roomSelector.append(`
  • ${item}
  • `); + }); $('#room-filter a').click(function () { $('#room-filter-btn').text($(this).text()); doFilter(); @@ -692,7 +692,7 @@ function letsPairingWithCode(code) { showMessage(msg.error, _('Error')); } else { - showPairingProcess(); + showPairingProcess(); } }); } @@ -887,13 +887,13 @@ function load(settings, onChange) { }); $('#code_pairing').click(function () { - if (!$('#pairing').hasClass('pulse')) { - $('#codeentry a.btn[name=\'pair\']').click(() => { - const code = $('#codeentry').find('input[id=\'qr_code\']').val(); - letsPairingWithCode(code) - }); - $('#codeentry').modal('open'); - } + if (!$('#pairing').hasClass('pulse')) { + $('#codeentry a.btn[name=\'pair\']').click(() => { + const code = $('#codeentry').find('input[id=\'qr_code\']').val(); + letsPairingWithCode(code) + }); + $('#codeentry').modal('open'); + } }); $(document).ready(function () { From 789461dbd64e80d78d862f4232abf3ef5d8d8826 Mon Sep 17 00:00:00 2001 From: Lennart Brinkmann Date: Thu, 5 Sep 2024 21:49:05 +0200 Subject: [PATCH 3/5] del old eslint config. --- .eslintrc.json | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100755 .eslintrc.json diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100755 index 679590d5..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "env": { - "es6": true, - "node": true, - "mocha": true - }, - "extends": [ - "eslint:recommended" - ], - "rules": { - "indent": [ - "error", - 4, - { - "SwitchCase": 1 - } - ], - "no-console": "off", - "no-var": "error", - "no-unused-vars": "warn", - "no-trailing-spaces": "error", - "prefer-const": "warn", - "quotes": [ - "warn", - "single", - { - "avoidEscape": true, - "allowTemplateLiterals": true - } - ], - "semi": [ - "warn", - "always" - ], - "no-prototype-builtins": "off" - }, - "parserOptions": { - "ecmaVersion": 2019 - } -} From 3b672b54f2c68bcb7d3c161f4871e2e1948afe17 Mon Sep 17 00:00:00 2001 From: Lennart Brinkmann Date: Thu, 5 Sep 2024 21:53:40 +0200 Subject: [PATCH 4/5] add translations to linter ignore. --- eslint.config.cjs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eslint.config.cjs b/eslint.config.cjs index f3d4f495..77624b38 100644 --- a/eslint.config.cjs +++ b/eslint.config.cjs @@ -11,7 +11,11 @@ const compat = new FlatCompat({ module.exports = [ { - ignores: ['.dev-server/**', 'admin/*.min.js'], + ignores: [ + '.dev-server/**', + 'admin/*.min.js', + 'admin/words.js' + ], }, ...compat.extends('eslint:recommended', 'plugin:prettier/recommended'), { From 76d39ae315334ade9dcd24793626a86c6c85619f Mon Sep 17 00:00:00 2001 From: Lennart Brinkmann Date: Thu, 5 Sep 2024 22:10:56 +0200 Subject: [PATCH 5/5] fix more linter warnings. --- admin/adapter-settings.js | 13 ++++++------- admin/admin.js | 4 ++-- lib/backup.js | 1 - 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/admin/adapter-settings.js b/admin/adapter-settings.js index aaf6045b..5ba7c6c6 100644 --- a/admin/adapter-settings.js +++ b/admin/adapter-settings.js @@ -4,8 +4,8 @@ const parts = path.split('/'); parts.splice(-3); const socket = io.connect('/', { path: parts.join('/') + '/socket.io' }); -var query = (window.location.search || '').replace(/^\?/, '').replace(/#.*$/, ''); -var args = {}; +const query = (window.location.search || '').replace(/^\?/, '').replace(/#.*$/, ''); +const args = {}; let theme = null; // parse parameters @@ -14,7 +14,7 @@ query.trim().split('&').filter(function (t) { return t.trim(); }).forEach(functi if (!i && parts.length === 1 && !isNaN(parseInt(b, 10))) { args.instance = parseInt(b, 10); } - var name = parts[0]; + const name = parts[0]; args[name] = parts.length === 2 ? parts[1] : true; if (name === 'instance') { @@ -28,7 +28,7 @@ query.trim().split('&').filter(function (t) { return t.trim(); }).forEach(functi } }); -var instance = args.instance; +const instance = args.instance; let common = null; // common information of adapter const host = null; // host object on which the adapter runs @@ -97,7 +97,7 @@ function loadSettings(callback) { alert('Please implement save function in your admin/index.html'); } else { const _query = query.split('&'); - for (var q = 0; q < _query.length; q++) { + for (let q = 0; q < _query.length; q++) { if (_query[q].indexOf('react=') !== -1) { $('.adapter-container').addClass('react-' + _query[q].substring(6)); theme = 'react-' + _query[q].substring(6); @@ -207,9 +207,8 @@ function onChange(isChanged) { } function showMessage(message, title, icon) { - var $dialogMessage; // noinspection JSJQueryEfficiency - $dialogMessage = $('#dialog-message'); + let $dialogMessage = $('#dialog-message'); if (!$dialogMessage.length) { $('body').append( '