-
-
Notifications
You must be signed in to change notification settings - Fork 802
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
Fixed ESLint bugs that required ts-specific rules for js functions and added prettier formatting (re-open #3184) #3229
base: develop-postgres
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request focuses on enhancing the Changes
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Finishing Touches
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
Documentation and Community
|
Our Pull Request Approval ProcessThanks for contributing! Testing Your CodeRemember, your PRs won't be reviewed until these criteria are met:
Our policies make our code better. ReviewersDo not assign reviewers. Our Queue Monitors will review your PR and assign them.
Reviewing Your CodeYour reviewer(s) will have the following roles:
CONTRIBUTING.mdRead our CONTRIBUTING.md file. Most importantly:
Other
|
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 comments (1)
scripts/githooks/check-localstorage-usage.js (1)
Line range hint
21-40
: Update file pattern to include .js filesThe grep pattern
.tsx\\?$
only matches.ts
and.tsx
files, but based on the PR objectives, we need to check JavaScript files as well.Update the pattern to include .js files:
- const result = execSync('git ls-files | grep ".tsx\\?$"', { + const result = execSync('git ls-files | grep "\\.(js|tsx?)$"', {
🧹 Nitpick comments (1)
scripts/githooks/check-localstorage-usage.js (1)
Line range hint
45-78
: Enhance localStorage detection robustnessThe current checks might miss some localStorage usages. Consider these improvements:
if ( - content.includes('localStorage.getItem') || - content.includes('localStorage.setItem') || - content.includes('localStorage.removeItem') + content.match(/\blocalStorage\.(getItem|setItem|removeItem|clear|key|\[["'].*?["']\])/g) || + content.match(/\bwindow\.localStorage\b/g) ) {This will also catch:
- Direct property access (e.g.,
localStorage['key']
)localStorage.clear()
andlocalStorage.key()
- References through
window.localStorage
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
scripts/githooks/check-localstorage-usage.js
(4 hunks)
🧰 Additional context used
📓 Learnings (1)
scripts/githooks/check-localstorage-usage.js (1)
Learnt from: MayankJha014
PR: PalisadoesFoundation/talawa-admin#2612
File: scripts/githooks/check-localstorage-usage.js:10-18
Timestamp: 2024-12-07T14:25:09.928Z
Learning: TypeScript type annotations should not be added to JavaScript (`.js`) files in this project. Type annotations can only be used in TypeScript (`.ts` or `.tsx`) files.
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Test Application
- GitHub Check: Analyse Code With CodeQL (javascript)
🔇 Additional comments (3)
scripts/githooks/check-localstorage-usage.js (3)
Line range hint
10-20
: Well-implemented skip comment mechanism!The function provides a clean way to handle exceptions with proper error handling and follows JavaScript conventions correctly.
92-95
: LGTM! Clear and well-formatted messagesThe console messages are properly formatted and provide helpful guidance about using custom hooks.
Line range hint
10-78
: Verify all TypeScript-specific ESLint rulesLet's ensure no other TypeScript-specific rules are being enforced on this JavaScript file.
✅ Verification successful
TypeScript ESLint rules are properly handled
The only TypeScript-specific rule being enforced is
@typescript-eslint/explicit-function-return-type
, which is appropriately disabled for each arrow function. No other TypeScript-specific rules are being enforced on this JavaScript file.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for TypeScript-specific ESLint rules in the ESLint config files echo "Checking ESLint configs for TypeScript-specific rules..." fd -e json -e js -e yaml -e yml . | xargs rg "@typescript-eslint|parserOptions.*typescript" -A 5 -B 5 # Verify if there are any other TypeScript-related ESLint errors in the file echo "Checking for TypeScript-related ESLint errors..." npx eslint scripts/githooks/check-localstorage-usage.js --format json | jq '.[] | select(.messages[].ruleId | contains("@typescript"))'Length of output: 20683
Hello @palisadoes, Since modifying the ESLint configuration file was causing linting errors in other PRs, I opted to ignore the rule only in the conflicting file rather than updating the entire ESLint configuration. Please review the changes in these files and let me know if there are any suggestions for improving the PR. Thanks! |
What kind of change does this PR introduce?
BugFix
Issue Number:
Fixes #3184
Did you add tests for your changes?
No
Snapshots/Videos:
Before
After
If relevant, did you update the documentation?
Not applicable
Does this PR introduce a breaking change?
No
Other information
Problem 1 : ESLint was configured to check typescript-specific return type for javascript file.
So i added comments to ignore the rule for javascript rules.
Problem 2: Prettier Test was failing since there were some missing commas in console.info
So i ran the prettier write command to fix that format to a better format.
Have you read the contributing guide?
Yes
Summary by CodeRabbit