chore: consistent type import paths - #3926
Conversation
✅ Deploy Preview for fakerjs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## next #3926 +/- ##
=======================================
Coverage 98.84% 98.84%
=======================================
Files 923 923
Lines 3216 3216
Branches 583 583
=======================================
Hits 3179 3179
Misses 33 33
Partials 4 4
🚀 New features to boost your workflow:
|
Shinigami92
left a comment
There was a problem hiding this comment.
Would it be possible to use a lint rule for this?
Maybe, though I'm not sure what to search for. |
Literally paste the url of this PR and tell your AI to make a WebFetch. It is 2026. |
|
@ST-DDT I gave claude this request:
Claude ResponseI've read the PR. The maintainer (Shinigami92) asked exactly this, and ST-DDT wasn't sure what to search for. Let me check what's already in faker's ESLint setup so I can give you something that drops in cleanly.Let me check faker's current ESLint config directly to tailor this.Yes — and Tailored to what the PR describes — everything under // eslint.config.ts (flat config)
{
files: ['src/**/*.ts'],
rules: {
'import/no-restricted-paths': ['error', {
zones: [
{
target: './src',
from: './src/index.ts',
// locales still import definitions from the root index until
// the generate:locales script is reworked (the follow-up PR)
except: ['./src/locales'],
message:
'Import from the specific source file (e.g. ./faker or the concrete definitions/types file), not the root barrel.',
},
],
}],
},
}The index file re-exporting from its own modules is fine — it's the source of the barrel, not an importer of it. And A few caveats worth flagging to the maintainers:
If the real intent is broader than "the root barrel" — i.e. ST-DDT's search regex One thing the plain core If you want, I can sketch the matching So maybe we could investigate further with https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-restricted-paths.md |
I noticed that the helpers module imports it's types directly from the root index, while all other modules import the faker instance from the faker file directly. This (minimally) speeds up build performance for partial builds, as a smaller set of files need to be parsed for the build process to complete.
I searched for:
import (type )?\{ .*(\.|/)'in:
srcexcluding:
src/localessrc/localesalways imports the definitions from the root index.I plan to address that once this PR is merged, as it requires changes to the
generate:localesscript.