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

Make generated files // swift-format-ignore #738

Open
weissi opened this issue Feb 15, 2025 · 7 comments
Open

Make generated files // swift-format-ignore #738

weissi opened this issue Feb 15, 2025 · 7 comments
Labels
area/generator Affects: plugin, CLI, config file. good first issue Good for newcomers kind/enhancement Improvements to existing feature.
Milestone

Comments

@weissi
Copy link
Member

weissi commented Feb 15, 2025

Description

I have generated files & swift-format. I don't want the formatter to reformat the generated code though. So it'd be awesome if it could generate a line with // swift-format-ignore which will disable formatting for that file.

Reproduction

N/a

Package version(s)

All

Expected behavior

No formatting

Environment

All

Additional information

No response

@weissi weissi added kind/bug Feature doesn't work as expected. status/triage Collecting information required to triage the issue. labels Feb 15, 2025
@czechboy0 czechboy0 added area/generator Affects: plugin, CLI, config file. kind/enhancement Improvements to existing feature. good first issue Good for newcomers and removed kind/bug Feature doesn't work as expected. status/triage Collecting information required to triage the issue. labels Feb 15, 2025
@czechboy0 czechboy0 added this to the Post-1.0 milestone Feb 15, 2025
@simonjbeaumont
Copy link
Collaborator

Sounds good.

Are we happy for it to be behind a config option for those that do want to include the generated files in their format?

@MahdiBM
Copy link
Contributor

MahdiBM commented Feb 15, 2025

This is probably the better solution although we could have something in the meanwhile.
We use .swiftformatignore in different projects for now, which has turned out to be fine. The formatting script in .github-workflows repo has been configured to use .swiftformatignore. swift-format itself doesn't really care about it.

@simonjbeaumont
Copy link
Collaborator

I agree that swift-format would benefit from ignore support in its own config file. You’re right that the reusable GitHub workflows have support for this already, but I don’t think we can expect that all adopters use these. @weissi presumably you don’t use the reusable script since you filed the issue?

@weissi
Copy link
Member Author

weissi commented Feb 26, 2025

I agree that swift-format would benefit from ignore support in its own config file. You’re right that the reusable GitHub workflows have support for this already, but I don’t think we can expect that all adopters use these. @weissi presumably you don’t use the reusable script since you filed the issue?

Correct, not using those. I'm fine with a configuration option to turn on/off // swift-format-ignore comments in gen'd files.

@MahdiBM
Copy link
Contributor

MahdiBM commented Feb 26, 2025

That'd be fine with me, I'd just make sure it's not tied to swift-format.

Maybe a "top-level-comments" property, then users can specify "swift-format-ignore".
+ good docs.

@FranzBusch
Copy link
Member

@simonjbeaumont
Copy link
Collaborator

@MahdiBM wrote:

That'd be fine with me, I'd just make sure it's not tied to swift-format.

Maybe a "top-level-comments" property, then users can specify "swift-format-ignore". + good docs.

I'm less inclined to make this super generalisable. Seems like an odd thing for folks to be inserting arbitrary things at the top of the generated file and, while I would be sympathetic to not wanting to over-index on one tool if we had an ecosystem of tens of linters, swift-format is now in the Swift toolchain so IMHO we could just add this unilaterally.

Sounds like @FranzBusch agrees (#738 (comment)) and if Swift Protobuf is doing this, then I'm inclined for us to.

What do others think. I know I originally suggested we make this configurable but maybe we should just add the comment(s) unilaterally? Any objections?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/generator Affects: plugin, CLI, config file. good first issue Good for newcomers kind/enhancement Improvements to existing feature.
Projects
None yet
Development

No branches or pull requests

5 participants