From 5c28787ff61c786c3681e19f343a9663d77525cf Mon Sep 17 00:00:00 2001 From: rishabhr4 <118053976+rishabhr4@users.noreply.github.com> Date: Tue, 8 Oct 2024 21:10:11 +0530 Subject: [PATCH] refactor: switch to optional chaining in custom filters and update eslint config (#1274) --- .eslintrc | 2 +- apps/nunjucks-filters/src/customFilters.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.eslintrc b/.eslintrc index 38ad4e746..727aafeae 100644 --- a/.eslintrc +++ b/.eslintrc @@ -13,7 +13,7 @@ extends: - plugin:sonarjs/recommended parserOptions: - ecmaVersion: 2018 + ecmaVersion: 2020 sourceType: module ecmaFeatures: jsx: true diff --git a/apps/nunjucks-filters/src/customFilters.js b/apps/nunjucks-filters/src/customFilters.js index 670554fa3..7d5339f17 100644 --- a/apps/nunjucks-filters/src/customFilters.js +++ b/apps/nunjucks-filters/src/customFilters.js @@ -198,7 +198,7 @@ function replaceServerVariablesWithValues(url, serverVariables) { const getVariableValue = (object, variable) => { const keyValue = object[variable]._json; - if (keyValue) return keyValue.default || (keyValue.enum && keyValue.enum[0]); + if (keyValue) return keyValue.default ?? keyValue.enum?.[0]; }; const urlVariables = getVariablesNamesFromUrl(url);