-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
refactor(es/transfomer): Prevent breaking change #11308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Code Review for PR #11308SummaryThis PR adds 🔴 Critical Issue: FormattingThe // ❌ Incorrect (current code)
#[derive(Debug, Default)]#[non_exhaustive]
pub struct DecoratorOptions {}Required fix: // ✅ Correct
#[derive(Debug, Default)]
#[non_exhaustive]
pub struct DecoratorOptions {}Affected files:
Only these files are correctly formatted:
Action required: Run ✅ Code QualityPositive aspects:
📋 Additional Observations
🔍 Security & Performance
🧪 Test CoverageNo tests need to be added for this change as:
✅ RecommendationApprove after formatting fix. Once you run Command to fix: cargo fmt --allThis aligns with repository guideline #8 from CLAUDE.md. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds the #[non_exhaustive] attribute to various option structs throughout the transformer codebase to prevent breaking changes when new fields are added in the future. This allows the library to evolve without breaking downstream users who construct these structs.
Key Changes:
- Added
#[non_exhaustive]attribute to 16 option structs across the transformer modules - Applied to various ES version options (ES2015-ES2026), TypeScript, JSX, RegExp, Decorator, Bugfix, and top-level Options structs
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
crates/swc_ecma_transformer/src/typescript/mod.rs |
Added #[non_exhaustive] to TypescriptOptions struct |
crates/swc_ecma_transformer/src/regexp.rs |
Added #[non_exhaustive] to RegExpOptions struct |
crates/swc_ecma_transformer/src/options/mod.rs |
Added #[non_exhaustive] to Options and EnvOptions structs |
crates/swc_ecma_transformer/src/jsx/mod.rs |
Added #[non_exhaustive] to JsxOptions struct |
crates/swc_ecma_transformer/src/es2026/mod.rs |
Added #[non_exhaustive] to Es2026Options struct |
crates/swc_ecma_transformer/src/es2022/mod.rs |
Added #[non_exhaustive] to Es2022Options struct |
crates/swc_ecma_transformer/src/es2021/mod.rs |
Added #[non_exhaustive] to Es2021Options struct |
crates/swc_ecma_transformer/src/es2020/mod.rs |
Added #[non_exhaustive] to Es2020Options struct |
crates/swc_ecma_transformer/src/es2019/mod.rs |
Added #[non_exhaustive] to Es2019Options struct |
crates/swc_ecma_transformer/src/es2018/mod.rs |
Added #[non_exhaustive] to Es2018Options struct |
crates/swc_ecma_transformer/src/es2017/mod.rs |
Added #[non_exhaustive] to Es2017Options struct |
crates/swc_ecma_transformer/src/es2016/mod.rs |
Added #[non_exhaustive] to Es2016Options struct |
crates/swc_ecma_transformer/src/es2015/mod.rs |
Added #[non_exhaustive] to Es2015Options struct |
crates/swc_ecma_transformer/src/decorators/mod.rs |
Added #[non_exhaustive] to DecoratorOptions struct |
crates/swc_ecma_transformer/src/bugfix/mod.rs |
Added #[non_exhaustive] to BugfixOptions struct |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| use crate::TraverseCtx; | ||
|
|
||
| #[derive(Debug, Default)] |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The #[non_exhaustive] attribute should be placed on a separate line from #[derive(Debug, Default)] for better readability and consistency with Rust formatting conventions. It should be:
#[derive(Debug, Default)]
#[non_exhaustive]
pub struct TypescriptOptions {}|
|
||
| use crate::TraverseCtx; | ||
|
|
||
| #[derive(Debug, Default)] |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The #[non_exhaustive] attribute should be placed on a separate line from #[derive(Debug, Default)] for better readability and consistency with Rust formatting conventions. It should be:
#[derive(Debug, Default)]
#[non_exhaustive]
pub struct Es2026Options {}|
|
||
| use crate::TraverseCtx; | ||
|
|
||
| #[derive(Debug, Default)] |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The #[non_exhaustive] attribute should be placed on a separate line from #[derive(Debug, Default)] for better readability and consistency with Rust formatting conventions. It should be:
#[derive(Debug, Default)]
#[non_exhaustive]
pub struct Es2022Options {}|
|
||
| use crate::TraverseCtx; | ||
|
|
||
| #[derive(Debug, Default)] |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The #[non_exhaustive] attribute should be placed on a separate line from #[derive(Debug, Default)] for better readability and consistency with Rust formatting conventions. It should be:
#[derive(Debug, Default)]
#[non_exhaustive]
pub struct Es2020Options {}|
|
||
| use crate::TraverseCtx; | ||
|
|
||
| #[derive(Debug, Default)] |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The #[non_exhaustive] attribute should be placed on a separate line from #[derive(Debug, Default)] for better readability and consistency with Rust formatting conventions. It should be:
#[derive(Debug, Default)]
#[non_exhaustive]
pub struct Es2019Options {}|
|
||
| use crate::TraverseCtx; | ||
|
|
||
| #[derive(Debug, Default)] |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The #[non_exhaustive] attribute should be placed on a separate line from #[derive(Debug, Default)] for better readability and consistency with Rust formatting conventions. It should be:
#[derive(Debug, Default)]
#[non_exhaustive]
pub struct JsxOptions {}|
|
||
| use crate::TraverseCtx; | ||
|
|
||
| #[derive(Debug, Default)] |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The #[non_exhaustive] attribute should be placed on a separate line from #[derive(Debug, Default)] for better readability and consistency with Rust formatting conventions. It should be:
#[derive(Debug, Default)]
#[non_exhaustive]
pub struct Es2021Options {}|
|
||
| use crate::TraverseCtx; | ||
|
|
||
| #[derive(Debug, Default)] |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The #[non_exhaustive] attribute should be placed on a separate line from #[derive(Debug, Default)] for better readability and consistency with Rust formatting conventions. It should be:
#[derive(Debug, Default)]
#[non_exhaustive]
pub struct Es2017Options {}|
|
||
| use crate::TraverseCtx; | ||
|
|
||
| #[derive(Debug, Default)] |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The #[non_exhaustive] attribute should be placed on a separate line from #[derive(Debug, Default)] for better readability and consistency with Rust formatting conventions. It should be:
#[derive(Debug, Default)]
#[non_exhaustive]
pub struct Es2015Options {}|
|
||
| use crate::TraverseCtx; | ||
|
|
||
| #[derive(Debug, Default)] |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The #[non_exhaustive] attribute should be placed on a separate line from #[derive(Debug, Default)] for better readability and consistency with Rust formatting conventions. It should be:
#[derive(Debug, Default)]
#[non_exhaustive]
pub struct DecoratorOptions {}
Code ReviewSummaryThis PR adds the attribute to all public option structs in the transformer crate to prevent breaking changes when new fields are added in the future. This is a defensive API design practice that's well-suited for public library code. Positive Aspects ✓
Code Quality ✓
Considerations
Test CoverageNo new tests are needed as this is a compile-time API change that doesn't affect runtime behavior. The existing tests should continue to pass. PerformanceNo performance impact - this is a compile-time-only attribute. SecurityNo security implications. RecommendationApprove ✓ This is a well-reasoned change that improves the library's API stability story. The consistent application across all option structs is good practice and aligns with Rust API guidelines for public library crates. |
Binary Sizes
Commit: 202ac73 |
CodSpeed Performance ReportMerging #11308 will not alter performanceComparing Summary
|
No description provided.