-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
rule-requestRequests for a new rules.Requests for a new rules.
Description
New Issue Checklist
- Updated SwiftLint to the latest version
- I searched for existing GitHub issues
New Rule Request
It would be happy when Image that initialized with string replaced with initializer with asset symbols.
- Why should this rule be added? Share links to existing discussion about what
the community thinks about this.
UIKit.UIImage(named:) and SwiftUI.Image(_:) contain the risk of bugs due to typos.
Since Xcode 15, Xcode generates codes for images in the Asset Catalog and it can avoid typos. (ref)
- Provide several examples of what would and wouldn't trigger violations.
Would trigger:
// UIKit
UIImage(named: "some_image") // simple
UIImage(named: "some image") // contains space
UIImage(named: "someImage", in: .module) // contains specified module
// SwiftUI
Image("some_image") // simple
Image("some image") // contains space
Image("someImage", bundle: .module) // contains specified moduleWould not trigger:
// UIKit
UIImage(resource: .someImage)
UIImage(systemName: "trash") // using SF Symbols
// SwiftUI
Image(.someImage)
Image(systemName: "trash") // using SF Symbols
- Should the rule be configurable, if so what parameters should be configurable?
Currently no.
- Should the rule be opt-in or enabled by default? Why?
See README.md for guidelines on when to mark a rule as opt-in.
Enabled by default on Swift 5.9+.
Asset symbol generation is enabled by default in Xcode, and it needs editing the build setting to disable it.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
rule-requestRequests for a new rules.Requests for a new rules.