There are multiple questions about about import and require and their differences. Like these:
What is the difference between 'import' and 'require' in JavaScript?
The difference between "require(x)" and import x
ignore eslint error: 'import' and 'export' may only appear at the top level
I'm building an electron app with Vue and linting with ES6. But as soon as I use import I get a lint error:
[eslint] Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
This happens both in the nodejs part of electron and the front end one.
The accepted answer in the last link says "ESLint natively doesnt support this because this is against the spec." and then gives an option of how to get rid of the error by using babel.
As I thought ES6 supports imports and I'm using ES6, why does it still complain about this?
I used vue-cli 3 to generate the project which has a main.js file which starts with import Vue from 'vue';
which gives me the lint error above even if running the code works.
Could someone clarify why ESLint set to use ES6 complains when using imports? And if its still not supported why does a framework like Vue use it? How would I properly use import with only ES6 without the use of babel?