Skip to content

Commit

Permalink
Merge branch 'develop' into reply-functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
disha1202 authored Sep 22, 2024
2 parents 7baed1d + c952c7a commit b3032db
Show file tree
Hide file tree
Showing 77 changed files with 861 additions and 1,509 deletions.
1 change: 1 addition & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ reviews:
drafts: false
base_branches:
- develop
- main
chat:
auto_reply: true
7 changes: 3 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/explicit-function-return-type": "error",

// Interfaces must begin with Interface or TestInterface followed by a PascalCase name
"@typescript-eslint/naming-convention": [
"error",
Expand Down Expand Up @@ -107,13 +106,13 @@
],
// restrict the use of same package in multiple import statements
"import/no-duplicates": "error",

// warn/1, error/2, off/0
"tsdoc/syntax": "error",

// Typescript Rules
"@typescript-eslint/ban-ts-comment": "error",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/no-unsafe-function-type": "error",
"@typescript-eslint/no-wrapper-object-types": "error",
"@typescript-eslint/no-empty-object-type": "error",
"@typescript-eslint/no-duplicate-enum-values": "error",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-non-null-asserted-optional-chain": "error",
Expand Down
123 changes: 123 additions & 0 deletions .github/workflows/eslint_disable_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""ESLint Checker Script.
Methodology:
Recursively analyzes TypeScript files in the 'src' directory and its subdirectories
as well as 'setup.ts' files to ensure they do not contain eslint-disable statements.
This script enforces code quality practices in the project.
NOTE:
This script complies with our python3 coding and documentation standards.
It complies with:
1) Pylint
2) Pydocstyle
3) Pycodestyle
4) Flake8
"""

import os
import re
import argparse
import sys

def has_eslint_disable(file_path):
"""
Check if a TypeScript file contains eslint-disable statements.
Args:
file_path (str): Path to the TypeScript file.
Returns:
bool: True if eslint-disable statement is found, False otherwise.
"""
eslint_disable_pattern = re.compile(r'//\s*eslint-disable(?:-next-line|-line)?', re.IGNORECASE)

try:
with open(file_path, 'r', encoding='utf-8') as file:
content = file.read()
return bool(eslint_disable_pattern.search(content))
except Exception as e:
print(f"Error reading file {file_path}: {e}")
return False

def check_eslint(directory):
"""
Recursively check TypeScript files for eslint-disable statements in the 'src' directory.
Args:
directory (str): Path to the directory.
Returns:
list: List of files containing eslint-disable statements.
"""
eslint_issues = []

src_dir = os.path.join(directory, 'src')

if not os.path.exists(src_dir):
print(f"Source directory '{src_dir}' does not exist.")
return eslint_issues

for root, dirs, files in os.walk(src_dir):
for file_name in files:
if file_name.endswith('.tsx') and not file_name.endswith('.test.tsx'):
file_path = os.path.join(root, file_name)
if has_eslint_disable(file_path):
eslint_issues.append(f'File {file_path} contains eslint-disable statement.')

setup_path = os.path.join(directory, 'setup.ts')
if os.path.exists(setup_path) and has_eslint_disable(setup_path):
eslint_issues.append(f'Setup file {setup_path} contains eslint-disable statement.')

return eslint_issues

def arg_parser_resolver():
"""Resolve the CLI arguments provided by the user."""
parser = argparse.ArgumentParser()
parser.add_argument(
"--directory",
type=str,
default=os.getcwd(),
help="Path to the directory to check (default: current directory)"
)
return parser.parse_args()

def main():
"""
Execute the script's main functionality.
This function serves as the entry point for the script. It performs
the following tasks:
1. Validates and retrieves the directory to check from
command line arguments.
2. Recursively checks TypeScript files for eslint-disable statements.
3. Provides informative messages based on the analysis.
4. Exits with an error if eslint-disable statements are found.
Raises:
SystemExit: If an error occurs during execution.
"""
args = arg_parser_resolver()
if not os.path.exists(args.directory):
print(f"Error: The specified directory '{args.directory}' does not exist.")
sys.exit(1)

eslint_issues = check_eslint(args.directory)

if eslint_issues:
for issue in eslint_issues:
print(issue)
print("ESLint-disable check failed. Exiting with error.")
sys.exit(1)

print("ESLint-disable check completed successfully.")
sys.exit(0)

if __name__ == "__main__":
main()
8 changes: 4 additions & 4 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '22.x'

- name: Count number of lines
run: |
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
if: steps.changed_files.outputs.any_changed == 'true'
env:
CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }}
run: npx eslint ${CHANGED_FILES}
run: npx eslint ${CHANGED_FILES} --max-warnings=1500 && python .github/workflows/eslint_disable_check.py

- name: Check for formatting errors
run: npm run format:check
Expand Down Expand Up @@ -174,7 +174,7 @@ jobs:
needs: [Code-Quality-Checks]
strategy:
matrix:
node-version: [20.x]
node-version: [22.x]
services:
mongo:
image: mongo:4.4
Expand Down Expand Up @@ -219,7 +219,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
node-version: '22.x'

- name: Generate Access Token Secret
run: echo "ACCESS_TOKEN_SECRET=$(openssl rand -hex 32)" >> $GITHUB_ENV
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
node-version: [22.x]
services:
redis:
image: redis:6.0
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.10.0
v22.7.0
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,3 @@ Core features include:

1. Visit our [YouTube Channel playlists](https://www.youtube.com/@PalisadoesOrganization/playlists) for more insights
1. The "[Getting Started - Developers](https://www.youtube.com/watch?v=YpBUoHxEeyg&list=PLv50qHwThlJUIzscg9a80a9-HmAlmUdCF&index=1)" videos are extremely helpful for new open source contributors.

Loading

0 comments on commit b3032db

Please sign in to comment.