AnyLint
AnyLint copied to clipboard
Convert SwiftLint custom rules to AnyLint checks
Such a converter could transform this:
class_name_suffix_collection_view_controller:
included: ".*\.swift"
regex: 'class +\w+(?<!CollectionViewController) *(?:<[^>]+>)? *: +\w+CollectionViewController'
name: "Class Name Suffix View Controller"
message: "All `CollectionViewController` subclasses should end on `CollectionViewController`."
severity: warning
to something like this:
// MARK: ClassNameSuffixCollectionViewController
try Lint.checkFileContents(
checkInfo: "ClassNameSuffixCollectionViewController: All `CollectionViewController` subclasses should end on `CollectionViewController`.",
regex: #"class +\w+(?<!CollectionViewController) *(?:<[^>]+>)? *: +\w+CollectionViewController"#,
matchingExamples: [], // TODO: [2020-04-21] not yet implemented
nonMatchingExamples: [], // TODO: [2020-04-21] not yet implemented
includeFilters: #".*\.swift"#
)
Consider showing a warning before doing the conversion with a hint that all SwiftLint rules that only work on specific kinds of Swift structures (e.g. only methods) might not work as expected. Consider adding a warning comment in the converted AnyLint configuration file. Also warn the user to make sure they have committed their code before running the new configuration file.