Registry / web-framework / eslint-plugin-import-zod

eslint-plugin-import-zod

JSON →
library1.2.1jsnpmunverified

ESLint plugin (v1.2.1) that enforces namespace imports for zod (`import * as z from "zod"`) to improve tree-shaking and reduce bundle sizes. Targets eslint >=9 and Node >=20, ships TypeScript types. Auto-fixable: converts default/named imports to namespace imports, splits mixed imports. Released as v1.0.0 in 2025, with active development (recent patches). Unique vs other import rules: specifically for zod ecosystem.

npm install eslint-plugin-import-zod
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-IMPO
E
eslint-plugin-import-zod
web-frameworkjavascriptv1.2.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

importZod
✓ import importZod from 'eslint-plugin-import-zod'
✗ const importZod = require('eslint-plugin-import-zod')
ESM-only; default export. Use dynamic import if needed in CJS.
prefer-zod-namespace
✓ import importZod from 'eslint-plugin-import-zod'; ... rules: { 'import-zod/prefer-zod-namespace': 'error' }
✗ Use with require(): const importZod = require('eslint-plugin-import-zod')
Rule name is a string; imported plugin provides it.
configs.recommended
✓ import importZod from 'eslint-plugin-import-zod'; export default [...importZod.configs.recommended]
✗ Using flat config array without spreading
configs.recommended is an array of config objects.

Sets up the plugin with recommended config and enables the prefer-zod-namespace rule in ESLint flat config.

import importZod from 'eslint-plugin-import-zod'; export default [ ...importZod.configs.recommended, { rules: { 'import-zod/prefer-zod-namespace': 'error', }, }, ];
Debug
Known issues
gotchaPlugin does not support CommonJS; must be used in ESM context.
fix
Use import syntax or configure ESLint as ESM.
affects: >=1.0.0
gotchaThe rule 'prefer-zod-namespace' auto-fixes imports by converting default imports to namespace imports; this may change module semantics.
fix
Review auto-fix changes; namespace import may affect type inference.
affects: >=1.2.0
deprecatedDeprecated pattern: import zod from 'zod' is auto-fixed to import * as zod from 'zod'.
fix
Use namespace import directly.
affects: >=1.2.0
gotchaPlugin only works with ESLint flat config (eslint.config.js), not .eslintrc.
fix
Migrate to flat config or wrap plugin with compatibility layer.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'eslint-plugin-import-zod'
Package not installed or module resolution fails in CJS
fix
npm install -D eslint-plugin-import-zod and ensure ESLint is running in ESM mode.
TypeError: importZod is not a function or config
Using require() in CJS context
fix
Change to dynamic import: const importZod = (await import('eslint-plugin-import-zod')).default;
Error: Failed to load plugin 'import-zod' declared in 'plugins': Cannot find module 'eslint-plugin-import-zod'
ESLint cannot resolve plugin due to wrong config format
fix
Use flat config and import the plugin directly, not via string name.
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies
eslintrequiredpeer dependency required to run the plugin
@typescript-eslint/utilsrequiredpeer dependency for TypeScript utility functions
Agent activity
27 hits · last 30 days
node
24
Amazon
1
OpenAI (training)
1
Resources
eslint-plugin-import-zod — npm install eslint-plugin-import-zod · libregistry