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

improvement: Support script files #1901

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ case class Args(

object Args extends TPrintImplicits {
val baseMatcher: PathMatcher =
FileSystems.getDefault.getPathMatcher("glob:**.{scala,sbt}")
FileSystems.getDefault.getPathMatcher("glob:**.{scala,sbt,sc}")
val runtimeScalaVersion: ScalaVersion = ScalaVersion
.from(scala.util.Properties.versionNumberString) // can be empty
.toOption
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ case class ScalafixConfig(

def dialectForFile(path: String): Dialect =
if (path.endsWith(".sbt")) DefaultSbtDialect
else if (path.endsWith(".sc"))
dialect
.withAllowToplevelTerms(true)
else dialect

val reader: ConfDecoder[ScalafixConfig] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,24 @@ class CliSyntacticSuite extends BaseCliSuite {
expectedExit = ExitStatus.Ok
)

check(
name = "fix script files",
originalLayout = s"""|/a.sc
|def foo { println(1) }
|lazy val bar = project
|""".stripMargin,
args = Array(
"-r",
"ProcedureSyntax",
"a.sc"
),
expectedLayout = s"""|/a.sc
|def foo: Unit = { println(1) }
|lazy val bar = project
|""".stripMargin,
expectedExit = ExitStatus.Ok
)

check(
name = "deprecated name emits warning",
originalLayout = s"""|/a.scala
Expand Down