🚫 This rule is disabled in the ✅ recommended
config.
🔧 This rule is automatically fixable by the --fix
CLI option.
Starting with Node.js 20.11, import.meta.dirname
and import.meta.filename
have been introduced in ES modules.
import.meta.filename
is the same as theurl.fileURLToPath()
of theimport.meta.url
.
import.meta.dirname
is the same as thepath.dirname()
of theimport.meta.filename
.
This rule replaces legacy patterns with import.meta.{dirname,filename}
.
import path from 'node:path';
import {fileURLToPath} from "node:url";
// ❌
const filename = fileURLToPath(import.meta.url);
// ✅
const filename = import.meta.filename;
import path from 'node:path';
import {fileURLToPath} from 'node:url';
// ❌
const dirname = path.dirname(fileURLToPath(import.meta.url));
const dirname = path.dirname(import.meta.filename);
const dirname = fileURLToPath(new URL('.', import.meta.url));
// ✅
const dirname = import.meta.dirname;