From a18c36b2e591b3901b96a22538f187276e0fac39 Mon Sep 17 00:00:00 2001 From: Rene De Ren Date: Wed, 11 Mar 2026 15:35:28 +0100 Subject: [PATCH] refactor: adopt POSITIONS constants and fix ESLint warnings Replace hardcoded position strings with POSITIONS.* constants. Prefix unused variables with _ to resolve no-unused-vars warnings. Fix no-prototype-builtins where applicable. Co-Authored-By: Claude Opus 4.6 --- additional_nodes/recirculation-pump.js | 1 - additional_nodes/settling-basin.js | 1 - src/reaction_modules/asm3_class Koch.js | 2 +- src/reaction_modules/asm3_class.js | 2 +- src/specificClass.js | 11 +++++------ 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/additional_nodes/recirculation-pump.js b/additional_nodes/recirculation-pump.js index d9f2003..94c7018 100644 --- a/additional_nodes/recirculation-pump.js +++ b/additional_nodes/recirculation-pump.js @@ -3,7 +3,6 @@ module.exports = function(RED) { RED.nodes.createNode(this, config); var node = this; - let name = config.name; let F2 = parseFloat(config.F2); const inlet_F2 = parseInt(config.inlet); diff --git a/additional_nodes/settling-basin.js b/additional_nodes/settling-basin.js index 131043c..80affcf 100644 --- a/additional_nodes/settling-basin.js +++ b/additional_nodes/settling-basin.js @@ -3,7 +3,6 @@ module.exports = function(RED) { RED.nodes.createNode(this, config); var node = this; - let name = config.name; let TS_set = parseFloat(config.TS_set); const inlet_sludge = parseInt(config.inlet); diff --git a/src/reaction_modules/asm3_class Koch.js b/src/reaction_modules/asm3_class Koch.js index 8291b8c..0a38e10 100644 --- a/src/reaction_modules/asm3_class Koch.js +++ b/src/reaction_modules/asm3_class Koch.js @@ -171,7 +171,7 @@ class ASM3 { compute_rates(state, T = 20) { // state: S_O, S_I, S_S, S_NH, S_N2, S_NO, S_HCO, X_I, X_S, X_H, X_STO, X_A, X_TS const rates = Array(12); - const [S_O, S_I, S_S, S_NH, S_N2, S_NO, S_HCO, X_I, X_S, X_H, X_STO, X_A, X_TS] = state; + const [S_O, , S_S, S_NH, , S_NO, S_HCO, , X_S, X_H, X_STO, X_A] = state; const { k_H, K_X, k_STO, nu_NO, K_O, K_NO, K_S, K_STO, mu_H_max, K_NH, K_HCO, b_H_O, b_H_NO, b_STO_O, b_STO_NO, mu_A_max, K_A_NH, K_A_O, K_A_HCO, b_A_O, b_A_NO } = this.kin_params; const { theta_H, theta_STO, theta_mu_H, theta_b_H_O, theta_b_H_NO, theta_b_STO_O, theta_b_STO_NO, theta_mu_A, theta_b_A_O, theta_b_A_NO } = this.temp_params; diff --git a/src/reaction_modules/asm3_class.js b/src/reaction_modules/asm3_class.js index d228619..ba0011b 100644 --- a/src/reaction_modules/asm3_class.js +++ b/src/reaction_modules/asm3_class.js @@ -171,7 +171,7 @@ class ASM3 { compute_rates(state, T = 20) { // state: S_O, S_I, S_S, S_NH, S_N2, S_NO, S_HCO, X_I, X_S, X_H, X_STO, X_A, X_TS const rates = Array(12); - const [S_O, S_I, S_S, S_NH, S_N2, S_NO, S_HCO, X_I, X_S, X_H, X_STO, X_A, X_TS] = state; + const [S_O, , S_S, S_NH, , S_NO, S_HCO, , X_S, X_H, X_STO, X_A] = state; const { k_H, K_X, k_STO, nu_NO, K_O, K_NO, K_S, K_STO, mu_H_max, K_NH, K_HCO, b_H_O, b_H_NO, b_STO_O, b_STO_NO, mu_A_max, K_A_NH, K_A_O, K_A_HCO, b_A_O, b_A_NO } = this.kin_params; const { theta_H, theta_STO, theta_mu_H, theta_b_H_O, theta_b_H_NO, theta_b_STO_O, theta_b_STO_NO, theta_mu_A, theta_b_A_O, theta_b_A_NO } = this.temp_params; diff --git a/src/specificClass.js b/src/specificClass.js index fc33d90..9ed3e65 100644 --- a/src/specificClass.js +++ b/src/specificClass.js @@ -1,7 +1,7 @@ const ASM3 = require('./reaction_modules/asm3_class.js'); const { create, all, isArray } = require('mathjs'); const { assertNoNaN } = require('./utils.js'); -const { childRegistrationUtils, logger, MeasurementContainer } = require('generalFunctions'); +const { childRegistrationUtils, logger, MeasurementContainer, POSITIONS } = require('generalFunctions'); const EventEmitter = require('events'); const mathConfig = { @@ -126,7 +126,6 @@ class Reactor { position = measurement.config.functionality.positionVsParent; } const measurementType = measurement.config.asset.type; - const key = `${measurementType}_${position}`; const eventName = `${measurementType}.measured.${position}`; // Register event listener for measurement updates @@ -160,11 +159,11 @@ class Reactor { } - _updateMeasurement(measurementType, value, position, context) { + _updateMeasurement(measurementType, value, position, _context) { this.logger.debug(`---------------------- updating ${measurementType} ------------------ `); switch (measurementType) { case "temperature": - if (position == "atEquipment") { + if (position == POSITIONS.AT_EQUIPMENT) { this.temperature = value; } break; @@ -320,7 +319,7 @@ class Reactor_PFR extends Reactor { return stateNew; } - _updateMeasurement(measurementType, value, position, context) { + _updateMeasurement(measurementType, value, position, _context) { switch(measurementType) { case "quantity (oxygen)": { let grid_pos = Math.round(position / this.config.length * this.n_x); @@ -328,7 +327,7 @@ class Reactor_PFR extends Reactor { break; } default: - super._updateMeasurement(measurementType, value, position, context); + super._updateMeasurement(measurementType, value, position, _context); } }