Skip to content

Commit 8234175

Browse files
committed
Improve eslint config to ensure lodash imports have their extension set
1 parent 03ef336 commit 8234175

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

eslint.config.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,14 @@ export default defineConfig([
8686
{
8787
name: 'lodash',
8888
message:
89-
"Named import from lodash should be avoided for performance reasons. Use a default import instead. E.g. `import merge from 'lodash/merge.js';` instead of `import { merge } from 'lodash';`.",
89+
"Named import from lodash should be avoided for performance reasons. Use a default import instead. E.g. `import merge from 'lodash/merge.js';` (note the file extension) instead of `import { merge } from 'lodash';`.",
90+
},
91+
],
92+
patterns: [
93+
{
94+
regex: 'lodash/(?![a-zA-Z]*\\.js$)',
95+
message:
96+
'Always specify the file extension when importing from lodash or it will cause runtime issues for ESM environments.',
9097
},
9198
],
9299
},

0 commit comments

Comments
 (0)