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

golopot picture golopot  Â·  3Comments

surfaceowl picture surfaceowl  Â·  3Comments

vsemozhetbyt picture vsemozhetbyt  Â·  3Comments

graingert picture graingert  Â·  3Comments

stephenkingsley picture stephenkingsley  Â·  3Comments