diff --git a/Rules.md b/Rules.md index 7d8259be05..2a8d0cedd3 100644 --- a/Rules.md +++ b/Rules.md @@ -95,6 +95,7 @@ * [No Grouping Extension](#no-grouping-extension) * [Notification Center Detachment](#notification-center-detachment) * [NSLocalizedString Key](#nslocalizedstring-key) +* [NSLocalizedString Require Bundle](#nslocalizedstring-require-bundle) * [NSObject Prefer isEqual](#nsobject-prefer-isequal) * [Number Separator](#number-separator) * [Object Literal](#object-literal) @@ -13549,6 +13550,60 @@ NSLocalizedString(↓"key_\(param)", comment: nil) +## NSLocalizedString Require Bundle + +Identifier | Enabled by default | Supports autocorrection | Kind | Analyzer | Minimum Swift Compiler Version +--- | --- | --- | --- | --- | --- +`nslocalizedstring_require_bundle` | Disabled | No | lint | No | 3.0.0 + +Calls to NSLocalisedString should specify the bundle which contains the strings file. + +### Examples + +
+Non Triggering Examples + +```swift +NSLocalizedString("someKey", bundle: .main, comment: "test") +``` + +```swift +NSLocalizedString("someKey", tableName: "a", + bundle: Bundle(for: A.self), + comment: "test") +``` + +```swift +NSLocalizedString("someKey", tableName: "xyz", + bundle: someBundle, value: "test" + comment: "test") +``` + +```swift +arbitraryFunctionCall("something") +``` + +
+
+Triggering Examples + +```swift +↓NSLocalizedString("someKey", comment: "test") +``` + +```swift +↓NSLocalizedString("someKey", tableName: "a", comment: "test") +``` + +```swift +↓NSLocalizedString("someKey", tableName: "xyz", + value: "test", comment: "test") +``` + +
+ + + ## NSObject Prefer isEqual Identifier | Enabled by default | Supports autocorrection | Kind | Analyzer | Minimum Swift Compiler Version