Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup/jslinter suppressions #8234

Merged
merged 10 commits into from
Jun 1, 2024
15 changes: 7 additions & 8 deletions UI/__mocks__/dijit/registry.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
/* eslint-disable no-shadow */
// Borrowed from dijit/registry to avoid pulling in all Dojo/Dijit

const registry = Object.create(null);

function findWidgets(root, skipNode) {
var outAry = [];

function getChildrenHelper(root){
for(var node = root.firstChild; node; node = node.nextSibling){
if(node.getAttribute && node.getAttribute("widgetid")){
outAry.push(node);
}else if(node !== skipNode){
getChildrenHelper(node);
function getChildrenHelper (node) {
for(var el = node.firstChild; el; el = el.nextSibling){
if(el.getAttribute && el.getAttribute("widgetid")){
outAry.push(el);
}else if(el !== skipNode){
getChildrenHelper(el);
}
}
}
Expand All @@ -22,4 +21,4 @@ function findWidgets(root, skipNode) {

registry.findWidgets = findWidgets;

module.exports = registry;
module.exports = registry;
1 change: 0 additions & 1 deletion UI/js-src/lsmb/menus/Tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ define([
complete = true;
}
},
// eslint-disable-next-line no-unused-vars
getRoot: function (onItem, onError) {
onItem({ id: 0 });
}
Expand Down
13 changes: 5 additions & 8 deletions UI/js-src/lsmb/parts/PartDescription.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ define([
channel: null,
height: null,
store: partRestStore,
/* eslint no-template-curly-in-string:0 */
queryExpr: "*${0}*",
autoComplete: false,
highlightMatch: "all",
Expand All @@ -40,18 +39,16 @@ define([
dropDownClass: _ComboBoxMenu,
autoSizing: true,
startup: function () {
var self = this;
this.inherited(arguments);
if (this.channel) {
this.own(
topic.subscribe(this.channel, function (selected) {
self.set("value", selected[self.searchAttr]);
topic.subscribe(this.channel, (selected) => {
this.set("value", selected[this.searchAttr]);
})
);
// eslint-disable-next-line no-unused-vars
this.on("change", function (newValue) {
if (self.item) {
topic.publish(self.channel, self.item);
this.on("change", () => {
if (this.item) {
topic.publish(this.channel, this.item);
}
});
}
Expand Down
10 changes: 4 additions & 6 deletions UI/js-src/lsmb/parts/PartSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ define([
this.initialValue = arguments[0].value;
},
startup: function () {
var self = this;
this.inherited(arguments);
if (this.channel) {
this.own(
topic.subscribe(this.channel, function (selected) {
self.set("value", selected[self.searchAttr]);
topic.subscribe(this.channel, (selected) => {
this.set("value", selected[this.searchAttr]);
})
);
// eslint-disable-next-line no-unused-vars
this.on("change", function (newValue) {
topic.publish(self.channel, self.item);
this.on("change", () => {
topic.publish(this.channel, this.item);
});
}
}
Expand Down
18 changes: 7 additions & 11 deletions UI/js-src/lsmb/reports/ComparisonSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,29 @@ define([
channel: "",
mode: "by-dates",
postCreate: function () {
var self = this;
this.inherited(arguments);
this.own(
topic.subscribe(this.channel, function (action, value) {
topic.subscribe(this.channel, (action, value) => {
var display = "";

if (action === "changed-period-type") {
self.mode = value;
this.mode = value;

if (value === "by-dates") {
display = self._comparison_periods.get("value");
display = this._comparison_periods.get("value");
}
}
self._update_display(display);
this._update_display(display);
})
);
},
startup: function () {
var self = this;

this.inherited(arguments);
this._comparison_periods = registry.byId("comparison-periods");
this.own(
// eslint-disable-next-line no-unused-vars
on(this._comparison_periods, "change", function (newvalue) {
self._update_display(
self._comparison_periods.get("value")
on(this._comparison_periods, "change", () => {
this._update_display(
this._comparison_periods.get("value")
);
})
);
Expand Down
28 changes: 12 additions & 16 deletions UI/js-src/lsmb/users/ChangePassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ define([
return this.lstrings[toTranslate];
},
startup: function () {
// eslint-disable-next-line guard-for-in
for (var str in this._lstrings) {
if (this.lstrings[str]) {
continue;
Expand Down Expand Up @@ -106,7 +105,6 @@ define([
nonWords: /\W/.test(pass)
};
var variationCount = 0;
// eslint-disable-next-line guard-for-in
for (var check in variations) {
variationCount += variations[check] === true ? 1 : 0;
}
Expand All @@ -128,17 +126,16 @@ define([
domAttr.set("pw-strength", "innerHTML", score);
},
submitForm: function () {
var I = this;
var r = request;
var oldPassword = I.oldpw.get("value");
var newPassword = I.newpw.get("value");
var confirmedPassword = I.verified.get("value");
var oldPassword = this.oldpw.get("value");
var newPassword = this.newpw.get("value");
var confirmedPassword = this.verified.get("value");
if (oldPassword === "" || newPassword === "") {
I.setFeedback(false, I.text("Password Required"));
this.setFeedback(false, this.text("Password Required"));
return;
}
if (newPassword !== confirmedPassword) {
I.setFeedback(false, I.text("Confirmation did not match"));
this.setFeedback(false, this.text("Confirmation did not match"));
return;
}
r("user.pl", {
Expand All @@ -150,21 +147,20 @@ define([
},
method: "POST"
})
// eslint-disable-next-line no-unused-vars
.then(function (response) {
I.setFeedback(true, I.text("Password Changed"));
.then(() => {
this.setFeedback(true, this.text("Password Changed"));
})
.otherwise(function (err) {
.otherwise((err) => {
if (err.response.status !== 200) {
if (err.response.status !== 500) {
I.setFeedback(
this.setFeedback(
false,
I.text("Bad username/Password")
this.text("Bad username/Password")
);
} else {
I.setFeedback(
this.setFeedback(
false,
I.text("Error changing password.")
this.text("Error changing password.")
);
}
}
Expand Down
3 changes: 1 addition & 2 deletions UI/js-src/lsmb/webpack.loaderConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
*/
const path = require("path");

// eslint-disable-next-line no-unused-vars
function getConfig(env) {
function getConfig( /* env */ ) {
// env is set by the 'buildEnvironment' and/or 'environment' plugin options
// (see webpack.config.js),
// or by the code at the end of this file if using without webpack
Expand Down Expand Up @@ -85,5 +84,5 @@
module.exports = getConfig;
} else {
// No webpack. This script was loaded by page via script tag, so load Dojo from CDN
getConfig({ dojoRoot: "//ajax.googleapis.com/ajax/libs/dojo/1.16.0" });

Check warning

Code scanning / CodeQL

Superfluous trailing arguments Warning

Superfluous argument passed to
function getConfig
.
}
17 changes: 6 additions & 11 deletions UI/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"tapable": "2.2.1",
"vue": "3.4.27",
"vue-i18n": "9.13.1",
"vue-router": "4.3.2"
"vue-router": "^4.3.2"
},
"devDependencies": {
"@babel/core": "7.24.6",
Expand Down Expand Up @@ -77,7 +77,6 @@
"dojo-webpack-plugin": "3.0.6",
"ejs-loader": "0.5.0",
"eslint": "8.57.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-eslint": "10.0.0",
"eslint-config-prettier": "9.1.0",
"eslint-import-resolver-webpack": "0.13.8",
Expand Down Expand Up @@ -203,8 +202,7 @@
"rules": {
"jest/prefer-expect-assertions": "off",
"jest/no-commented-out-tests": "off",
"no-console": "off",
"camelcase": "off"
"no-console": "off"
}
},
{
Expand Down Expand Up @@ -253,7 +251,6 @@
"es6": true
},
"extends": [
"airbnb-base/legacy",
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
Expand All @@ -270,7 +267,6 @@
"!__mocks__/**"
],
"rules": {
"camelcase": "error",
"compat/compat": "warn",
"consistent-return": "error",
"curly": [
Expand All @@ -280,11 +276,7 @@
"dot-notation": "error",
"eqeqeq": "error",
"func-names": 0,
"global-require": "error",
"guard-for-in": "error",
"new-cap": 0,
"no-alert": "error",
"no-console": "error",
"no-continue": 0,
"no-else-return": "error",
"no-lonely-if": "error",
Expand All @@ -303,7 +295,10 @@
"no-use-before-define": "error",
"no-useless-escape": "error",
"no-useless-return": "error",
"one-var": "error",
"one-var": [
"error",
"never"
],
"radix": "error",
"spaced-comment": [
"error",
Expand Down
1 change: 0 additions & 1 deletion UI/src/components/ServerUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ export default {
// the widgets. (it may take a bit for the new content to overwrite the old
// content...)
query("*", document.getElementById("maindiv")).forEach(
/* eslint-disable no-param-reassign */
(n) => delete n._cssState
);
} catch (e) {
Expand Down
1 change: 0 additions & 1 deletion UI/src/elements/lsmb-base-input.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/** @format */
/* eslint-disable class-methods-use-this */

import { LsmbDijit } from "@/elements/lsmb-dijit";

Expand Down
1 change: 0 additions & 1 deletion UI/src/elements/lsmb-button.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/** @format */
/* eslint-disable class-methods-use-this */

import { LsmbDijit } from "@/elements/lsmb-dijit";

Expand Down
1 change: 0 additions & 1 deletion UI/src/elements/lsmb-date.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/** @format */
/* eslint-disable class-methods-use-this, max-classes-per-file */

import { LsmbBaseInput } from "@/elements/lsmb-base-input";

Expand Down
2 changes: 0 additions & 2 deletions UI/src/elements/lsmb-dijit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/** @format */
/* eslint-disable class-methods-use-this */

export class LsmbDijit extends HTMLElement {
dojoWidget = null;
Expand All @@ -21,7 +20,6 @@ export class LsmbDijit extends HTMLElement {
}

_collectProps() {
/* eslint-disable no-eval */
let extra = this.hasAttribute("dojo-props")
? eval("({" + this.getAttribute("dojo-props") + "})")
: {};
Expand Down
1 change: 0 additions & 1 deletion UI/src/elements/lsmb-password.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/** @format */
/* eslint-disable class-methods-use-this */

import { LsmbText } from "@/elements/lsmb-text";

Expand Down
1 change: 0 additions & 1 deletion UI/src/elements/lsmb-text.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/** @format */
/* eslint-disable class-methods-use-this, max-classes-per-file */

import { LsmbBaseInput } from "@/elements/lsmb-base-input";

Expand Down
7 changes: 2 additions & 5 deletions UI/src/i18n.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/** @format */
/* eslint-disable global-require */
/* eslint-disable camelcase, prettier/prettier */

const rtlDetect = require("rtl-detect");

Expand All @@ -14,7 +12,6 @@ function _mapLocale(locale) {
return locale;
}

// eslint-disable-next-line import/no-unresolved
import messages from '@/locales/en.json';
import { nextTick } from "vue";

Expand All @@ -38,14 +35,14 @@ export async function setI18nLanguage(lang) {
const _messages = await import(/* webpackChunkName: "lang-[request]" */ `@/locales/${locale}.json`);
i18n.global.setLocaleMessage(locale, _messages.default);
}
catch (e) {
catch {
const strippedLocale = locale.replace(/_[a-z]+/i, '');
try {
const _messages = await import(/* webpackChunkName: "lang-[request]" */ `@/locales/${strippedLocale}.json`);
i18n.global.setLocaleMessage(strippedLocale, _messages.default);
locale = strippedLocale;
}
catch (f) {
catch {
locale = "en";
}
}
Expand Down
5 changes: 1 addition & 4 deletions UI/src/main-vue.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/** @format */
/* eslint-disable no-console, import/no-unresolved, vue/multi-word-component-names */

import { createApp } from "vue";
import router from "@/router";
Expand All @@ -19,7 +18,6 @@ let appName;
let lsmbDirective = {
beforeMount(el, binding /* , vnode */) {
let handler = (event) => {
/* eslint-disable no-param-reassign */
binding.instance[binding.arg] = event.target.value;
};
el.addEventListener("input", handler);
Expand All @@ -37,8 +35,7 @@ if (document.getElementById("main")) {
mounted() {
window.__lsmbLoadLink = (url) =>
this.$router.push(
// eslint-disable-next-line no-useless-escape
url.replace(/^https?:\/\/(?:[^@\/]+)/, "")
url.replace(/^https?:\/\/(?:[^@/]+)/, "")
);

let m = document.getElementById("main");
Expand Down
2 changes: 0 additions & 2 deletions UI/src/robot-vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@ function contextRef(service, key) {
typeof service.context[key] === typeof {}
) {
const s = service;
// eslint-disable-next-line vue/no-ref-as-operand
ref = reactive(service.context[key]);
s.context[key] = ref;
} else {
// eslint-disable-next-line vue/no-ref-as-operand
ref = allocRef(service.context[key]);
}
const ctxRef = {
Expand Down
Loading
Loading