Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP2stack specificStack: node
nodeesmpaths
Use import.meta.dirname instead of recomputing the directory in ESM
In ESM, get the current directory via import.meta.dirname rather than deriving it from import.meta.url manually.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codejs
| 1 | import { fileURLToPath } from 'url'; |
| 2 | import { dirname } from 'path'; |
| 3 | const __dirname = dirname(fileURLToPath(import.meta.url)); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codejs
| 1 | const dir = import.meta.dirname; |
Explanation (EN)
Objašnjenje (HR)