-
Notifications
You must be signed in to change notification settings - Fork 434
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
fix locale sort's path and fix format script to sort cypress dir #9070
fix locale sort's path and fix format script to sort cypress dir #9070
Conversation
Caution Review failedThe pull request is closed. WalkthroughThe changes involve updates to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Lint
participant Sorter
User->>Lint: Trigger lint-staged
Lint->>Sorter: Read locale data from public/locale/en.json
Sorter->>Sorter: Sort JSON data
Sorter->>Lint: Write sorted data back to public/locale/en.json
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hey @rithviknishad can you please review the changes? |
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (1)
scripts/sort-locales.js (1)
Line range hint
4-15
: Consider adding error handling for file operations.The script performs file operations without error handling, which could fail silently if the directory or file doesn't exist.
Consider adding basic error handling:
const fs = require("fs"); const file = "public/locale/en.json"; -const data = JSON.parse(fs.readFileSync(file, "utf8")); +try { + const data = JSON.parse(fs.readFileSync(file, "utf8")); -const sortedData = Object.keys(data) - .sort() - .reduce((acc, key) => { - acc[key] = data[key]; - return acc; - }, {}); + const sortedData = Object.keys(data) + .sort() + .reduce((acc, key) => { + acc[key] = data[key]; + return acc; + }, {}); -fs.writeFileSync(file, JSON.stringify(sortedData, null, 2) + "\n"); + fs.writeFileSync(file, JSON.stringify(sortedData, null, 2) + "\n"); + console.log(`Successfully sorted locale file: ${file}`); +} catch (error) { + console.error(`Error processing locale file: ${error.message}`); + process.exit(1); +}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
package.json
(1 hunks)scripts/sort-locales.js
(1 hunks)
🔇 Additional comments (4)
scripts/sort-locales.js (1)
4-4
: Verify the existence of the new locale directory structure.
The path change from src/Locale/en.json
to public/locale/en.json
looks good and aligns with common practices of storing static assets in the public directory. However, we should ensure the new structure is properly set up.
Let's verify the directory structure and check for other locale files:
✅ Verification successful
Path change to public/locale/en.json
is properly implemented
The verification confirms:
- The new
public/locale
directory exists and is properly set up - Multiple locale files are present (
en.json
,hi.json
,kn.json
,ml.json
,mr.json
,ta.json
) - No references to the old path
src/Locale
were found in the codebase
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify locale directory structure and files
# Check if the new directory exists
if [ -d "public/locale" ]; then
echo "✓ public/locale directory exists"
else
echo "✗ public/locale directory not found"
fi
# List all JSON files in the locale directory
echo "Locale files found:"
fd -e json . public/locale
# Check if there are any remaining references to the old path
echo "Checking for old path references:"
rg -i "src/Locale" --type js --type json --type ts
Length of output: 439
package.json (3)
169-171
: Ensure sort-locales script is updated.
The lint-staged configuration points to the new locale path. Verify that the sort-locales
script in scripts/sort-locales.js
has been updated to use the same path.
#!/bin/bash
# Description: Verify sort-locales script is updated with new path
# Check the sort-locales script for path references
echo "Checking sort-locales script..."
rg -i "locale" scripts/sort-locales.js
Line range hint 173-175
: Verify npm version compatibility with Node.js requirement.
The package requires Node.js >=22.11.0
but specifies npm@10.9.0
. Please verify this combination is compatible, as npm versions typically align with specific Node.js versions.
#!/bin/bash
# Description: Check for any npm version related issues in the repository
# Look for npm-related warnings or errors in package-lock.json
echo "Checking package-lock.json for version conflicts..."
rg -i "npm" package-lock.json
# Check for engine-strict configuration
echo "Checking for engine-strict configuration..."
rg -i "engine-strict" .npmrc
Also applies to: 176-176
169-171
: Verify the architectural decision to move locale files.
Moving locale files from src/
to public/
directory represents a significant architectural change. While this makes the files directly accessible at runtime, please ensure this aligns with your build and deployment strategy.
✅ Verification successful
The locale path change is properly implemented and consistent
The verification shows that:
- No files exist in the old
src/Locale
directory - Multiple locale files (en, hi, kn, ml, mr, ta) are present in the new
public/locale
directory - The
sort-locales.js
script has been updated to use the new path - No other references to the old path exist in the codebase
The architectural change to move locale files to public/locale
appears to be complete and consistent across the codebase. This is a valid approach as it makes the locale files directly accessible as static assets.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the existence and usage of locale files in both old and new locations
# Check if files exist in both locations
echo "Checking locale file locations..."
fd -t f -e json . src/Locale/
fd -t f -e json . public/locale/
# Look for any remaining references to the old path
echo "Checking for references to old path..."
rg -i "src/Locale" -g '!package.json'
Length of output: 515
Script:
#!/bin/bash
# Let's verify the locale file locations and references more thoroughly
# Check for locale files in both locations
echo "=== Checking locale files in src/Locale ==="
fd -t f -e json . "src/Locale"
echo -e "\n=== Checking locale files in public/locale ==="
fd -t f -e json . "public/locale"
# Search for imports or requires of locale files
echo -e "\n=== Checking for locale file imports/requires ==="
rg -l "(?i)(import|require).*locale.*\.json"
# Check for any webpack or build config files that might handle locales
echo -e "\n=== Checking build configurations ==="
fd -e config.js -e webpack.config.js
# Look for references to locale paths in JavaScript/TypeScript files
echo -e "\n=== Checking for locale path references ==="
rg "(?i)(src/Locale|public/locale)" -g "*.{js,jsx,ts,tsx}"
Length of output: 957
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice find @JavidSumra
@JavidSumra @JavidSumra Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌 |
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit
New Features
Bug Fixes