2

How to tell eslint to: disable next line for

"'import' and 'export' may appear only with 'sourceType: module'"

Without configuration, it has to be inline.

The following doesn't seem to be working

/* eslint-disable */ 
// eslint-disable-next-line 

Why:

Let's say you are writing a test inside a NON module project, and you want to prove you can or cannot dynamically import an ESM module.

describe('my test', it("doesn't work", ()=> require('./my.esm.js')) 

Where 'my.esm.js' could be

export function noop {} 

...or whatever

But the main project, nor the tests are module based.

1 Answer 1

2

You can try to add "sourceType": "module" to your eslint config file. Here's example:

{ "parserOptions": { "ecmaVersion": 6, "sourceType": "module", "ecmaFeatures": { "jsx": true } }, "rules": { "semi": "error" } } 

source: eslint docs

Sign up to request clarification or add additional context in comments.

6 Comments

Thank you, but I need it be in-line as a comment.
@Dan okay! I understood your concern. but did it work?
,The configuration ? I'm pretty sure it will ... , don't see why not. But is not what I need :(
I suggest you to refer original eslint docs for this. I have already mentioned a link in my answer. I hope you may find your answer there.
This answer does nothing for me. I still see the same error. Any ideas?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.