Javascript: Prefer default export not working for const variable

Created on 17 Apr 2018  Â·  2Comments  Â·  Source: airbnb/javascript

If I have single export in a file like this

export const url = "google.com";

It shows me linting error for prefer-default-export, but making it default would throw me this error
Parsing error: Unexpected token const

question

Most helpful comment

Because that’s not a default export; if you want it default you’ll have to do it in two lines:

const url = ‘google.com’;
export default url;

All 2 comments

Because that’s not a default export; if you want it default you’ll have to do it in two lines:

const url = ‘google.com’;
export default url;

This solves my problem. Cool, thanks 🎉

Was this page helpful?
0 / 5 - 0 ratings

Related issues

weihongyu12 picture weihongyu12  Â·  3Comments

mismith picture mismith  Â·  3Comments

tpiros picture tpiros  Â·  3Comments

koiralakiran1 picture koiralakiran1  Â·  3Comments

xgqfrms-GitHub picture xgqfrms-GitHub  Â·  3Comments