chore(react-sdk): use new Array() constructor instead of Array() - #2198
chore(react-sdk): use new Array() constructor instead of Array()#2198dkx955 wants to merge 1 commit into
Conversation
SonarCloud flags calling Array() without new. Both call sites take a single numeric argument, so switching to the constructor form is behaviour preserving. Fixes asyncapi#1915
🦋 Changeset detectedLatest commit: 05dcaac The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.
What reviewer looks at during PR reviewThe following are ideal points maintainers look for during review. Reviewing these points yourself beforehand can help streamline the review process and reduce time to merge.
|
📝 WalkthroughWalkthroughThe React SDK now uses ChangesReact SDK Array Constructors
Estimated code review effort: 1 (Trivial) | ~3 minutes Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
@dkx955 Thank you for the PR, but as the changes are regarding a |



Description
SonarCloud flags both call sites for calling
Array()withoutnew. Both take a single numeric argument, so the constructor form is behaviour preserving:apps/react-sdk/src/utils/withNewLines.ts:9apps/react-sdk/src/utils/withIndendation.ts:46I grepped the whole repo for
Array(not preceded bynewand outsidenode_modules; these two are the only remaining occurrences in scope, so this closes the issue rather than partially addressing it.Equivalence checked rather than assumed —
Array(n).fill(x).join('')vsnew Array(n).fill(x).join('')forn = 0, 1, 5, both the space and the tab/newline fill characters, identical output in every case (Array(n)andnew Array(n)produce the same sparse array;.fill()then densifies it). The two forms differ only in that the call form is shadowable by a local binding namedArray, which is what the rule guards against.A changeset is included (
@asyncapi/generator-react-sdk, patch).What I have not done: I did not run the full monorepo build or test suite locally, so I am relying on CI for that rather than claiming a green run I did not observe. There are no existing unit tests covering these two utilities. The behavioural check above was run directly in Node v22.
Related issue(s)
Fixes #1915
AI assistance
Generated-by: Claude Code (Claude Opus, model
claude-opus-5)Disclosing per AI-POLICY.md. I read the policy after opening this PR and am editing the description to add the required line — the original description disclosed the AI assistance in prose but not in the machine-checkable form the policy asks for, which is my mistake, not the check's.
On the accountability point the policy makes ("AI tools are instruments; humans are the only authors"): this account is operated by an AI-assisted lab with the account owner's authorisation, and we take responsibility for every line here as if hand-written. The diff is two lines, the equivalence argument is verifiable in a Node REPL in seconds, and I can justify any part of it on request. If maintainers would rather not take AI-assisted contributions from a non-human-typed workflow regardless of disclosure, say so and I will close this myself without argument.