Skip to content

Commit f02db61

Browse files
fix:improved code-quality
1 parent 9adebf8 commit f02db61

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

.github/workflows/scripts/detect_ts_ignore.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
format="%(levelname)s: %(message)s",
1313
)
1414

15+
TS_IGNORE_PATTERN = r"(?://|/\*)\s*@ts-ignore(?:\s+|$)"
16+
1517

1618
def check_ts_ignore(files: list[str]) -> int:
1719
"""Check for occurrences of '@ts-ignore' in the given files.
@@ -31,7 +33,8 @@ def check_ts_ignore(files: list[str]) -> int:
3133
for line_num, line in enumerate(f, start=1):
3234
# Handle more variations of @ts-ignore
3335
if re.search(
34-
r"(?://|/\*)\s*@ts-ignore(?:\s+|$)", line.strip()
36+
TS_IGNORE_PATTERN,
37+
line.strip(),
3538
):
3639
print(
3740
f"❌ Error: '@ts-ignore' found in {file} "
@@ -44,7 +47,7 @@ def check_ts_ignore(files: list[str]) -> int:
4447
except FileNotFoundError:
4548
logging.warning(f"File not found: {file}")
4649
except OSError as e:
47-
logging.error(f"Could not read {file}: {e}")
50+
logging.exception(f"Could not read {file}: {e}")
4851
if not ts_ignore_found:
4952
print("✅ No '@ts-ignore' comments found in the files.")
5053

@@ -65,10 +68,13 @@ def main() -> None:
6568
comments are found, or 1 if any are detected.
6669
"""
6770
parser = argparse.ArgumentParser(
68-
description="Check for @ts-ignore in changed files."
71+
description="Check for @ts-ignore in changed files.",
6972
)
7073
parser.add_argument(
71-
"--files", nargs="+", help="List of changed files", required=True
74+
"--files",
75+
nargs="+",
76+
help="List of changed files",
77+
required=True,
7278
)
7379
args = parser.parse_args()
7480

0 commit comments

Comments
 (0)