forked from realm/SwiftLint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nslocalizedstring_require_bundle] Add NSLocalizedStringRequireBundle…
…Rule description
- Loading branch information
Matthew Healy
committed
Mar 29, 2019
1 parent
9d0ac2d
commit 74b51c5
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
Source/SwiftLintFramework/Rules/Lint/NSLocalizedStringRequireBundleRule.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import Foundation | ||
import SourceKittenFramework | ||
|
||
public struct NSLocalizedStringRequireBundleRule: ASTRule, OptInRule, ConfigurationProviderRule, AutomaticTestableRule { | ||
public var configuration = SeverityConfiguration(.warning) | ||
|
||
public init() {} | ||
|
||
public static let description = RuleDescription( | ||
identifier: "nslocalizedstring_require_bundle", | ||
name: "NSLocalizedString Require Bundle", | ||
description: "Calls to NSLocalisedString should specify the bundle which contains the strings file.", | ||
kind: .lint, | ||
nonTriggeringExamples: [ | ||
""" | ||
NSLocalizedString("someKey", bundle: .main, comment: "test") | ||
""", | ||
""" | ||
NSLocalizedString("someKey", tableName: "a", | ||
bundle: Bundle(for: A.self), | ||
comment: "test") | ||
""", | ||
""" | ||
NSLocalizedString("someKey", tableName: "xyz", | ||
bundle: someBundle, value: "test" | ||
comment: "test") | ||
""", | ||
""" | ||
arbitraryFunctionCall("something") | ||
""" | ||
], | ||
triggeringExamples: [ | ||
""" | ||
↓NSLocalizedString("someKey", comment: "test") | ||
""", | ||
""" | ||
↓NSLocalizedString("someKey", tableName: "a", comment: "test") | ||
""", | ||
""" | ||
↓NSLocalizedString("someKey", tableName: "xyz", | ||
value: "test", comment: "test") | ||
""" | ||
] | ||
) | ||
|
||
public func validate(file: File, | ||
kind: SwiftExpressionKind, | ||
dictionary: [String: SourceKitRepresentable]) -> [StyleViolation] { | ||
return [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters