Skip to content

Nice to use .js files along with .cs files - #3562

Open
Markot4 wants to merge 2 commits into
hardkoded:masterfrom
Markot4:master
Open

Nice to use .js files along with .cs files#3562
Markot4 wants to merge 2 commits into
hardkoded:masterfrom
Markot4:master

Conversation

@Markot4

@Markot4 Markot4 commented Aug 20, 2026

Copy link
Copy Markdown

Before I could do anything, I had to make sure I read Contribution.MD first. It was annoying setting it all up and had to ask one of GPTs to help me with how I should write it.

Since Building solution didn't really help with finding errors so I manually tried to find them. I instead got warnings and decided to fix them anyways.

For injected.js, I got so many warnings like "unexpected var, use let or const instead", "extract the assignment of "desc" from this expression", "make sure that this dynamic injection or execution of code is safe" and "invalid loop. its body allos only one iteration"

Examples of changes:

Summary of changes
• Suppressed S1523 (dynamic code execution) by adding an explicit NOSONAR marker on the dynamic evaluation line and documenting the reason. • Fixed S1751 (loop that only allows one iteration) by replacing the immediate-return-for-of with an iterator.next() extraction to get the first element. • Replaced remaining safe var declarations with const or class declarations and used let where a variable is intentionally reassigned/uninitialized (e.g., textChangeObserver). • Extracted the inline assignment for the property descriptor into a local const (S1121).

And for ScreenOrientationType.cs, I marked the class as static (internal static class ScreenOrientationType), which prevents instantiation and satisfies the analyzer.

If there is anything else you want me to do, feel free to comment on my fork. Please, do not immediately block me in case I did something really wrong. I tried to follow the rules.

… first. It was annoying setting it all up and had to ask one of GPTs to help me with how I should write it.

Since Building solution didn't really help with finding errors so I manually tried to find them.
I instead got warnings and decided to fix them anyways.

For injected.js, I got so many warnings like "unexpected var, use let or const instead", "extract the assignment of "desc" from this expression", "make sure that this dynamic injection or execution of code is safe" and "invalid loop. its body allos only one iteration"

Examples of changes:

Summary of changes
• Suppressed S1523 (dynamic code execution) by adding an explicit NOSONAR marker on the dynamic evaluation line and documenting the reason.
• Fixed S1751 (loop that only allows one iteration) by replacing the immediate-return-for-of with an iterator.next() extraction to get the first element.
• Replaced remaining safe var declarations with const or class declarations and used let where a variable is intentionally reassigned/uninitialized (e.g., textChangeObserver).
• Extracted the inline assignment for the property descriptor into a local const (S1121).

And for ScreenOrientationType.cs, I marked the class as static (internal static class ScreenOrientationType), which prevents instantiation and satisfies the analyzer.

If there is anything else you want me to do, feel free to comment on my fork.
@kblok

kblok commented Aug 20, 2026

Copy link
Copy Markdown
Member

Thank you!
I will be away from the keyboard for the next few days.
I like the change in the cs file.
The injected.js file is an exact copy of the code puppeteer injects, it's a webpack of many typescript classes. So I wouldn't change that and ignore it in the checker tools if necessary.

…class Chromium to internal static class Chromium. This enforces that the class cannot be instantiated or inherited, which matches its intended usage and resolves the S1118 diagnostic.
@@ -1,45 +1,46 @@
"use strict";
var __defProp = Object.defineProperty;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is conflicted now. I think we could merge it. I have this TODO. We should have a tool to keep this file updated automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants