-
-
Notifications
You must be signed in to change notification settings - Fork 474
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
📎 Implement noGlobalDirnameFilename rule #4331
Comments
@ematipico I don't know Rust, so unfortunately can't implement it myself. |
Then why was this task open? Usually, these issues are open after a previous discussion, or by maintainers. If there wasn't prior discussion, could you please open a discussion instead? |
@ematipico I've linked previous discussion, see #4245. I believe you thumbs uped it as well :D There was an ask to open a task for it from one of the collaborators. |
We have the noCommonJs rule, but it only applies to imports and exports. If we want to add the prefer-modules rule, I think we should break it down into a few specific rules.
|
|
IMO from a user's perspective "noGlobalLegacyPath" reads like it's banning something related to paths, not global variables |
|
Is this not covered by noRedundantUseStrict?
It is already a syntax error in module. Do I miss something?
I wonder, is there reason to create a dedicated rule or should we ad this to
noGlobalDirnameFilename should be fine. |
From a quick search, it looks like these globals are only valid in commonjs environments. So I think yeah, it would make sense to put it in the same rule. However, things against this that I can think of is:
For those reasons I think it would make sense to keep this as a separate rule, or have options for the |
It's covered! I missed it. |
You made a good point. Let's keep the rule separated. We should certainly add a pointer to the new rule in |
Description
__dirname
doesn't work in ESM context, but is not easily caught by tests, as e. g. vitest injects__dirname
, so it works correctly there, but then fails in production. __filename is also in a similar situation.Prior art: https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-module.md
Also see #4245
The text was updated successfully, but these errors were encountered: