I have a simple HTML + CSS + JS project, where I want to use a JS class. I defined the class as:
class Warning {
constructor(id, className) {
this.id = id;
this.className = className;
}
add () {
$(this.id).addClass(this.className);
}
remove () {
$(this.id).removeClass(this.className);
}
}
export default Warning;
and tried to use it in contact.js:
import Warning from './Warning.js';
const warning = new Warning();
However with both import and export, I got ESLint error:
Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
I tried to use type="module" where the class is imported, but error is still there:
<script src="/static/js/Warning.js" charset="utf-8" type="module"></script>
Any idea how I could use the class?