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

Lint rule to ban __dirname and __filename #224

Open
luxaritas opened this issue Jul 26, 2023 · 0 comments
Open

Lint rule to ban __dirname and __filename #224

luxaritas opened this issue Jul 26, 2023 · 0 comments
Labels
priority: p3/standard Enhancement with nominal value or bug with nominal impact scope: eslint-plugin size: sm type: enhancement New feature or request

Comments

@luxaritas
Copy link
Member

Describe your idea

Add a lint rule that bans usage of __dirname and __filename (ideally, just in ESM scope)

Motivation

These globals are not defined in ESM scope. Something like url.fileURLToPath(import.meta.url)/path.dirname(url.fileURLToPath(import.meta.url)) or a construction like path.fileURLToPath('relative/path', import.meta.url) should be used instead

Proposed Solution

Maybe adding additional configuration to no-restricted-globals? This would prevent usage in non-transpiled CJS projects though

Other Information

No response

@luxaritas luxaritas added type: enhancement New feature or request scope: eslint-plugin size: sm priority: p3/standard Enhancement with nominal value or bug with nominal impact labels Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3/standard Enhancement with nominal value or bug with nominal impact scope: eslint-plugin size: sm type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant