Files
SwiftLint/Source/SwiftLintFramework/Rules/Style/InclusiveLanguageRuleExamples.swift
Dalton Claybrook d305e03905 Add inclusive_language rule (#3243)
Current events have renewed the conversation in our community about the roles of terminology with racist connotations in our software. Many companies and developers are now taking appropriate steps to remove this terminology from their codebases and products. (e.g. [GitHub](https://twitter.com/natfriedman/status/1271253144442253312)) This small rule prevents the use of declarations that contain any of the terms: whitelist, blacklist, master, and slave. It may be appropriate to add more terms to this list now or in the future.
2020-11-07 22:03:08 -05:00

74 lines
1.9 KiB
Swift

internal struct InclusiveLanguageRuleExamples {
// MARK: - Default config
static let nonTriggeringExamples: [Example] = [
Example("let foo = \"abc\""),
Example("""
enum AllowList {
case foo, bar
}
"""),
Example("func updateAllowList(add: String) {}")
]
static let triggeringExamples: [Example] = [
Example("let ↓slave = \"abc\""),
Example("""
enum ↓BlackList {
case foo, bar
}
"""),
Example("func ↓updateWhiteList(add: String) {}"),
Example("""
enum ListType {
case ↓whitelist
case ↓blacklist
}
"""),
Example("↓init(master: String, slave: String) {}"),
Example("""
final class FooBar {
func register<↓Master, ↓Slave>(one: Master, two: Slave) {}
}
""")
]
// MARK: - Non-default config
static let nonTriggeringExamplesWithConfig: [Example] = [
Example("""
public let blackList = [
"foo", "bar"
]
""", configuration: [
"override_terms": ["abc123"]
]),
Example("""
private func doThisThing() {}
""", configuration: [
"override_terms": ["abc123"],
"additional_terms": ["xyz789"]
])
]
static let triggeringExamplesWithConfig: [Example] = [
Example("""
enum Things {
case foo, ↓fizzBuzz
}
""", configuration: [
"additional_terms": ["fizzbuzz"]
]),
Example("""
private func ↓thisIsASwiftyFunction() {}
""", configuration: [
"additional_terms": ["swift"]
]),
Example("""
private var ↓fooBar = "abc"
""", configuration: [
"additional_terms": ["FoObAr"]
])
]
}