-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Description
Hello there. I've been updating dependancies and now in all files I import fs/promises in I am getting Cannot use import declarations in modules that export using CommonJS (module.exports = 'foo' or exports.bar = 'hi') import/no-import-module-exports
I'm not entirely sure whats happening here.
Here is some info:
.eslintrc.json
{
"env": {
"es2021": true,
"node": true
},
"extends": ["airbnb-base", "prettier"],
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"rules": {
"no-console": "off",
"no-param-reassign": "off",
"no-restricted-syntax": "off"
}
}
Eslint version ^8.2.0
Eslint plug import version ^2.25.2
An example file that is getting the error:
import fs from 'fs/promises';
const subscriptions = new Map();
export default async (client) => {
/**
* loads all modules and their subscriptions
*/
const modules = await fs.readdir('./src/modules');
await Promise.all(
modules.map(async (moduleName) => {
// Loads the module
const module = await import(`./modules/${moduleName}/module.js`);
// skips the module, in case it is disabled.
if (module.enabled) {
// Loads each of it's subscriptions into their according list.
module.subscriptions.forEach((fun, event) => {
if (!subscriptions.has(event)) {
subscriptions.set(event, []);
}
subscriptions.get(event).push(fun);
});
}
})
);
/**
* Setting up all events.
* binds all events inside the subscriptions map to call all functions provided
*/
subscriptions.forEach((funs, event) => {
client.on(event, (...args) => {
funs.forEach(async (fun) => {
try {
await fun(client, ...args);
} catch (e) {
client.emit('error', e);
}
});
});
});
};
A screenshot of the error happening
A related issue from eslint-config-airbnb-base
airbnb/javascript#2496
shian15810, micalevisk, HiroyukiTamura, raulvillora, zavarka and 1 moreljharb
Metadata
Metadata
Assignees
Labels
No labels