Skip to content

fix: consolidates utility functions by merging into a single utils.ts file. #3996

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

Closed

Conversation

Siddhant-Pragyan-Sinha
Copy link
Contributor

@Siddhant-Pragyan-Sinha Siddhant-Pragyan-Sinha commented Mar 31, 2025

fixes issue #3956
Describe the bug

BEFORE:-
Screenshot From 2025-03-31 11-50-20

AFTER:-
image_2025-03-31_123531524
image_2025-03-31_135427283

Summary of Changes by File

utils.test.js

  • Added comprehensive test suite for the convertToJson function to handle JSON parsing, YAML parsing, object handling, and invalid input scenarios
  • Implemented new tests for the previously uncovered pause function, verifying timeout behavior, resolution after specified time, and handling of zero/negative timeout values
  • Created thorough error handling tests for the writeJSON function, covering specific error scenarios:
    • File not found (ENOENT) errors
    • Read errors during file operations
    • Write errors when saving content
    • Conversion errors when parsing content
    • Generic error handling for unexpected issues

check-edit-links.test.js

  • Implemented test coverage for pause and logger functions.

  • Changed the import statement to match the new configuration.

tools-object.test.js

  • Implemented test coverage for convertToJson along with logger.

  • Changed the import statement to match the new file configuration.

##readAndWriteJson.test.js

  • Implemented test coverage for writeJSON along with convertToJson.

  • Used a simple mock implementation for writeJSON that matches the original test.

##extract-tools-github.test.js

  • Implemented test coverage for convertToJson along with logger.

  • Changed the import statement to match the new file configuration.

build-tools.test.js

  • Implemented logger mocking similar to tools-object.test.js to prevent warning messages from appearing in test output
  • Ensured that validation still occurs but warning output is suppressed

utils.ts

  • No direct changes to the implementation code were made

  • The logger.ts file and the readAndWriteJson.ts file components were added to it without any change in their code.

build-dashboard.test.js

  • Implemented pause function for better test coverage and to solve the errors
jest.mock('../../scripts/utils', () => ({
  logger: { error: jest.fn(), warn: jest.fn() },
  pause: jest.fn().mockResolvedValue(undefined)
  • Ensured that the file exists by writing a basic object into it

These changes collectively achieved 100% test coverage across the codebase while addressing specific issues with hanging processes and test output cleanliness.

How to test:-

  1. Clone the project locally.
  2. Run npm test to see the output

Checklist:-

  1. No error was encountered when executing tsc --noEmit .

  2. No error was encountered when executing npm run build .

  3. No error was encountered when executing npm run lint .

Feedback from maintainers and reviewers is requested, to review and do the needful changes, if any.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added utility functions for pausing execution and converting/writing JSON files with enhanced error handling.
  • Refactor

    • Consolidated and streamlined utility imports across scripts for simpler and more maintainable module access.
    • Restructured utility modules to centralize exports, removing dedicated logger and JSON utility files.
    • Updated test suites to align with new utility module structure and improve test coverage and clarity.

Copy link
Contributor

coderabbitai bot commented Mar 31, 2025

Walkthrough

This pull request consolidates several utility functions by updating import paths across various script and test files. Specifically, the writeJSON and logger functions are now imported from the more general ../utils module rather than their individual files. The changes include the addition of a new asynchronous writeJSON function in scripts/utils.ts, the export of existing functions (convertToJson and pause), and an updated Winston logger configuration. Additionally, dedicated files for the logger and read/write JSON functionality have been removed, and corresponding tests have been updated.

Changes

File(s) Change Summary
scripts/adopters/index.ts, scripts/finance/index.ts Updated import for writeJSON from specific file (readAndWriteJson) to the consolidated ../utils module.
scripts/build-meetings.ts, scripts/build-newsroom-videos.ts, scripts/build-tools.ts, scripts/compose.ts, scripts/dashboard/build-dashboard.ts, scripts/markdown/check-edit-links.ts, scripts/markdown/check-markdown.ts, scripts/tools/combine-tools.ts, scripts/tools/tools-object.ts Changed import for logger from explicit submodule paths to the broader ./utils or ../utils module, indicating a restructuring of the utility exports.
scripts/tools/extract-tools-github.ts Consolidated imports of pause and logger into a single import from ../utils; renamed function parameter from PerPage to perPage for consistent camelCase.
tests/adopters/index.test.js, tests/dashboard/build-dashboard.test.js, tests/markdown/check-edit-links.test.js, tests/markdown/check-markdown.test.js, tests/readAndWriteJson.test.js, tests/tools/combine-tools.test.js, tests/tools/extract-tools-github.test.js, tests/tools/tools-object.test.js, tests/utils.test.js Updated import statements and adjusted mocks to refer to the consolidated utils module using ES6 syntax; added tests for the new pause and writeJSON functions; enhanced mocks and assertions.
scripts/utils.ts Introduced new exports: asynchronous writeJSON, pause, and the existing convertToJson; added a new Winston logger configuration with enhanced error handling and formatting.
scripts/utils/logger.ts, scripts/utils/readAndWriteJson.ts Removed dedicated implementations for logger and writeJSON, consolidating these functionalities into the unified utils module.
package.json Updated script path for "test:locales" to run from scripts/check-locales.ts instead of scripts/utils/check-locales.ts.
scripts/check-locales.ts Updated import path for logger from './logger' to './utils'.
.github/workflows/if-nodejs-pr-testing.yml Modified grep pattern to exclude both AM and PM timestamps in locale check output.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Caller
    participant Utils as Utils Module (writeJSON)
    participant FS as File System

    Caller->>Utils: call writeJSON(readPath, writePath)
    Utils->>FS: readFile(readPath)
    FS-->>Utils: return file content
    Utils->>Utils: convertToJson(content)
    Utils->>FS: writeFile(writePath, JSON content)
    FS-->>Utils: acknowledge write completion
    Utils-->>Caller: return result (or handle error)
Loading

Suggested labels

ready-to-merge

Suggested reviewers

  • devilkiller-ag
  • anshgoyalevil
  • sambhavgupta0705
  • vishvamsinh28
  • TRohit20

Poem

I'm a rabbit, hopping through code so light,
Import paths now clear, shining ever so bright.
Logger and JSON in a single, neat stream,
Each refactor a cuddle, like a warm little dream.
I nibble on changes with an eager delight,
My whiskers twitch with joy at this streamlined flight.
🐇💻 Happy coding in our streamlined night!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Mar 31, 2025

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 928d434
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/67ea4fbf80c224000867f701
😎 Deploy Preview https://deploy-preview-3996--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f8dce7b and 400fcff.

📒 Files selected for processing (2)
  • scripts/tools/extract-tools-github.ts (1 hunks)
  • tests/tools/extract-tools-github.test.js (1 hunks)
🧰 Additional context used
🪛 ESLint
scripts/tools/extract-tools-github.ts

[error] 8-8: '/home/jailuser/git/scripts/utils.ts' imported multiple times.

(import/no-duplicates)

tests/tools/extract-tools-github.test.js

[error] 3-3: Import in body of module; reorder to top.

(import/first)


[error] 3-3: ../../scripts/utils.ts import should occur before import of axios

(import/order)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
scripts/tools/extract-tools-github.ts (1)

7-7: Combine utility imports: resolved duplicate import issue.

Great consolidation of the pause and logger imports into a single statement, which prevents duplicate-import ESLint errors and simplifies module dependencies.

🧰 Tools
🪛 ESLint

[error] 2-7: Run autofix to sort these imports!

(simple-import-sort/imports)

🧹 Nitpick comments (4)
scripts/tools/extract-tools-github.ts (2)

28-30: Rename PerPage parameter to follow camelCase.

The getReqUrl helper uses a PerPage parameter, which violates the standard camelCase naming convention in TypeScript. Consider renaming it to perPage for consistency:

-    const getReqUrl = (PerPage: number, pageNo: number) =>
-      `...?per_page=${PerPage}&page=${pageNo}`;
+    const getReqUrl = (perPage: number, pageNo: number) =>
+      `...?per_page=${perPage}&page=${pageNo}`;

18-19: Remove redundant try/catch: no additional error handling added.

The current try { ... } catch (err) { throw err; } block simply rethrows the caught error without augmenting it. You can safely eliminate the try/catch (or remove the ESLint disable for no-useless-catch) to clean up the code.

tests/tools/extract-tools-github.test.js (2)

1-3: Fix import formatting for consistency.

Add a space in the named import and ensure imports are grouped consistently:

-import { logger} from '../../scripts/utils';
+import { logger } from '../../scripts/utils';
🧰 Tools
🪛 ESLint

[error] 2-2: Missing file extension "ts" for "../../scripts/tools/extract-tools-github"

(import/extensions)


[error] 3-3: Insert ·

(prettier/prettier)


[error] 3-3: Missing file extension "ts" for "../../scripts/utils"

(import/extensions)


5-8: Verify mocking of pause invocation.

The test correctly mocks both logger.info and pause, but there's no assertion that pause is invoked when fetching additional pages. Consider adding:

expect(pause).toHaveBeenCalledWith(1000);

in the multi-page test to ensure your pagination delay logic is covered.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 400fcff and 48f934a.

📒 Files selected for processing (2)
  • scripts/tools/extract-tools-github.ts (1 hunks)
  • tests/tools/extract-tools-github.test.js (1 hunks)
🧰 Additional context used
🪛 ESLint
scripts/tools/extract-tools-github.ts

[error] 2-7: Run autofix to sort these imports!

(simple-import-sort/imports)

tests/tools/extract-tools-github.test.js

[error] 2-2: Missing file extension "ts" for "../../scripts/tools/extract-tools-github"

(import/extensions)


[error] 3-3: Insert ·

(prettier/prettier)


[error] 3-3: Missing file extension "ts" for "../../scripts/utils"

(import/extensions)

🔇 Additional comments (1)
tests/tools/extract-tools-github.test.js (1)

1-11: ESM import strategy and mock ordering is correct.

The test migrates from CommonJS to ESM for axios, getData, and mocks the entire utils module before exercising getData. Thanks to Jest’s hoisting of jest.mock, the mocks are applied in time to intercept the pause and logger imports used by getData, and the tests cover success, pagination, and error cases.

🧰 Tools
🪛 ESLint

[error] 2-2: Missing file extension "ts" for "../../scripts/tools/extract-tools-github"

(import/extensions)


[error] 3-3: Insert ·

(prettier/prettier)


[error] 3-3: Missing file extension "ts" for "../../scripts/utils"

(import/extensions)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
scripts/tools/extract-tools-github.ts (1)

2-7: Consider sorting imports

The static analysis tool flagged that these imports could be sorted more consistently.

 import axios from 'axios';
 import dotenv from 'dotenv';
 
 import type { ToolsData } from '@/types/scripts/tools';
 
-import { pause, logger } from '../utils';
+import { logger, pause } from '../utils';
🧰 Tools
🪛 ESLint

[error] 2-7: Run autofix to sort these imports!

(simple-import-sort/imports)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 48f934a and fba965f.

📒 Files selected for processing (2)
  • scripts/tools/extract-tools-github.ts (2 hunks)
  • tests/tools/extract-tools-github.test.js (1 hunks)
🧰 Additional context used
🪛 ESLint
scripts/tools/extract-tools-github.ts

[error] 2-7: Run autofix to sort these imports!

(simple-import-sort/imports)

tests/tools/extract-tools-github.test.js

[error] 2-2: Missing file extension "ts" for "../../scripts/tools/extract-tools-github"

(import/extensions)


[error] 3-3: Missing file extension "ts" for "../../scripts/utils"

(import/extensions)

⏰ Context from checks skipped due to timeout of 180000ms (1)
  • GitHub Check: Test NodeJS PR - macos-13
🔇 Additional comments (4)
scripts/tools/extract-tools-github.ts (2)

7-7: Import consolidation looks good

The consolidation of utility imports into a single statement is a positive improvement that aligns with the PR's objective of centralizing utility functions in a single utils.ts file.

🧰 Tools
🪛 ESLint

[error] 2-7: Run autofix to sort these imports!

(simple-import-sort/imports)


28-29: Parameter naming improvement

Changing from PerPage to perPage improves consistency by following JavaScript/TypeScript camelCase naming conventions.

tests/tools/extract-tools-github.test.js (2)

1-3: Import syntax modernization looks good

The switch from CommonJS require() to ES module import syntax is a positive change that makes the test file more consistent with modern JavaScript practices and matches the implementation file's syntax.

🧰 Tools
🪛 ESLint

[error] 2-2: Missing file extension "ts" for "../../scripts/tools/extract-tools-github"

(import/extensions)


[error] 3-3: Missing file extension "ts" for "../../scripts/utils"

(import/extensions)


5-7: Comprehensive mocking implementation

The Jest mock has been properly updated to include both the logger and pause functions from the consolidated utils module, which is necessary for the tests to run correctly after the utility consolidation.

@Siddhant-Pragyan-Sinha
Copy link
Contributor Author

Siddhant-Pragyan-Sinha commented Apr 22, 2025

Hey @vishvamsinh28 @sambhavgupta0705 please take a look at this PR and provide feedback regarding it.

@Siddhant-Pragyan-Sinha Siddhant-Pragyan-Sinha changed the title fix: consolidates utility functions by merging into a single utils.ts file fix: consolidates utility functions by merging into a single utils.ts file. Apr 23, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 81f70b7 and 4ca0611.

📒 Files selected for processing (1)
  • scripts/adopters/index.ts (2 hunks)
🧰 Additional context used
🪛 ESLint
scripts/adopters/index.ts

[error] 14-14: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 14-15: Delete ··⏎

(prettier/prettier)

⏰ Context from checks skipped due to timeout of 180000ms (3)
  • GitHub Check: Redirect rules - asyncapi-website
  • GitHub Check: Header rules - asyncapi-website
  • GitHub Check: Pages changed - asyncapi-website
🔇 Additional comments (1)
scripts/adopters/index.ts (1)

4-4: Import path successfully updated.

The import path has been correctly updated to use the consolidated utils.ts file, which aligns with the PR's objective of centralizing utility functions.

@Siddhant-Pragyan-Sinha
Copy link
Contributor Author

Siddhant-Pragyan-Sinha commented Apr 24, 2025

Hey @akshatnema , the PR testing for macos is failing again and again due to a test failing in build-tools.test.js, a file that has not been modified.
Can you help me with this?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
scripts/check-locales.ts (1)

185-185: Add a newline at the end of the file

The file is missing a newline at the end, which is causing linting errors. This is a minor issue but should be fixed to maintain consistent formatting.

 if (process.argv[1] === fileURLToPath(import.meta.url)) {
   validateLocales();
-}
+}
+
🧰 Tools
🪛 ESLint

[error] 185-185: Newline required at end of file but not found.

(eol-last)


[error] 185-185: Insert

(prettier/prettier)

scripts/utils.ts (3)

70-76: Add blank lines for better readability in writeJSON function

To improve code readability and follow consistent formatting practices, add blank lines after variable declarations and before return statements.

 export async function writeJSON(readPath: string, writePath: string) {
   try {
     const readContent = await readFile(readPath, 'utf-8');
     const jsonContent = convertToJson(readContent);
+    
     await writeFile(writePath, JSON.stringify(jsonContent));
+    
     return jsonContent;
   } catch (err: any) {
🧰 Tools
🪛 ESLint

[error] 73-73: Expected blank line after variable declarations.

(newline-after-var)


[error] 74-74: Expected blank line before this statement.

(padding-line-between-statements)


[error] 75-75: Expected blank line before this statement.

(padding-line-between-statements)


82-85: Fix indentation in error condition

The indentation in the error condition is inconsistent and causing linting errors. Let's fix the formatting to maintain consistent code style.

     } else if (err.message.includes('write')) {
       throw new Error(`Error while writing file\nError: ${err}`);
-    } else if (err.message.includes('Invalid content') ||
-               err.message.includes('JSON') ||
-               err.message.includes('YAML')) {
+    } else if (
+      err.message.includes('Invalid content') ||
+      err.message.includes('JSON') ||
+      err.message.includes('YAML')
+    ) {
       throw new Error(`Error while conversion\nError: ${err}`);
🧰 Tools
🪛 ESLint

[error] 82-82: Insert ⏎······

(prettier/prettier)


[error] 83-83: Delete ·········

(prettier/prettier)


[error] 84-84: Replace ·········err.message.includes('YAML') with err.message.includes('YAML')⏎····

(prettier/prettier)


90-90: Add a newline at the end of the file

The file is missing a newline at the end, which is causing linting errors. This is a minor issue but should be fixed to maintain consistent formatting.

     }
   }
-}
+}
+
🧰 Tools
🪛 ESLint

[error] 90-90: Newline required at end of file but not found.

(eol-last)


[error] 90-90: Insert

(prettier/prettier)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c52ace8 and 14361f0.

📒 Files selected for processing (4)
  • package.json (1 hunks)
  • scripts/check-locales.ts (2 hunks)
  • scripts/utils.ts (3 hunks)
  • tests/check-locales.test.js (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • package.json
  • tests/check-locales.test.js
🧰 Additional context used
🪛 ESLint
scripts/utils.ts

[error] 73-73: Expected blank line after variable declarations.

(newline-after-var)


[error] 74-74: Expected blank line before this statement.

(padding-line-between-statements)


[error] 75-75: Expected blank line before this statement.

(padding-line-between-statements)


[error] 82-82: Insert ⏎······

(prettier/prettier)


[error] 83-83: Delete ·········

(prettier/prettier)


[error] 84-84: Replace ·········err.message.includes('YAML') with err.message.includes('YAML')⏎····

(prettier/prettier)


[error] 90-90: Newline required at end of file but not found.

(eol-last)


[error] 90-90: Insert

(prettier/prettier)

scripts/check-locales.ts

[error] 185-185: Newline required at end of file but not found.

(eol-last)


[error] 185-185: Insert

(prettier/prettier)

⏰ Context from checks skipped due to timeout of 180000ms (3)
  • GitHub Check: Redirect rules - asyncapi-website
  • GitHub Check: Header rules - asyncapi-website
  • GitHub Check: Pages changed - asyncapi-website
🔇 Additional comments (3)
scripts/check-locales.ts (1)

6-6: Import path update looks good

Changing the import path from './logger' to './utils' aligns with the PR goal of consolidating utility functions into a single utils.ts file.

scripts/utils.ts (2)

2-5: Good job consolidating utility functions

The consolidation of imports, logger configuration, and utility functions into a single file improves code organization and maintainability. The exports for convertToJson and pause functions, along with the new winston logger configuration, align well with the PR objectives.

Also applies to: 15-15, 45-45, 51-65


67-90: Comprehensive error handling in writeJSON function

The error handling in the writeJSON function is well-implemented, with specific error messages for different types of failures (read errors, write errors, conversion errors). This will make debugging much easier.

🧰 Tools
🪛 ESLint

[error] 73-73: Expected blank line after variable declarations.

(newline-after-var)


[error] 74-74: Expected blank line before this statement.

(padding-line-between-statements)


[error] 75-75: Expected blank line before this statement.

(padding-line-between-statements)


[error] 82-82: Insert ⏎······

(prettier/prettier)


[error] 83-83: Delete ·········

(prettier/prettier)


[error] 84-84: Replace ·········err.message.includes('YAML') with err.message.includes('YAML')⏎····

(prettier/prettier)


[error] 90-90: Newline required at end of file but not found.

(eol-last)


[error] 90-90: Insert

(prettier/prettier)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
scripts/utils.ts (1)

76-76: Remove trailing whitespace.

There is trailing whitespace on this line that should be removed.

-    await writeFile(writePath, JSON.stringify(jsonContent));
-    
+    await writeFile(writePath, JSON.stringify(jsonContent));
🧰 Tools
🪛 ESLint

[error] 76-76: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 76-76: Delete ····

(prettier/prettier)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 14361f0 and a2d2063.

📒 Files selected for processing (3)
  • .github/workflows/if-nodejs-pr-testing.yml (1 hunks)
  • scripts/check-locales.ts (1 hunks)
  • scripts/utils.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/check-locales.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
scripts/utils.ts (2)
tests/utils.test.js (2)
  • readPath (24-24)
  • writePath (25-25)
tests/readAndWriteJson.test.js (2)
  • readPath (18-18)
  • writePath (19-19)
🪛 ESLint
scripts/utils.ts

[error] 76-76: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 76-76: Delete ····

(prettier/prettier)

🔇 Additional comments (5)
scripts/utils.ts (4)

2-3: Appropriate imports added for new functionality.

The imports for Winston and file operations are correctly added to support the newly consolidated functionality from separate files.

🧰 Tools
🪛 ESLint

[error] 1-3: Run autofix to sort these imports!

(simple-import-sort/imports)


15-15: Good export pattern for existing utility functions.

Making these previously internal utility functions (convertToJson and pause) available as exports improves reusability across the codebase.

Also applies to: 45-45


54-65: Well-configured Winston logger.

The logger implementation is properly configured with:

  • Environment variable controlled log level
  • Colorized output for better readability
  • Consistent timestamp format
  • Aligned formatting for easier scanning

70-94: Comprehensive error handling in writeJSON function.

The function effectively distinguishes between different error types:

  • Read errors (including file not found)
  • Write errors
  • Conversion errors (JSON/YAML parsing)
  • Generic errors

This will make debugging issues much clearer for developers.

🧰 Tools
🪛 ESLint

[error] 76-76: Trailing spaces not allowed.

(no-trailing-spaces)


[error] 76-76: Delete ····

(prettier/prettier)

.github/workflows/if-nodejs-pr-testing.yml (1)

136-136: Improved timestamp filtering in locale checks.

The updated regex pattern now correctly filters out log lines with both AM and PM timestamps, providing cleaner output for locale check errors.

@akshatnema
Copy link
Member

Fixed with #4049

@akshatnema akshatnema closed this Apr 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants