1
votes

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

1 Answers

2
votes

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