Socket
Socket
Sign inDemoInstall

scalafmt

Package Overview
Dependencies
0
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    scalafmt

A JS API for [`scalafmt`](https://github.com/scalameta/scalafmt).


Version published
Weekly downloads
5
increased by400%
Maintainers
3
Created
Weekly downloads
 

Readme

Source

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 format
  • configString [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 range
    • end: 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)
// }

FAQs

Last updated on 04 Aug 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc