Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hope will be more flexible disable rules #1753

Open
rakuyoMo opened this issue Jul 10, 2024 · 0 comments
Open

Hope will be more flexible disable rules #1753

rakuyoMo opened this issue Jul 10, 2024 · 0 comments

Comments

@rakuyoMo
Copy link
Contributor

As far as I know, there are currently several ways to disable SwiftFormat in the code:

// swiftformat:disable:next

// swiftformat:disable <rule1> [<rule2> [rule<3> ...]]

// swiftformat:disable all

This issue is for swiftformat:disable:next. I hope there will be more flexible disable rules, such as disable:this and disable:previous.

Consider the following code:

struct DBModel: Codable {
    /// Some descriptive notes 
    /// swiftformat:disable:next redundantRawValues
    enum Columns: String, CodingKey {
        /// Descriptive comment for the case, with or without it.
        case id = "id"
    }
}

The situation of swiftformat:disable:next redundantRawValues is awkward. It is mistakenly written into the type annotation of Columns, but if this method is not used, the only option is to use the more complicated swiftformat:disable redundantRawValues, which takes up more lines and is not concise enough.

If we had swiftformat:disable:previous , things would be much better:

struct DBModel: Codable {
    /// Some descriptive notes 
    enum Columns: String, CodingKey {
        // swiftformat:disable:previous redundantRawValues

        /// Descriptive comment for the case, with or without it.
        case id = "id"
    }
}

Sincerely hope that disable:this and disable:previous can be introduced into SwiftFormat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants