From 9140665f5a9c2638569a090a52fdca0df3ff5d46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 11 Mar 2024 23:37:56 +0100 Subject: [PATCH] Activate no-constant-condition rule of eslint --- sao/eslint.config.mjs | 1 - sao/src/common.js | 12 ++++++------ sao/tests/sao.js | 9 ++++----- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/sao/eslint.config.mjs b/sao/eslint.config.mjs index ba02fae098..22713fc032 100644 --- a/sao/eslint.config.mjs +++ b/sao/eslint.config.mjs @@ -21,7 +21,6 @@ export default [ }, }, rules: { - "no-constant-condition": "off", "no-empty": "off", "no-extra-boolean-cast": "off", "no-prototype-builtins": "off", diff --git a/sao/src/common.js b/sao/src/common.js index b879be2d59..53fee99554 100644 --- a/sao/src/common.js +++ b/sao/src/common.js @@ -1022,7 +1022,8 @@ read_token: function() { var quoted = false; var escapedstate = ' '; - while (true) { + const always = true; + while (always) { var nextchar = this.instream.read(1); if (this.state === null) { this.token = ''; // past en of file @@ -1166,13 +1167,12 @@ try { var lex = new Sao.common.udlex(input); var tokens = []; - while (true) { + do { var token = lex.next(); - if (token === null) { - break; + if (token !== null) { + tokens.push(token); } - tokens.push(token); - } + } while (token !== null); tokens = this.group_operator(tokens); tokens = this.parenthesize(tokens); tokens = this.group(tokens); diff --git a/sao/tests/sao.js b/sao/tests/sao.js index 94ba6753d8..44da512b2a 100644 --- a/sao/tests/sao.js +++ b/sao/tests/sao.js @@ -1505,13 +1505,12 @@ var udlex = function(input) { var lex = new Sao.common.udlex(input); var tokens = []; - while (true) { + do { var token = lex.next(); - if (token === null) { - break; + if (token !== null) { + tokens.push(token); } - tokens.push(token); - } + } while (token !== null); return tokens; }; var c = function(clause) {