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

ScalaFmt takes filepath into consideration. #1854

Merged
merged 5 commits into from
May 23, 2024

Conversation

SimY4
Copy link
Contributor

@SimY4 SimY4 commented Oct 10, 2023

ScalaFmt extension takes the file path into account to get the fileOverride scalafmt.conf section to work correctly.

@SimY4 SimY4 force-pushed the topic/scalafmt-file-path branch 2 times, most recently from 162a94d to 72fe5de Compare October 10, 2023 04:59
@nedtwigg
Copy link
Member

Looks like this breaks the integration tests, not sure why.

@nedtwigg nedtwigg added waiting on PR submitter pr-archive PRs which are still valid but have gotten stuck for some reason labels Feb 12, 2024
@SimY4 SimY4 force-pushed the topic/scalafmt-file-path branch 3 times, most recently from 30924e4 to 47c06a8 Compare May 23, 2024 01:29
@SimY4 SimY4 force-pushed the topic/scalafmt-file-path branch from 47c06a8 to 1fff681 Compare May 23, 2024 04:20
@SimY4
Copy link
Contributor Author

SimY4 commented May 23, 2024

@nedtwigg took me almost a year to come back to it finally. I figured it out.

ScalaFmt treats certain files specially, i.e. .scala files are treated as source files and .sc files are treated and worksheets or ammonite shell scripts. What's relevant for spotless is that they have a slightly different syntax rules and therefore they can be formatted slightly differently.

Once I've started feeding real file path into scalafmt, this difference become apparent. In maven test suite there's a test that checks whether .scala and .sc files can be formatted but the check assumed that they both would be formatted the same way. And that was no longer the case.

@@ -1,4 +1,4 @@
@ foobar("annot", {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change here is to eliminate the difference in formatting between .sc and .scala files so that test harness would still work the same.

@nedtwigg
Copy link
Member

Thanks for coming back!

@nedtwigg nedtwigg enabled auto-merge May 23, 2024 07:29
fix formatting.
auto-merge was automatically disabled May 23, 2024 09:28

Head branch was pushed to by a user without write access

@nedtwigg
Copy link
Member

lol after all that I delete the actual fix, lol. Thanks for checking and fixing!

@nedtwigg nedtwigg merged commit df26a83 into diffplug:main May 23, 2024
14 checks passed
@SimY4 SimY4 deleted the topic/scalafmt-file-path branch May 23, 2024 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-archive PRs which are still valid but have gotten stuck for some reason waiting on PR submitter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants