sindresorhus / eslint-plugin-unicorn

More than 100 powerful ESLint rules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support `import.meta.dirname` and `import.meta.filename` in `prefer-module` rule

sindresorhus opened this issue · comments

  • Replace __dirname and __filename with them.
  • Replace const __dirname = path.dirname(fileURLToPath(import.meta.url)); with them.

Are you considering adding this as an option? Given that many projects are still running on the previous LTS version and libraries support older versions, this change would break their code

I think we can just wait until we can target Node.js 20 (in April).

Perfect. I could work on this :). Also, I would consider replacing this pattern:

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

This not implemented

Replace const __dirname = path.dirname(fileURLToPath(import.meta.url)); with them.