Skip to content

Add prefer_asset_symbols rule#6261

Merged
SimplyDanny merged 12 commits intorealm:mainfrom
danglingP0inter:kirti/prefer-asset-symbols
Oct 10, 2025
Merged

Add prefer_asset_symbols rule#6261
SimplyDanny merged 12 commits intorealm:mainfrom
danglingP0inter:kirti/prefer-asset-symbols

Conversation

@danglingP0inter
Copy link
Contributor

Implements a new SwiftLint rule that suggests using asset symbols over string-based image initialization to avoid typos and enable compile-time checking.

The rule detects:

  • UIImage(named: "string") calls
  • SwiftUI Image("string") calls

And suggests using asset symbols like:

  • UIImage(resource: .imageName)
  • Image(.imageName)

Resolves #5939

@SwiftLintBot
Copy link

SwiftLintBot commented Sep 28, 2025

1047 Warnings
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/App/BraveWidgets/SingleStatWidget.swift:79:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/App/BraveWidgets/FavoritesWidget.swift:69:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/App/BraveWidgets/ShortcutsWidget.swift:211:15: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/App/BraveWidgets/TopNewsWidget.swift:151:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/App/BraveWidgets/TopNewsWidget.swift:244:13: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/App/BraveWidgets/StatsWidget.swift:61:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/App/BraveWidgets/StatsWidget.swift:66:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/App/BraveWidgets/TopNewsListWidget.swift:82:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/App/BraveWidgets/TopNewsListWidget.swift:179:19: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveVPN/Components/Settings/BraveVPNEnableSettingsHeader.swift:76:20: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveVPN/Components/Settings/BraveVPNEnableSettingsHeader.swift:85:20: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveVPN/Components/Settings/BraveVPNEnableSettingsHeaderView.swift:76:11: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveVPN/Components/Common/BraveVPNCommonUI.swift:70:13: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveVPN/Components/Region/BraveVPNRegionConfirmationView.swift:24:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveVPN/Components/InstallVPN/BraveVPNInstallView.swift:24:16: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveNews/Settings/BraveNewsAddSourceResultsViewController.swift:119:13: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveNews/FeedCardFooterButton.swift:16:12: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveNews/Cards/BraveNewsErrorView.swift:64:28: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveNews/Cards/BraveNewsEmptyFeedView.swift:63:28: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveNews/Cards/BraveNewsOptInView.swift:41:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveNews/FeedActionAlertView.swift:160:14: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveNews/Customize/OptInView.swift:21:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveNews/FeedItemView.swift:188:14: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/AssetsListView.swift:61:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/Transaction Confirmations/PendingTransactionView.swift:104:13: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/CryptoView.swift:66:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/CryptoView.swift:330:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/Transactions/TransactionDetailsView.swift:282:13: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/UnlockWalletView.swift:120:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/Portfolio/PortfolioAssetsView.swift:99:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/Portfolio/AddCustomAssetView.swift:222:19: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/Scanner/AddressQRCodeScannerView.swift:170:18: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/Asset Details/AssetDetailView.swift:208:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/Asset Details/AssetDetailView.swift:223:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/WalletActions/BuyTokenView.swift:316:15: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/WalletActions/SwapCryptoView.swift:495:11: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/Onboarding/BackupWalletView.swift:66:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/Onboarding/SetupCryptoView.swift:84:21: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/Onboarding/SetupCryptoView.swift:86:21: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/Onboarding/SetupCryptoView.swift:88:21: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/Onboarding/SetupCryptoView.swift:90:21: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/Onboarding/SetupCryptoView.swift:114:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/Onboarding/OnBoardingCompletedView.swift:28:13: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/Onboarding/OnBoardingCompletedView.swift:54:11: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/Onboarding/CreateWalletView.swift:237:13: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Crypto/Onboarding/RestoreWalletView.swift:240:13: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/PasswordEntryView.swift:166:11: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/Panels/WalletPanelView.swift:62:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/BraveWallet/OriginInfoFavicon.swift:21:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Reader/ReaderModeStyleViewController.swift:166:14: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Reader/ReaderModeStyleViewController.swift:177:14: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Popup/QRCodePopupView.swift:48:17: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Popup/QRCodePopupView.swift:56:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/ScriptHandlers/Sandboxed/LoginsScriptHandler.swift:169:11: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/UserContent/UserScripts/Scripts_Dynamic/ScriptHandlers/Sandboxed/LoginsScriptHandler.swift:170:11: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Shields/ShieldsActivityItemSourceProvider.swift:27:27: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabTray/Views/TabTrayButtons.swift:13:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabTray/Views/TabSyncContainerView.swift:81:19: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabTray/Views/TabSyncContainerView.swift:95:19: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabTray/Views/TabSyncContainerView.swift:110:19: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabTray/Views/TabTrayCell.swift:119:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabTray/Views/TabTrayPrivateModeInfoView.swift:67:14: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Tabs/TabBar/TabBarCell.swift:22:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Playlist/Onboarding & Toast/PlaylistToast.swift:217:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+DownloadQueueDelegate.swift:73:18: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/BrowserViewController/BVC+TabDelegate.swift:59:18: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/New Tab Page/Sections/NTPDefaultBrowserCalloutProvider.swift:121:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/New Tab Page/Sections/StatsSectionProvider.swift:146:17: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/New Tab Page/Sections/StatsSectionProvider.swift:225:13: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/New Tab Page/Sections/StatsSectionProvider.swift:242:18: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/New Tab Page/Backgrounds/NewTabPageBackgroundButtonsView.swift:265:14: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/New Tab Page/Notifications/NTPNotificationView.swift:28:14: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/New Tab Page/Notifications/NTPNotificationView.swift:74:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/New Tab Page/Notifications/NTPLearnMoreContentView.swift:29:16: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Favorites/Views/Cells/FavoritesCell.swift:16:33: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/SendTab/SendTabProcessController.swift:29:16: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/SendTab/SendTabProcessController.swift:31:16: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Favorites/FavoritesViewController.swift:770:30: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/DownloadToast.swift:139:14: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/DownloadToast.swift:166:14: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/PrivacyHub/PrivacyHubLastWeekSection.swift:62:11: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/PrivacyHub/PrivacyHubLastWeekSection.swift:94:11: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/PrivacyHub/NotificationCalloutView.swift:83:19: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/PrivacyHub/NotificationCalloutView.swift:103:15: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Search/Views/Cells/SearchActionsCell.swift:19:16: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Search/SearchViewController.swift:962:32: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Search/SearchViewController.swift:1012:30: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Toolbars/BottomToolbar/Menu/Bookmarks/IndentedImageTableViewCell.swift:20:16: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Browser/Toolbars/UrlBar/RewardsButton.swift:24:12: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Passcode/WindowProtection.swift:24:14: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Brave Rewards/Panel/BraveRewardsStatusView.swift:22:12: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Brave Rewards/Panel/BraveRewardsStatusView.swift:29:12: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Brave Rewards/Panel/BraveRewardsViewController.swift:36:60: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Brave Rewards/OptIn/BraveTalkOptInSuccessView.swift:15:14: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Brave Rewards/OptIn/BraveTalkOptInSuccessView.swift:39:14: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Brave Rewards/OptIn/BraveTalkRewardsOptInView.swift:30:14: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Brave Rewards/OptIn/BraveTalkRewardsOptInView.swift:75:14: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Sync/SyncCameraView.swift:37:14: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Sync/SyncPairWordsViewController.swift:37:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Sync/SyncWelcomeViewController.swift:94:40: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Widgets/TranslucentBottomSheet.swift:17:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Widgets/MenuButton.swift:27:13: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Brave/Frontend/Widgets/BottomSheetViewController.swift:47:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/AIChat/Components/Messages/AIChatResponseMessageView.swift:147:11: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/FaviconModels/Favicon.swift:16:36: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/AIChat/Components/Paywall/AIChatPaywallView.swift:142:13: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/DataImporter/UI/DataImporterFailedView.swift:18:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/DataImporter/UI/DataImporterSuccessView.swift:18:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/DataImporter/UI/DataImporterView.swift:108:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/DataImporter/UI/DataImporterView.swift:159:11: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/DataImporter/UI/DataImporterMultipleProfilesView.swift:39:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/DataImporter/UI/DataImporterTutorialView.swift:56:17: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/DataImporter/UI/DataImporterPasswordConflictView.swift:24:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/PlaylistUI/PlaylistSidebarList.swift:246:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/PlaylistUI/PlaylistSidebarList.swift:247:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/PlaylistUI/PlaylistSidebarList.swift:248:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/PlaylistUI/PlaylistSidebarList.swift:249:9: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Onboarding/VPNNotifications/VPNLinkReceiptView.swift:23:7: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Onboarding/ProductNotifications/ShareTrackersController.swift:233:22: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Onboarding/ProductNotifications/ShareTrackersController.swift:235:22: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ This PR introduced a violation in Brave: /ios/brave-ios/Sources/Onboarding/Welcome/WelcomeNTPOnboardingView.swift:28:16: Warning: Prefer using asset symbols over string-based image initialization (prefer_asset_symbols)
⚠️ Danger found 1047 violations with this PR. Due to GitHub's max issue comment size, the number shown has been truncated to 121.
18 Messages
📖 Building this branch resulted in a binary size of 26237.6 KiB vs 26195.6 KiB when built on main (0% larger).
📖 Linting Aerial with this PR took 0.8 s vs 0.84 s on main (4% faster).
📖 Linting Alamofire with this PR took 1.0 s vs 1.01 s on main (0% faster).
📖 Linting Brave with this PR took 6.79 s vs 6.83 s on main (0% faster).
📖 Linting DuckDuckGo with this PR took 21.07 s vs 21.12 s on main (0% faster).
📖 Linting Firefox with this PR took 10.82 s vs 10.75 s on main (0% slower).
📖 Linting Kickstarter with this PR took 7.52 s vs 7.53 s on main (0% faster).
📖 Linting Moya with this PR took 0.41 s vs 0.45 s on main (8% faster).
📖 Linting NetNewsWire with this PR took 2.38 s vs 2.36 s on main (0% slower).
📖 Linting Nimble with this PR took 0.62 s vs 0.65 s on main (4% faster).
📖 Linting PocketCasts with this PR took 6.71 s vs 6.84 s on main (1% faster).
📖 Linting Quick with this PR took 0.43 s vs 0.4 s on main (7% slower).
📖 Linting Realm with this PR took 3.29 s vs 3.29 s on main (0% slower).
📖 Linting Sourcery with this PR took 1.81 s vs 1.81 s on main (0% slower).
📖 Linting Swift with this PR took 4.1 s vs 4.12 s on main (0% faster).
📖 Linting VLC with this PR took 1.14 s vs 1.1 s on main (3% slower).
📖 Linting Wire with this PR took 17.21 s vs 17.18 s on main (0% slower).
📖 Linting WordPress with this PR took 11.23 s vs 11.18 s on main (0% slower).

Generated by 🚫 Danger

Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Please consider my comments.

Implements a new SwiftLint rule that suggests using asset symbols over
string-based image initialization to avoid typos and enable compile-time
checking.

The rule detects:
- UIImage(named: "string") calls
- SwiftUI Image("string") calls

And suggests using asset symbols like:
- UIImage(resource: .imageName)
- Image(.imageName)

Resolves realm#5939
- Replace string-based matching with proper SwiftSyntax node matching
- Add isUIImageCall() and isImageCall() methods that match on syntax tree structure
- Improves reliability and performance by avoiding string conversions
- Addresses PR feedback about not relying on string representations
- Replace manual argument counting with node.arguments.onlyElement
- Ensures exactly one argument for both UIImage(named:) and Image(_:)
- Eliminates need for separate checks for additional parameters
- More concise and reliable than previous implementation
- Addresses PR feedback about argument position validation
- Remove onlyElement restriction to allow bundle parameter detection
- Update UIImage logic to find any argument with 'named' label
- Update SwiftUI Image logic to check first argument regardless of additional params
- Add bundle image cases to triggeringExamples
- Remove bundle cases from nonTriggeringExamples
- ImageResource generates assets across all bundles, so violations should be triggered
- Change from finding any 'named' argument to checking first argument specifically
- Ensures UIImage(named:) pattern is correctly identified
- More precise matching for UIImage initializer signatures
- Maintains same behavior but with better argument position validation
@danglingP0inter danglingP0inter force-pushed the kirti/prefer-asset-symbols branch from d69efde to 4f5a426 Compare October 9, 2025 16:56
- Change @SwiftSyntaxRule(optIn: false) to @SwiftSyntaxRule(optIn: true)
- Rule now requires explicit enablement in configuration
- Follows SwiftLint guidelines for new rules being opt-in by default
…s opt-in

- Change opt-in: false to opt-in: true in integration test configuration
- Ensures consistency between rule implementation and test expectations
- Fixes integration test validation for the opt-in rule setting
Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more comments. 😉

- Merged isUIImageCall and isImageCall into a single isImageCall function with className parameter
- Merged isUIImageNamedInit and isSwiftUIImageInit into a single isImageInit function with className and argumentLabel parameters
- Reduced code duplication and improved maintainability
Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good now. Thanks @danglingP0inter!

Linting checks but complain about a few trailing spaces in the CHANGELOG.

@danglingP0inter
Copy link
Contributor Author

danglingP0inter commented Oct 10, 2025

That looks good now. Thanks @danglingP0inter!

Linting checks but complain about a few trailing spaces in the CHANGELOG.

Fixed. Removed trailing spaces. Thanks, @SimplyDanny!

@SimplyDanny SimplyDanny enabled auto-merge (squash) October 10, 2025 19:08
@SimplyDanny SimplyDanny merged commit 9a61f48 into realm:main Oct 10, 2025
21 checks passed
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: Prefer using Asset Symbols

3 participants