Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sindresorhus opened this issue Jan 13, 2024 · 5 comments

Comments

@sindresorhus
Copy link
Owner

  • Replace __dirname and __filename with them.
  • Replace const __dirname = path.dirname(fileURLToPath(import.meta.url)); with them.
@casantosmu
Copy link
Contributor

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

@sindresorhus
Copy link
Owner Author

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

@casantosmu
Copy link
Contributor

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

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

@fregante
Copy link
Collaborator

@fisker Did #2261 fix this?

@fisker
Copy link
Collaborator

fisker commented Feb 10, 2024

This not implemented

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants