Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prettier-plugin-apex

Package Overview
Dependencies
Maintainers
2
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prettier-plugin-apex

Salesforce Apex plugin for Prettier

  • 1.0.0-alpha.2
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

Prettier Apex Build Status

Prettier Banner

This is a code formatter for the Apex Programming Language, used on the Salesforce development platform.

It uses the excellent Prettier engine for formatting, and the jorje compiler from Salesforce for parsing.

Status

This project is actively being worked on, and has been tested on production code.

  • Formatting still needs work.
  • Some defaults might be changed in the future, e.g. default number of spaces, continuation indent, etc.

Usage

Requirements

  • Node >= 8
  • Java Runtime Engine >= 1.8.0

How to use

First, install the library:

# Install locally
npm install --save-dev prettier prettier-plugin-apex

# Or install globally
npm install --global prettier prettier-plugin-apex

If you install globally, run:

prettier --write "/path/to/project/**/*.{trigger,cls}"

If you install locally, you can add prettier as a script in package.json:

{
  "scripts": {
    "prettier": "prettier"
  }
}

Then in order to run it:

npm run prettier -- --write "/path/to/project/**/*.{trigger,cls}"

Performance Tips/3rd party integration

By default, this library invokes a CLI application to get the AST of the Apex code. However, since this CLI application is written in Java, there is a heavy start up cost associated with it. In order to alleviate this issue, we also have an optional Nailgun server that makes sure the start up is invoked exactly once. This is especially useful if this library is integrated in a 3rd party application.

In order to use this server, you have to evoke it out of band before running Prettier, as well as specifying a special flag when running Prettier:

# Start the server
node /path/to/libary/tests_config/set_up.js

# In a separate console
prettier --use-standalone-server --write "/path/to/project/**/*.{trigger,cls}"

# After you are done, stop the server
node /path/to/libary/tests_config/tear_down.js

License

MIT

Keywords

FAQs

Package last updated on 10 Dec 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc