forked from PalisadoesFoundation/talawa-api
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
20240929103244 Merge develop into main
- Loading branch information
Peter Harrison
committed
Sep 29, 2024
1 parent
0b9dd20
commit ad5b242
Showing
1,323 changed files
with
609,538 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,6 @@ reviews: | |
drafts: false | ||
base_branches: | ||
- develop | ||
- main | ||
chat: | ||
auto_reply: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
node_modules | ||
videos | ||
images | ||
data | ||
.env | ||
.git | ||
.gitignore | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// List of files to skip | ||
const filesToSkip = [ | ||
"app.ts", | ||
"index.ts", | ||
"constants.ts", | ||
"db.ts", | ||
"env.ts", | ||
"logger.ts", | ||
"getSort.ts", | ||
// Add more files to skip as needed | ||
]; | ||
|
||
// List of directories to skip | ||
const dirsToSkip = [ | ||
"typeDefs", | ||
"services", | ||
|
||
// Add more directories to skip as needed | ||
]; | ||
|
||
// Recursively find all .tsx files, excluding files listed in filesToSkip and directories in dirsToSkip | ||
function findTsxFiles(dir) { | ||
let results = []; | ||
try { | ||
const list = fs.readdirSync(dir); | ||
list.forEach((file) => { | ||
const filePath = path.join(dir, file); | ||
const stat = fs.statSync(filePath); | ||
if (stat && stat.isDirectory()) { | ||
// Skip directories in dirsToSkip | ||
if (!dirsToSkip.includes(path.basename(filePath))) { | ||
results = results.concat(findTsxFiles(filePath)); | ||
} | ||
} else if ( | ||
filePath.endsWith('.ts') && | ||
!filePath.endsWith('.spec.ts') && | ||
!filesToSkip.includes(path.relative(dir, filePath)) | ||
) { | ||
results.push(filePath); | ||
} | ||
}); | ||
} catch (err) { | ||
console.error(`Error reading directory ${dir}: ${err.message}`); | ||
} | ||
return results; | ||
} | ||
|
||
// Check if a file contains at least one TSDoc comment | ||
function containsTsDocComment(filePath) { | ||
try { | ||
const content = fs.readFileSync(filePath, 'utf8'); | ||
return /\/\*\*[\s\S]*?\*\//.test(content); | ||
} catch (err) { | ||
console.error(`Error reading file ${filePath}: ${err.message}`); | ||
return false; | ||
} | ||
} | ||
|
||
// Main function to run the validation | ||
function run() { | ||
const dir = process.argv[2] || './src'; // Allow directory path as a command-line argument | ||
const files = findTsxFiles(dir); | ||
let allValid = true; | ||
|
||
files.forEach((file) => { | ||
if (!containsTsDocComment(file)) { | ||
console.error(`No TSDoc comment found in file: ${file}`); | ||
allValid = false; | ||
} | ||
}); | ||
|
||
if (!allValid) { | ||
process.exit(1); | ||
} | ||
} | ||
|
||
run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
3) Pycodestyle | ||
4) Flake8 | ||
""" | ||
|
||
import os | ||
import argparse | ||
import re | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.