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

@salesforce/acorn-visualforce

Package Overview
Dependencies
Maintainers
5
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@salesforce/acorn-visualforce

acorn extension for Salesforce js dialect with merge fields

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-87.1%
Maintainers
5
Weekly downloads
 
Created
Source

Acorn-VisualForce

This is plugin for Acorn - a tiny, fast JavaScript parser, written completely in JavaScript.

It was created as an experimental parser for VisualForce inline JS.

Usage

You can use module directly in order to get Acorn instance with plugin installed:

const acorn = require('@salesforce/acorn-visualforce');

Or you can use inject.js for injecting plugin into your own version of Acorn like following:

const acorn = require('@salesforce/acorn-visualforce/inject')(require('./custom-acorn'));

Then, use plugins option whenever you need to support VisualForce merge fields while parsing:

const code = 'var foo = {! JSENCODE(someApexVariable) };'
const ast = acorn.parse(code, {
  plugins: { vfel: true }
});

Produces:

{
    "type": "Program",
    "start": 0,
    "end": 42,
    "body": [{
        "type": "VariableDeclaration",
        "start": 0,
        "end": 42,
        "declarations": [{
            "type": "VariableDeclarator",
            "start": 4,
            "end": 41,
            "id": {
                "type": "Identifier",
                "start": 4,
                "end": 7,
                "name": "foo"
            },
            "init": {
                "type": "VFELExpression",
                "start": 10,
                "end": 41,
                "value": {
                    "type": "CallExpression",
                    "start": 12,
                    "end": 39,
                    "callee": {
                        "type": "Identifier",
                        "start": 12,
                        "end": 21,
                        "name": "JSENCODE"
                    },
                    "arguments": [{
                        "type": "Identifier",
                        "start": 22,
                        "end": 38,
                        "name": "someApexVariable"
                    }]
                }
            }
        }],
        "kind": "var"
    }],
    "sourceType": "script"
}

License

This plugin is issued under the BSD-3-Clause license.

Keywords

FAQs

Package last updated on 14 Apr 2017

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