For my project, I've set up ESM (.mjs) files for server-side code, CommonJS (.js) for tooling, and TypeScript (.ts) for the client side.
In VS Code, when I look at CommonJS files, I'm getting errors related to requires such as "Require statement not part of import statement.eslint@typescript-eslint/no-var-requires."
While this rule makes sense for .ts files, it doesn't quite fit for CommonJS.
Here's a snippet from my ESLint config in package.json...
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended",
"@vue/typescript/recommended",
"@vue/prettier",
"@vue/prettier/@typescript-eslint"
],
"parserOptions": {
"ecmaVersion": 2020
},
"rules": {
"prettier/prettier": [
"error",
{
"semi": false
}
]
},
"overrides": [
{
"files": [
"**/__tests__/*.{j,t}s?(x)",
"**/tests/unit/**/*.spec.{j,t}s?(x)"
],
"env": {
"jest": true
}
}
]
},
Any suggestions on how I can configure it so that TypeScript rules apply to .ts files, CommonJS rules to .js files, and ESM rules to .mjs files?