ESLint throws error when using mandatory file extensions in import in Node

Viewed 149

In latest Node 16.8, file extensions are now mandatory in import (e.g. import { getFoo } from './api.js';). At the same time ESLint throws an error Unexpected use of file extension "js" for "./api.js".

This is my config file:

module.exports = {
  env: {
    node: true,
    es2021: true,
  },
  extends: [
    'airbnb-base',
  ],
  parserOptions: {
    ecmaVersion: 12,
  },
  rules: {
    'no-console': 'off',
  },
};

What's the best practice at the moment? Or at least the best walkaround?

If not, can I at least disable that rule?

0 Answers
Related