From ef7d09c611518729c85d6c0713a82f276f82816b Mon Sep 17 00:00:00 2001 From: sayali-2308 Date: Thu, 26 Feb 2026 21:48:56 -0500 Subject: [PATCH 1/2] fix: resolve SonarCloud issues - node imports, lang attribute, duplicate selector --- postinstall.js | 5 ++--- public/emailFormat.html | 4 ++-- public/index.css | 12 ------------ refactor-css-classes.js | 32 ++++++++++++-------------------- 4 files changed, 16 insertions(+), 37 deletions(-) diff --git a/postinstall.js b/postinstall.js index 6325c0e091..36c0027727 100644 --- a/postinstall.js +++ b/postinstall.js @@ -1,10 +1,9 @@ // Script to copy tinymce to public folder. Read more: https://www.tiny.cloud/docs/tinymce/latest/react-pm-host/ const fse = require('fs-extra'); -const path = require('path'); +const path = require('node:path'); const topDir = __dirname; -// const topDir = import.meta.dirname; fse.emptyDirSync(path.join(topDir, 'public', 'tinymce')); fse.copySync(path.join(topDir, 'node_modules', 'tinymce'), path.join(topDir, 'public', 'tinymce'), { overwrite: true, -}); +}); \ No newline at end of file diff --git a/public/emailFormat.html b/public/emailFormat.html index 3a7af10312..c176fbd69d 100644 --- a/public/emailFormat.html +++ b/public/emailFormat.html @@ -1,9 +1,9 @@ - + Hello, World

Hello, World

- + \ No newline at end of file diff --git a/public/index.css b/public/index.css index 3b776350f3..93d65327c5 100644 --- a/public/index.css +++ b/public/index.css @@ -7,24 +7,12 @@ /* THEME ROOT (BODY / ROOT) */ /* ========================= */ -body.dark-mode:not(.no-global-theme), -body.bm-dashboard-dark:not(.no-global-theme) { - background-color: #1b2a41 !important; - color: #ffffff !important; -} - body.dark-mode:not(.no-global-theme) #root, body.bm-dashboard-dark:not(.no-global-theme) #root { background-color: #1b2a41 !important; color: #ffffff !important; } -/* SAFE BASE (dark mode) */ -body.dark-mode:not(.no-global-theme), -body.bm-dashboard-dark:not(.no-global-theme) { - color: #ffffff; -} - /* ========================= */ /* TYPOGRAPHY (DARK MODE) */ /* ========================= */ diff --git a/refactor-css-classes.js b/refactor-css-classes.js index 4a41662026..3bd17784dc 100644 --- a/refactor-css-classes.js +++ b/refactor-css-classes.js @@ -1,14 +1,14 @@ // updated on june 11 /* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable no-console */ -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); const postcss = require('postcss'); const safeParser = require('postcss-safe-parser'); // Helper to convert kebab-case, snake_case, pascalcase to camelCase const toCamelCase = str => { - const formatted = str.replace(/[-_](\w)/g, (_, char) => char.toUpperCase()); + const formatted = str.replaceAll(/[-_](\w)/gu, (_, char) => char.toUpperCase()); return formatted.charAt(0).toLowerCase() + formatted.slice(1); }; @@ -21,7 +21,7 @@ const convertCSSFile = filePath => { root.walkRules(rule => { const updated = rule.selectors.map(selector => { - return selector.replace(/\.(\w[\w-]*)/g, (_, className) => { + return selector.replaceAll(/\.(\w[\w-]*)/gu, (_, className) => { const camel = toCamelCase(className); classMap[className] = camel; return `.${camel}`; @@ -32,15 +32,12 @@ const convertCSSFile = filePath => { }); fs.writeFileSync(filePath, root.toString()); - // eslint-disable-next-line no-console console.log(`βœ… Updated CSS: ${filePath}`); - // eslint-disable-next-line no-console - // console.log('classMap after CSS processing:', classMap); }; // Step 2: Replace import statement for CSS module in JSX const replaceImportStatement = code => { - const importRegex = /import\s+['"](.+\/)?([a-zA-Z0-9_-]+)\.css['"];/; + const importRegex = /import\s+['"](.+\/)?([a-zA-Z0-9_-]+)\.css['"];/u; // eslint-disable-next-line default-param-last return code.replace(importRegex, (_, pathPrefix = '', cssFileName) => { return `import styles from '${pathPrefix}${cssFileName}.module.css';`; @@ -64,8 +61,8 @@ const replaceInCodeFile = filePath => { } // Step 2: Replace className="text-light input-file-upload" β†’ className={styles.textLight + " " + styles.inputFileUpload} - code = code.replace(/className\s*=\s*["']([^"']+)["']/g, (_, classStr) => { - const classList = classStr.trim().split(/\s+/); + code = code.replaceAll(/className\s*=\s*["']([^"']+)["']/gu, (_, classStr) => { + const classList = classStr.trim().split(/\s+/u); // Skip transforming if no class in classList exists in classMap if (classList.every(cls => !classMap[cls])) { @@ -98,7 +95,7 @@ const walkDir = dir => { if (stats.isDirectory()) { walkDir(fullPath); } else if (file.endsWith('.css')) { - cssFiles.push(fullPath); // Add CSS file path to the array + cssFiles.push(fullPath); } else if ( file.endsWith('.js') || file.endsWith('.jsx') || @@ -106,28 +103,23 @@ const walkDir = dir => { file.endsWith('.tsx') || file.endsWith('.html') ) { - codeFiles.push(fullPath); // Add JS/JSX file path to the array + codeFiles.push(fullPath); } }); // Now process CSS files first cssFiles.forEach(cssFile => { console.log('Processing CSS file:', cssFile); - convertCSSFile(cssFile); // Process CSS files + convertCSSFile(cssFile); }); // Then process code files (JS/JSX, etc.) codeFiles.forEach(codeFile => { console.log('Processing code file:', codeFile); - replaceInCodeFile(codeFile); // Process JS/JSX files + replaceInCodeFile(codeFile); }); }; // πŸš€ Start here: Replace with your actual project folder path const rootDir = 'src/components/HGNForm'; -walkDir(rootDir); - -// const mapPath = path.join(__dirname, 'class-map.json'); -// fs.writeFileSync(mapPath, JSON.stringify(classMap, null, 2)); -// // eslint-disable-next-line no-console -// console.log(`πŸ—ΊοΈ Class map written to ${mapPath}`); +walkDir(rootDir); \ No newline at end of file From 1e2af668eb8af94edcec9459feda7fac72658310 Mon Sep 17 00:00:00 2001 From: sayali-2308 Date: Thu, 26 Feb 2026 22:12:28 -0500 Subject: [PATCH 2/2] fix: format files with prettier to pass CI checks --- postinstall.js | 2 +- refactor-css-classes.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/postinstall.js b/postinstall.js index 36c0027727..571e1dcde4 100644 --- a/postinstall.js +++ b/postinstall.js @@ -6,4 +6,4 @@ const topDir = __dirname; fse.emptyDirSync(path.join(topDir, 'public', 'tinymce')); fse.copySync(path.join(topDir, 'node_modules', 'tinymce'), path.join(topDir, 'public', 'tinymce'), { overwrite: true, -}); \ No newline at end of file +}); diff --git a/refactor-css-classes.js b/refactor-css-classes.js index 3bd17784dc..12a78646d5 100644 --- a/refactor-css-classes.js +++ b/refactor-css-classes.js @@ -122,4 +122,4 @@ const walkDir = dir => { // πŸš€ Start here: Replace with your actual project folder path const rootDir = 'src/components/HGNForm'; -walkDir(rootDir); \ No newline at end of file +walkDir(rootDir);