question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add option to specify my own acorn

See original GitHub issue

Acorn and acorn-jsx are hardcoded in espree which makes it hard to extend espree for other syntax flavors.

// reference code from espree
var acornJSX = require("acorn-jsx/inject"),
var rawAcorn = require("acorn");
var acorn = acornJSX(rawAcorn);

// following down the code
        if (extra.ecmaFeatures.jsx) {
            // Should process jsx plugin before espree plugin.
            acornOptions.plugins = {
                jsx: true,
                espree: true
            };
        }

I wrote my own acorn extension, and I would like to feed it to espree in my eslint plugin.

The way I do it now is monkey patch api.verify in eslint with the following code:

const proxyquire = require('proxyquire');

let espreePath = Object.keys(requireCache).find(key => key.endsWith(path.join('espree', 'espree.js')))
espreePath = espreePath ? espreePath : 'espree'
let acornPath = Object.keys(requireCache).find(key => key.endsWith(path.join('dist', 'acorn.js')))
acornPath = acornPath ? acornPath : 'acorn'

const acorn = require(acornPath)
const acornVFEL = require('@salesforce/acorn-visualforce/dist/inject')(acorn, true)
const espree = proxyquire(espreePath, { acorn: acornVFEL })

Which is a) ugly, b) prone to errors.

The problem with this approach is that acorn-jsx is injected later overriding my overrides to acorn. Ideally, my plugin should be injected after acorn-jsx, but there is no way I can do it currently.

Is it possible to add an option to espree to specify my own acorn package in a fashion that acorn-jsx does? It should be a very simple addition, something like var acorn = options.acorn || require("acorn-jsx")

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
not-an-aardvarkcommented, May 3, 2017

Thanks for explaining.

It would require some effort to rewrite them to make it “injectable”, but I’m willing to do this, as long as I’ll have confidence that the maintainers are onboard with this change.

Please don’t do this yet – I was just throwing an idea out there, and I’m not sure it’s the right choice 😃

0reactions
nzakascommented, Dec 1, 2020

Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to be implemented after 90 days tend to never be implemented, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can I choose my investments? - Acorns Help Center
Although you cannot choose the investments in our managed portfolios, you have the ability to select a more/less aggressive portfolio than ...
Read more >
Preferences - Acorn - Flying Meat Software
The Preference Panel for Acorn is located under Acorn ▸ Preferences . ... Here you will find options to select the default color...
Read more >
how to Use Acorns App - Investing For Beginners - YouTube
For example, if you link your debit card and buy something for $16.80, .20 cents will be invested in your Acorn account. Another...
Read more >
Acorns App Tutorial | Turn PENNIES into MILLIONS!? - YouTube
Acorns App Tutorial | Turn PENNIES into MILLIONS!$5000 of Investments Managed for FREE from Wealthfornt: ...
Read more >
5 PRO TIPS To Get The Most Out Of ACORNS - YouTube
IMPORTANT LINKS: - Acorns - My recommended app for investing and ... please do your own research to make the best personal decisions...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found