1.1.0-beta.5 • Published 7 years ago
scalafmt v1.1.0-beta.5
scalafmt
A JS API for scalafmt
.
It exposes a single function:
format(code: string, configString?: string, ranges?: Range[]): string
: formats the given code
where:
code
is the entire source code you want to formatconfigString
optional is the Scalafmt configuration (as documented here). If not provided, the default one is used.ranges
optional is an array of ranges. If not provided, the entire document is formatted. Each range is an object with two properties:start
: the start line of the rangeend
: the end line of the range (not inclusive)
Example:
const { format } = require('scalafmt');
const input = `
object Main {
case class Foo(
a: String,
b: Boolean,
c: Int
)
val x = Foo("a", true
, 2)
}`;
const output = format(input);
console.log(output);
// Output:
// object Main {
// case class Foo(
// a: String,
// b: Boolean,
// c: Int
// )
// val x = Foo("a", true, 2)
// }
1.1.0-beta.5
7 years ago
1.1.0-beta.4
7 years ago
1.1.0-beta.3
7 years ago
1.1.0-beta.2
7 years ago
1.1.0-beta.1
7 years ago