Add `prefer_scaled_to_fit` opt-in rule by DemiDevv · Pull Request #6609 · realm/SwiftLint · GitHub
Skip to content

Add prefer_scaled_to_fit opt-in rule#6609

Draft
DemiDevv wants to merge 3 commits intorealm:mainfrom
DemiDevv:demidev/prefer-scaled-to-fit
Draft

Add prefer_scaled_to_fit opt-in rule#6609
DemiDevv wants to merge 3 commits intorealm:mainfrom
DemiDevv:demidev/prefer-scaled-to-fit

Conversation

@DemiDevv
Copy link
Copy Markdown

Closes #5713

Adds a new opt-in rule prefer_scaled_to_fit that suggests using
scaledToFit() or scaledToFill() instead of
aspectRatio(contentMode:) when the content mode is a constant
(.fit or .fill).

As noted in Apple's documentation, scaledToFit() is equivalent to
aspectRatio(nil, contentMode: .fit), so the shorter form is
preferred when no custom aspect ratio is provided.

@SwiftLintBot
Copy link
Copy Markdown

SwiftLintBot commented Apr 17, 2026

@DemiDevv
Copy link
Copy Markdown
Author

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.

Rule Request: SwiftUI: Prefer scaledToFit()/scaledToFill() over aspectRatio(contentMode:)

2 participants