π« This rule is disabled in the following configs: β
recommended, βοΈ unopinionated.
π§ 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.filenameis the same as theurl.fileURLToPath()of theimport.meta.url.
import.meta.dirnameis 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;