Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable eslint parsing error message

In my code I have a conditional export:

if (process.env.NODE_ENV === 'testing')
  export myFunc;

In es6 this statement is not allowed because imports and exports should be top-level, but using babel with some plugins and webpack this condition is eliminated at build-time, so in my resulting code this export is either top-level or not present.

But eslint reports a parsing error and I want to get rid of it. /*eslint-disable */ doesn't work, because, well, it's not a rule violation, it's a parsing error. Is there a possible workaround?

P.S.: I know I can commonjs it, but I want to stick with es6.

like image 500
aush Avatar asked Oct 15 '25 10:10

aush


1 Answers

I know I can commonjs it, but I want to stick with es6.

Really, you aren't compliant with ES6 specification, so... you need to commonjs it.

The Idea behind a transpiler is that you'll can disable it when the next specification comes actual.

In this case, your code won't work in a full ES6 environment.

like image 67
Hitmands Avatar answered Oct 17 '25 00:10

Hitmands