Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Target the file path instead of adding package.json for resolution
Don't create a subfolder package.json solely to enable a bare directory import; reference the explicit entry file path instead.
Bad example
| 1 | // scripts/task/package.json — added only so `node scripts/task` resolves |
| 2 | { |
| 3 | "type": "module", |
| 4 | "main": "index.ts" |
| 5 | } |
| 6 |
|
| 7 | // package.json script: |
| 8 | "task": "node scripts/task" |
Explanation (EN)
Adding a package.json just so a directory import resolves introduces a config file that exists for no other reason and can mask how the entry point is actually located (Node only auto-resolves index for JS, not TS).
Objašnjenje (HR)
Dodavanje package.json samo da bi se import direktorija razrijesio unosi konfiguracijsku datoteku koja postoji bez drugog razloga i moze sakriti kako se ulazna tocka zapravo pronalazi (Node automatski razrjesava index samo za JS, ne TS).
Good example
| 1 | // package.json script — point directly at the file |
| 2 | "task": "node scripts/task/index.ts" |
Explanation (EN)
Reference the explicit entry file. It's clearer, avoids an extra config file, and doesn't rely on resolution behavior that differs between JS and TS.
Objašnjenje (HR)
Referenciraj eksplicitnu ulaznu datoteku. Jasnije je, izbjegava dodatnu konfiguracijsku datoteku i ne oslanja se na ponasanje razrjesavanja koje se razlikuje izmedu JS-a i TS-a.