From b88a4c17fe6989b3801015b1e8f3815dbafb50f6 Mon Sep 17 00:00:00 2001 From: im-vedant <194vedantgutpa@gmail.com> Date: Sat, 28 Dec 2024 23:06:55 +0530 Subject: [PATCH] Remove test files and ensured that python files follow coding standards --- .../workflows/code_coverage_disable_check.py | 26 +++++++++---------- .github/workflows/eslint_disable_check.py | 14 ++++++---- src/App.tsx | 2 -- src/setupTests.ts | 1 - 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.github/workflows/code_coverage_disable_check.py b/.github/workflows/code_coverage_disable_check.py index d6333f212f..b6a0cb4f7c 100644 --- a/.github/workflows/code_coverage_disable_check.py +++ b/.github/workflows/code_coverage_disable_check.py @@ -2,7 +2,8 @@ Methodology: - Recursively analyzes TypeScript files in the specified directories or checks specific files + Recursively analyzes TypeScript files in the specified directories or + checks specific files to ensure they do not contain code coverage disable statements. This script enforces proper code coverage practices in the project. @@ -37,7 +38,8 @@ def has_code_coverage_disable(file_path): otherwise. """ code_coverage_disable_pattern = re.compile( - r"""//?\s*istanbul\s+ignore(?:\s+(?:next|-line))?[^\n]*|/\*\s*istanbul\s+ignore\s+(?:next|-line)\s*\*/""", + r"""//?\s*istanbul\s+ignore(?:\s+(?:next|-line))?[^\n]*| + /\*\s*istanbul\s+ignore\s+(?:next|-line)\s*\*/""", re.IGNORECASE, ) try: @@ -57,7 +59,7 @@ def has_code_coverage_disable(file_path): def check_code_coverage(files_or_dirs): """ - Check TypeScript files for code coverage disable statements. + Check TypeScript files for code coverage disable statements. Args: files_or_dirs (list): List of files or directories to check. @@ -75,13 +77,13 @@ def check_code_coverage(files_or_dirs): if "node_modules" in root: continue for file_name in files: - if ( - file_name.endswith(".tsx") - or file_name.endswith(".ts") - ): + if file_name.endswith(".tsx") or file_name.endswith(".ts"): file_path = os.path.join(root, file_name) if has_code_coverage_disable(file_path): - print(f"File {file_path} contains code coverage disable statement.") + print( + f"""File {file_path} contains code coverage + disable statement.""" + ) code_coverage_found = True elif os.path.isfile(item): # If it's a file, check it directly @@ -92,10 +94,10 @@ def check_code_coverage(files_or_dirs): and not file_name.endswith(".test.ts") and not file_name.endswith(".spec.tsx") and not file_name.endswith(".spec.ts") - - ) : + ): if has_code_coverage_disable(item): - print(f"File {item} contains code coverage disable statement.") + print(f"""File {item} contains code coverage disable + statement.""") code_coverage_found = True return code_coverage_found @@ -143,9 +145,7 @@ def main(): SystemExit: If an error occurs during execution. """ args = arg_parser_resolver() - files_or_dirs = args.files if args.files else args.directory - print(files_or_dirs) # Check code coverage in the specified files or directories code_coverage_found = check_code_coverage(files_or_dirs) diff --git a/.github/workflows/eslint_disable_check.py b/.github/workflows/eslint_disable_check.py index 5b824a76fb..ee17fcb220 100644 --- a/.github/workflows/eslint_disable_check.py +++ b/.github/workflows/eslint_disable_check.py @@ -1,11 +1,12 @@ #!/usr/bin/env python3 -# -*- coding: UTF-8 -*- +# -*- coding: UTF-8 -*- """ESLint Checker Script. Methodology: Recursively analyzes TypeScript files in the specified directory - or checks specific files directly to ensure they do not contain eslint-disable statements. + or checks specific files directly to ensure they do not contain + eslint-disable statements. This script enforces code quality practices in the project. @@ -77,7 +78,8 @@ def check_eslint(files_or_directories): print(f"File {item} contains eslint-disable statement.") eslint_found = True elif os.path.isdir(item): - # If it's a directory, walk through it and check all .ts and .tsx files + # If it's a directory, walk through it and check all + # .ts and .tsx files for root, _, files in os.walk(item): if "node_modules" in root: continue @@ -85,7 +87,10 @@ def check_eslint(files_or_directories): if file_name.endswith(".ts") or file_name.endswith(".tsx"): file_path = os.path.join(root, file_name) if has_eslint_disable(file_path): - print(f"File {file_path} contains eslint-disable statement.") + print( + f"""File {file_path} contains eslint-disable + statement.""" + ) eslint_found = True return eslint_found @@ -136,7 +141,6 @@ def main(): # Determine whether to check files or directories based on the arguments files_or_directories = args.files if args.files else args.directory - print(files_or_directories) # Check eslint in the specified files or directories eslint_found = check_eslint(files_or_directories) diff --git a/src/App.tsx b/src/App.tsx index d9d6db2606..4d2ca76010 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -70,9 +70,7 @@ const { setItem } = useLocalStorage(); * * @returns The rendered routes and components of the application. */ -// eslint-disable -// istanbul ignore next function app(): JSX.Element { /*const { updatePluginLinks, updateInstalled } = bindActionCreators( actionCreators, diff --git a/src/setupTests.ts b/src/setupTests.ts index 37ad9f43c6..19c34e040a 100644 --- a/src/setupTests.ts +++ b/src/setupTests.ts @@ -3,7 +3,6 @@ // expect(element).toHaveTextContent(/react/i) // learn more: https://github.com/testing-library/jest-dom import '@testing-library/jest-dom'; -// eslint-disable global.fetch = jest.fn(); import { format } from 'util';