Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receiving "Unexpected token export" when using default export #418

Closed
jtreanor opened this issue Feb 18, 2019 · 2 comments
Closed

Receiving "Unexpected token export" when using default export #418

jtreanor opened this issue Feb 18, 2019 · 2 comments

Comments

@jtreanor
Copy link
Contributor

jtreanor commented Feb 18, 2019

I am having some trouble getting Peril set up for our org. It seems to be getting stuck on the default export, and I don't know why.

Note: I noticed the caveat in the setup doc about the mono repo not being ready so I am using peril at 0db941d on Heroku.

The peril settings repo is here. The rules use the default export like this:

import {warn, fail, danger} from "danger";

export default async () => {
    ....
    // Warn if the PR doesn't have a milestone
    const issue = await danger.github.api.issues.get(danger.github.thisPR);
    if (issue.data.milestone == null) {
        warn("PR is not assigned to a milestone.");
    }
    ...
};

You can see the full file here.

For some reason that I can't seem to figure out I am receiving this error from Peril:

Unexpected token export
/app/danger-0.w2es6eqarz8.js:5
export default async () => {
^^^^^^

SyntaxError: Unexpected token export
    at new Script (vm.js:79:7)
    at VMScript.compile (/app/node_modules/vm2/lib/main.js:78:20)
    at NodeVM.run (/app/node_modules/vm2/lib/main.js:414:27)
    at Object.<anonymous> (/app/node_modules/danger/distribution/runner/runners/vm2.js:115:37)
    at step (/app/node_modules/danger/distribution/runner/runners/vm2.js:43:23)
    at Object.next (/app/node_modules/danger/distribution/runner/runners/vm2.js:24:53)
    at /app/node_modules/danger/distribution/runner/runners/vm2.js:18:71
    at new Promise (<anonymous>)
    at __awaiter (/app/node_modules/danger/distribution/runner/runners/vm2.js:14:12)
    at Object.exports.runDangerfileEnvironment (/app/node_modules/danger/distribution/runner/runners/vm2.js:95:121)
    at runDangerAgainstFileInline (/app/out/danger/danger_runner.js:49:37)
    at process._tickCallback (internal/process/next_tick.js:68:7)

I also get the same error when running yarn danger pr https://github.com/wordpress-mobile/WordPress-iOS/pull/10931 in the repo itself.

Am I missing something obvious or is this a bug somewhere?

@orta
Copy link
Member

orta commented Feb 18, 2019

Yeah, this feels like danger/danger-js#812 to me

Once #417 is working reliably I'll try do a run on getting babel etc up and running, for now you can probably just rename the JS files to TS and I'd expect it shouldwork

@jtreanor
Copy link
Contributor Author

Thanks for the quick response @orta!

Renaming the files to .ts worked, although I'm now seeing #367. I'll follow up in that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants