Skip to content

Commit e36724d

Browse files
committed
updated css_check.py
1 parent 00fe16b commit e36724d

File tree

3 files changed

+29
-22
lines changed

3 files changed

+29
-22
lines changed

.github/workflows/scripts/css_check.py

+13-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
# Define namedtuples for storing results
1111
Violation = namedtuple("Violation", ["file_path", "css_file", "reason"])
1212
CorrectImport = namedtuple("CorrectImport", ["file_path", "css_file"])
13-
EmbeddedViolation = namedtuple("EmbeddedViolation", ["file_path", "css_codes"])
13+
EmbeddedViolation = namedtuple(
14+
"EmbeddedViolation", ["file_path", "css_codes", "line_numbers"]
15+
)
1416
CSSCheckResult = namedtuple(
1517
"CSSCheckResult", ["violations", "correct_imports", "embedded_violations"]
1618
)
@@ -93,8 +95,10 @@ def process_typescript_file(
9395
# Check for embedded CSS
9496
embedded_css = check_embedded_css(content)
9597
if embedded_css:
98+
line_numbers = [violation[0] for violation in embedded_css]
99+
css_codes = [violation[1] for violation in embedded_css]
96100
embedded_css_violations.append(
97-
EmbeddedViolation(file_path, embedded_css)
101+
EmbeddedViolation(file_path, css_codes, line_numbers)
98102
)
99103

100104

@@ -311,11 +315,14 @@ def main():
311315
if result.embedded_violations:
312316
output.append("\nEmbedded CSS Violations:")
313317
for violation in result.embedded_violations:
314-
for css_code in violation.css_codes:
318+
for line_number, css_code in zip(
319+
violation.line_numbers, violation.css_codes
320+
):
321+
relative_file_path = os.path.relpath(violation.file_path)
315322
output.append(
316-
f"- {violation.file_path}: "
317-
f"has embedded color code `{css_code}`. use CSS variable "
318-
f"in src/style/app.module.css."
323+
f"- File: {relative_file_path}, Line: {line_number}: "
324+
f"Embedded color code `{css_code}` detected. Please replace"
325+
f"it with a CSS variable in `src/style/app.module.css`."
319326
)
320327
exit_code = 1
321328

docs/docs/auto-docs/components/SignOut/SignOut/functions/default.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
> **default**(): `Element`
88
9-
Defined in: [src/components/SignOut/SignOut.tsx:20](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/components/SignOut/SignOut.tsx#L20)
9+
Defined in: [src/components/SignOut/SignOut.tsx:19](https://github.com/PalisadoesFoundation/talawa-admin/blob/main/src/components/SignOut/SignOut.tsx#L19)
1010

1111
Renders a sign out button.
1212

src/components/SignOut/SignOut.tsx

+15-15
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ const SignOut = (): JSX.Element => {
2121
const [revokeRefreshToken] = useMutation(REVOKE_REFRESH_TOKEN);
2222
const navigate = useNavigate();
2323

24-
const logout = async (): Promise<void> => {
25-
const handleSignOut = () => {
26-
localStorage.clear();
27-
endSession();
28-
navigate('/');
29-
};
24+
const logout = async (): Promise<void> => {
25+
const handleSignOut = () => {
26+
localStorage.clear();
27+
endSession();
28+
navigate('/');
29+
};
3030

31-
try {
32-
await revokeRefreshToken();
33-
handleSignOut();
34-
} catch (error) {
35-
console.error('Error revoking refresh token:', error);
36-
// Still sign out the user locally even if token revocation fails
37-
handleSignOut();
38-
}
39-
};
31+
try {
32+
await revokeRefreshToken();
33+
handleSignOut();
34+
} catch (error) {
35+
console.error('Error revoking refresh token:', error);
36+
// Still sign out the user locally even if token revocation fails
37+
handleSignOut();
38+
}
39+
};
4040
return (
4141
<div className={styles.signOutContainer}>
4242
<LogoutIcon />

0 commit comments

Comments
 (0)