AnyLint icon indicating copy to clipboard operation
AnyLint copied to clipboard

Convert SwiftLint custom rules to AnyLint checks

Open Jeehut opened this issue 4 years ago • 1 comments

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"#
    )

Jeehut avatar Apr 21 '20 10:04 Jeehut

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.

Jeehut avatar Jul 02 '21 10:07 Jeehut