#Weird eslint issue

6 messages · Page 1 of 1 (latest)

humble timber

Ok so, I transitioned my code to modules more recently and I had this bit of code that works perfectly fine:

client.commands = new Collection();
const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
    const filePath = path.join(commandsPath, file);
    const { default: command } = await import(filePath);
    client.commands.set(command.data.name, command);
}

but es lint says this:

Parsing error: Cannot use keyword 'await' outside an async function eslint
dim gust

are you using esm?

humble timber
dim gust

do you have type: module in your package.json?

humble timber

The code runs