-
-
Notifications
You must be signed in to change notification settings - Fork 811
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
feat: added Check for embedded CSS and the correct stylesheet in Typescript files #3261
base: develop-postgres
Are you sure you want to change the base?
feat: added Check for embedded CSS and the correct stylesheet in Typescript files #3261
Conversation
WalkthroughA new Python script Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (2)
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: 3
🧹 Nitpick comments (1)
.github/workflows/pull-request.yml (1)
43-50
: Consider adding exclusions for generated TypeScript files.The current file pattern might include generated TypeScript files that shouldn't be checked for CSS violations.
- name: Get changed TypeScript files id: changed-ts-files uses: tj-actions/changed-files@v45 with: files: | **/*.ts **/*.tsx + files_ignore: | + **/*.generated.ts + **/*.gen.ts + **/dist/**
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/css_check.py
(1 hunks).github/workflows/pull-request.yml
(1 hunks)
🧰 Additional context used
📓 Learnings (1)
📓 Common learnings
Learnt from: IITI-tushar
PR: PalisadoesFoundation/talawa-admin#3041
File: .github/workflows/css_check.py:11-22
Timestamp: 2025-01-07T09:50:29.019Z
Learning: In the talawa-admin project, CSS validation in TypeScript files should only check for hex color codes using the pattern `#([0-9a-fA-F]{3}){1,2}` and ensure that files only reference the `src/style/app.module.css` stylesheet.
🪛 GitHub Check: Performs linting, formatting, type-checking, checking for different source and target branch
.github/workflows/css_check.py
[warning] 1-1:
File ignored by default.
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Test Application
- GitHub Check: Analyse Code With CodeQL (javascript)
🔇 Additional comments (2)
.github/workflows/css_check.py (2)
9-21
: LGTM! Function correctly implements CSS color code detection.The implementation aligns with the project requirements for detecting hex color codes.
59-59
: Reconsider excluding test files from CSS validation.The current implementation skips files in test directories, but CSS violations in test files could still impact the application.
@palisadoes i have updated the code to run for files changed in the PR... |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop-postgres #3261 +/- ##
=====================================================
+ Coverage 10.74% 90.21% +79.47%
=====================================================
Files 309 330 +21
Lines 7802 8491 +689
Branches 1729 1934 +205
=====================================================
+ Hits 838 7660 +6822
+ Misses 6900 601 -6299
- Partials 64 230 +166 ☔ View full report in Codecov by Sentry. |
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.
See comments
f"Embedded CSS found in {file_path}: {', '.join(embedded_css)}" | ||
) | ||
|
||
return violations, correct_css_imports, embedded_css_violations |
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.
Return a namedtuple. There is less risk of mistakes later by other contributors
print("\n".join(violations)) | ||
|
||
if embedded_css_violations: | ||
print("\nEmbedded CSS Violations:") |
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.
- Use a single string and at the end give an explanation of what the contributor must do. Use the python """ string representation to achieve this.
- We need contributors to understand the next steps and fix things without having to ask why
- It reduces the workload of the reviewers
- Give the color code and line number in the message. Make it easier for the end user to rectify the situation
) | ||
|
||
if violations: | ||
print("\nCSS Import Violations:") |
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.
- Use a single string and at the end give an explanation of what the contributor must do. Use the python """ string representation to achieve this.
- We need contributors to understand the next steps and fix things without having to ask why
- It reduces the workload of the reviewers
|
||
if correct_css_imports: | ||
print("\nCorrect CSS Imports:") | ||
print("\n".join(correct_css_imports)) |
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.
Make printing successes an optional message based on a argparse CLI flag.
print("\nCorrect CSS Imports:") | ||
print("\n".join(correct_css_imports)) | ||
else: | ||
print("\nNo correct CSS imports found.") |
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.
This isn't necessary. Please remove
embedded_css = check_embedded_css(content) | ||
if embedded_css: | ||
embedded_css_violations.append( | ||
f"Embedded CSS found in {file_path}: {', '.join(embedded_css)}" |
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.
Make this a named tuple with only the variable names. Add the text at the time of printing.
) | ||
else: | ||
violations.append( | ||
f"Invalid CSS import ({css_file}) in {file_path}" |
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.
Make this a named tuple with only the variable names. Add the text at the time of printing.
# Check if the CSS import matches the allowed patterns | ||
if any(css_file.endswith(pattern) for pattern in allowed_css_patterns): | ||
correct_css_imports.append( | ||
f"Correct CSS import ({css_file}) in {file_path}" |
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.
Make this a named tuple with only the variable names. Add the text at the time of printing.
|
||
# Check for CSS imports with an improved regex pattern | ||
css_imports = re.findall( | ||
r'import\s+.*?["\'](.*?\.css)["\'];', content |
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.
There is no test to see whether the CSS file actually exists. Please fix.
continue | ||
|
||
# Check for CSS imports with an improved regex pattern | ||
css_imports = re.findall( |
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.
How do you handle the use of single or double quotes? What does prettier apply, if relevant?
What kind of change does this PR introduce?
feature
Issue Number:#2907
Fixes #2907
Snapshots/Videos:
If relevant, did you update the documentation?
Summary
Other information
Have you read the contributing guide?
yes
Summary by CodeRabbit
New Features
Chores