fix(purity): remove AbortController from impure constructors#1648
fix(purity): remove AbortController from impure constructors#1648Rel1cx merged 3 commits intoRel1cx:mainfrom
Conversation
`new AbortController()` is a pure operation that creates an in-memory object without side effects (no I/O, no DOM mutation, no listeners). It should not be flagged by the purity rule. Closes Rel1cx#1625 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@zerone0x is attempting to deploy a commit to the Rel1cx's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
623712a to
40d81f0
Compare
There was a problem hiding this comment.
Pull request overview
Updates the purity ESLint rule’s impure-constructor list and test suite to treat new AbortController() as a pure operation, resolving false-positive reports (Closes #1625).
Changes:
- Removed
AbortControllerfrom theIMPURE_CTORSset. - Updated
purityrule tests by movingnew AbortController()frominvalidtovalid.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
packages/shared/src/constants.ts |
Stops classifying AbortController as an impure constructor so it won’t be flagged during render. |
packages/plugins/eslint-plugin-react-x/src/rules/purity/purity.spec.ts |
Adjusts test expectations so new AbortController() is allowed in component render paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| code: tsx` | ||
| function Component() { | ||
| const ws = new (WebSocket as any)("ws://example.com"); | ||
| return <div>Content</div>; | ||
| } | ||
| `, | ||
| errors: [{ messageId: "default" }], | ||
| }, |
There was a problem hiding this comment.
PR description says AbortController test cases were moved from invalid to valid, but the type-wrapped constructor case (new (AbortController as any)()) was removed from invalid without being added to valid. Consider adding an explicit valid case for the type-wrapped AbortController constructor (or update the PR description) to avoid losing coverage for this scenario.
Summary
AbortControllerfrom theIMPURE_CTORSset, sincenew AbortController()is a pure operation that creates an in-memory object without side effects (no I/O, no DOM mutation, no event listeners).Closes #1625
Test plan
new AbortController()directly in a component render pathuseEffectstill pass