Skip to content

Commit

Permalink
resolved2
Browse files Browse the repository at this point in the history
  • Loading branch information
gautam-divyanshu committed Jan 9, 2025
2 parents 65efd33 + 5893198 commit 4a94f87
Show file tree
Hide file tree
Showing 108 changed files with 5,279 additions and 3,499 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,13 @@
"docs/sidebars.ts",
"docs/src/**",
"docs/blog/**"
],
"overrides": [
{
"files": ["*.js"],
"rules": {
"@typescript-eslint/explicit-function-return-type": "off"
}
}
]
}
150 changes: 150 additions & 0 deletions .github/workflows/css_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""Check TypeScript files for CSS violations and embedded CSS."""

import argparse
import os
import re
import sys


def check_embedded_css(content: str) -> list:
"""
Check for embedded CSS in the content.
Args:
content: The content of the file to check.
Returns:
A list of embedded CSS violations found.
"""
embedded_css_pattern = r"#([0-9a-fA-F]{3}){1,2}" # Matches CSS color codes
return re.findall(embedded_css_pattern, content)


def check_files(
directory: str, exclude_files: list, exclude_directories: list, allowed_css_patterns: list
) -> tuple:
"""
Check TypeScript files for CSS violations and print correct CSS imports.
Args:
directory: The directory to check.
exclude_files: List of files to exclude from analysis.
exclude_directories: List of directories to exclude from analysis.
allowed_css_patterns: List of allowed CSS file patterns.
Returns:
A tuple containing lists of violations, correct CSS imports, and embedded CSS violations.
"""
violations = []
correct_css_imports = []
embedded_css_violations = []

# Normalize exclude paths
exclude_files = set(os.path.abspath(file) for file in exclude_files)
exclude_directories = set(os.path.abspath(dir) for dir in exclude_directories)

for root, _, files in os.walk(directory):
# Skip excluded directories
if any(root.startswith(exclude_dir) for exclude_dir in exclude_directories):
continue

for file in files:
file_path = os.path.abspath(os.path.join(root, file))

# Skip excluded files
if file_path in exclude_files:
continue

# Process TypeScript files
if file.endswith((".ts", ".tsx")) and "test" not in root:
try:
with open(file_path, "r", encoding="utf-8") as f:
content = f.read()
except (IOError, UnicodeDecodeError) as e:
print(f"Error reading file {file_path}: {e}")
continue

# Check for CSS imports with an improved regex pattern
css_imports = re.findall(
r'import\s+.*?["\'](.*?\.css)["\'];', content
)
for css_file in css_imports:
# 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}"
)
else:
violations.append(
f"Invalid CSS import ({css_file}) in {file_path}"
)

# Check for embedded CSS
embedded_css = check_embedded_css(content)
if embedded_css:
embedded_css_violations.append(
f"Embedded CSS found in {file_path}: {', '.join(embedded_css)}"
)

return violations, correct_css_imports, embedded_css_violations


def main():
"""Run the CSS check script."""
parser = argparse.ArgumentParser(
description="Check for CSS violations in TypeScript files."
)
parser.add_argument("--directory", required=True, help="Directory to check.")
parser.add_argument(
"--exclude_files",
nargs="*",
default=[],
help="Specific files to exclude from analysis.",
)
parser.add_argument(
"--exclude_directories",
nargs="*",
default=[],
help="Directories to exclude from analysis.",
)
parser.add_argument(
"--allowed_css_patterns",
nargs="*",
default=["app.module.css"],
help="Allowed CSS file patterns.",
)
args = parser.parse_args()

violations, correct_css_imports, embedded_css_violations = check_files(
directory=args.directory,
exclude_files=args.exclude_files,
exclude_directories=args.exclude_directories,
allowed_css_patterns=args.allowed_css_patterns,
)

if violations:
print("\nCSS Import Violations:")
print("\n".join(violations))

if embedded_css_violations:
print("\nEmbedded CSS Violations:")
print("\n".join(embedded_css_violations))

if correct_css_imports:
print("\nCorrect CSS Imports:")
print("\n".join(correct_css_imports))
else:
print("\nNo correct CSS imports found.")

if violations or embedded_css_violations:
sys.exit(1) # Exit with error code if violations found
else:
print("\nNo CSS violations found.")
sys.exit(0) # Exit with success code


if __name__ == "__main__":
main()

65 changes: 65 additions & 0 deletions .github/workflows/merge-conflict-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Merge Conflict Check Workflow

on:
pull_request:
branches:
- '**'
types:
- opened
- reopened
- synchronize
- ready_for_review

jobs:
Merge-Conflict-Check:
name: Check for Merge Conflicts
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Check Mergeable Status via Github API
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
max_retries=3
retry_delay=5
for ((i=1; i<=max_retries; i++)); do
echo "Attempt $i of $max_retries"
if ! response=$(gh api "repos/${{ github.repository }}/pulls/$PR_NUMBER" --jq '.mergeable'); then
if [[ $response == *"rate limit exceeded"* ]]; then
echo "Rate limit exceeded. Waiting before retry..."
sleep 60 # Wait longer for rate limit
else
echo "Failed to call GitHub API: $response"
if [ $i -eq $max_retries ]; then
echo "Maximum retries reached. Exiting."
exit 1
fi
sleep $retry_delay
fi
continue
fi
case "$response" in
"true")
echo "No conflicts detected."
exit 0
;;
"false")
echo "Merge conflicts detected."
exit 1
;;
*)
echo "Mergeable status unknown: $response"
if [ $i -eq $max_retries ]; then
echo "Maximum retries reached. Exiting."
exit 1
fi
sleep $retry_delay
;;
esac
done
16 changes: 15 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ jobs:
chmod +x ./.github/workflows/scripts/countline.py
./.github/workflows/scripts/countline.py --lines 600 --exclude_files src/screens/LoginPage/LoginPage.tsx src/GraphQl/Queries/Queries.ts src/screens/OrgList/OrgList.tsx src/GraphQl/Mutations/mutations.ts src/components/EventListCard/EventListCardModals.tsx src/components/TagActions/TagActionsMocks.ts src/utils/interfaces.ts src/screens/MemberDetail/MemberDetail.tsx
# Run the CSS import check script
- name: Check for CSS violations and print correct imports
run: |
if [ ! -f ./.github/workflows/css_check.py ]; then
echo "Error: CSS check script not found"
exit 1
fi
chmod +x ./.github/workflows/css_check.py
./.github/workflows/css_check.py --directory . || {
echo "Error: CSS check failed"
exit 1
}
- name: Get changed TypeScript files
id: changed-files
uses: tj-actions/changed-files@v45
Expand Down Expand Up @@ -97,6 +110,7 @@ jobs:
with:
files: |
.env*
vitest.config.js
src/App.tsx
.github/**
env.example
Expand Down Expand Up @@ -436,7 +450,7 @@ jobs:
name: Validate CodeRabbit Approval
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
needs: [Code-Quality-Checks, Test-Application, Start-App-Without-Docker, Docker-Start-Check]
needs: [Test-Docusaurus-Deployment]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/scripts/validate-coderabbit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ else
echo " of the PR web page, add a comment with the"
echo " statement below to restart a review"
echo ""
echo "@coderabbitai full review"
echo " @coderabbitai full review"
echo ""
exit 1
fi
5 changes: 2 additions & 3 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ name: Mark stale issues and pull requests

on:
schedule:
- cron: "0 0 * * *"
- cron: "0 * * * *"

permissions:
issues: write
pull-requests: write

jobs:
stale:

name: Process Stale Issues and PRs
runs-on: ubuntu-latest

steps:
- uses: actions/stale@v9
with:
Expand Down
2 changes: 0 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run format:fix
# npm run lint:fix
Expand Down
Empty file added 3141
Empty file.
2 changes: 1 addition & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/.github/ @palisadoes
CODEOWNERS @palisadoes
# CODEOWNERS @palisadoes
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export default {
],
coverageThreshold: {
global: {
lines: 20,
statements: 20,
lines: 1,
statements: 1,
},
},
testPathIgnorePatterns: [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"format:check": "prettier --check \"**/*.{ts,tsx,json,scss,css}\"",
"check-tsdoc": "node .github/workflows/check-tsdoc.js",
"typecheck": "tsc --project tsconfig.json --noEmit",
"prepare": "husky install",
"prepare": "husky",
"jest-preview": "jest-preview",
"update:toc": "node scripts/githooks/update-toc.js",
"lint-staged": "lint-staged --concurrent false",
Expand Down
1 change: 1 addition & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,7 @@
"endOfResults": "endOfResults"
},
"userChat": {
"title": "Chats",
"add": "Add",
"chat": "Chat",
"search": "Search",
Expand Down
1 change: 1 addition & 0 deletions public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,7 @@
"endOfResults": "Fin des résultats"
},
"userChat": {
"title": "Discussions",
"add": "Ajouter",
"chat": "Chat",
"contacts": "Contacts",
Expand Down
1 change: 1 addition & 0 deletions public/locales/hi/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,7 @@
"endOfResults": "परिणाम समाप्त"
},
"userChat": {
"title": "चैट्स",
"add": "जोड़ें",
"chat": "बात करना",
"contacts": "संपर्क",
Expand Down
1 change: 1 addition & 0 deletions public/locales/sp/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,7 @@
"createAdvertisement": "Crear publicidad"
},
"userChat": {
"title": "Chats",
"add": "Agregar",
"chat": "Charlar",
"search": "Buscar",
Expand Down
1 change: 1 addition & 0 deletions public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,7 @@
"endOfResults": "结果结束"
},
"userChat": {
"title": "聊天",
"add": "添加",
"chat": "聊天",
"contacts": "联系方式",
Expand Down
4 changes: 2 additions & 2 deletions scripts/githooks/check-localstorage-usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ if (filesWithLocalStorage.length > 0) {

console.info(
'\x1b[34m%s\x1b[0m',
'\nInfo: Consider using custom hook functions.'
'\nInfo: Consider using custom hook functions.',
);
console.info(
'Please use the getItem, setItem, and removeItem functions provided by the custom hook useLocalStorage.\n'
'Please use the getItem, setItem, and removeItem functions provided by the custom hook useLocalStorage.\n',
);

process.exit(1);
Expand Down
Loading

0 comments on commit 4a94f87

Please sign in to comment.