Skip to content

Commit

Permalink
fixed the eslint checker (#2318)
Browse files Browse the repository at this point in the history
  • Loading branch information
ARYANSHAH1567 authored Oct 12, 2024
1 parent 887af3a commit 4718e18
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/eslint_disable_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@ def has_eslint_disable(file_path):
Returns:
bool: True if eslint-disable statement is found, False otherwise.
"""
with open(file_path, 'r') as file:
content = file.read()
return re.search(r'//\s*eslint-disable', content)
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):
"""
Expand Down Expand Up @@ -72,7 +78,6 @@ def arg_parser_resolver():
Returns:
result: Parsed argument object
"""
parser = argparse.ArgumentParser()
parser.add_argument(
Expand All @@ -98,7 +103,6 @@ def main():
Raises:
SystemExit: If an error occurs during execution.
"""

args = arg_parser_resolver()

if not os.path.exists(args.directory):
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
if: steps.changed-files.outputs.only_changed != 'true'
env:
CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }}
run: npx eslint ${CHANGED_FILES}
run: npx eslint ${CHANGED_FILES} && python .github/workflows/eslint_disable_check.py

- name: Check for TSDoc comments
run: npm run check-tsdoc # Run the TSDoc check script
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"preview": "vite preview --config config/vite.config.ts",
"test": "cross-env NODE_ENV=test jest --env=./scripts/custom-test-env.js --watchAll --coverage",
"eject": "react-scripts eject",
"lint:check": "eslint \"**/*.{ts,tsx}\" --max-warnings=0",
"lint:check": "eslint \"**/*.{ts,tsx}\" --max-warnings=0 && python .github/workflows/eslint_disable_check.py",
"lint:fix": "eslint --fix \"**/*.{ts,tsx}\"",
"format:fix": "prettier --write \"**/*.{ts,tsx,json,scss,css}\"",
"format:check": "prettier --check \"**/*.{ts,tsx,json,scss,css}\"",
Expand Down

0 comments on commit 4718e18

Please sign in to comment.