{"id":19799,"library":"eslint-plugin-import-zod","title":"eslint-plugin-import-zod","description":"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.","status":"active","version":"1.2.1","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/samchungy/eslint-plugin-import-zod","tags":["javascript","eslint","eslintplugin","eslint-plugin","zod","imports","typescript"],"install":[{"cmd":"npm install eslint-plugin-import-zod","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-import-zod","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-import-zod","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required to run the plugin","package":"eslint","optional":false},{"reason":"peer dependency for TypeScript utility functions","package":"@typescript-eslint/utils","optional":false}],"imports":[{"note":"ESM-only; default export. Use dynamic import if needed in CJS.","wrong":"const importZod = require('eslint-plugin-import-zod')","symbol":"importZod","correct":"import importZod from 'eslint-plugin-import-zod'"},{"note":"Rule name is a string; imported plugin provides it.","wrong":"Use with require(): const importZod = require('eslint-plugin-import-zod')","symbol":"prefer-zod-namespace","correct":"import importZod from 'eslint-plugin-import-zod'; ... rules: { 'import-zod/prefer-zod-namespace': 'error' }"},{"note":"configs.recommended is an array of config objects.","wrong":"Using flat config array without spreading","symbol":"configs.recommended","correct":"import importZod from 'eslint-plugin-import-zod'; export default [...importZod.configs.recommended]"}],"quickstart":{"code":"import importZod from 'eslint-plugin-import-zod';\n\nexport default [\n  ...importZod.configs.recommended,\n  {\n    rules: {\n      'import-zod/prefer-zod-namespace': 'error',\n    },\n  },\n];","lang":"javascript","description":"Sets up the plugin with recommended config and enables the prefer-zod-namespace rule in ESLint flat config."},"warnings":[{"fix":"Use import syntax or configure ESLint as ESM.","message":"Plugin does not support CommonJS; must be used in ESM context.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Review auto-fix changes; namespace import may affect type inference.","message":"The rule 'prefer-zod-namespace' auto-fixes imports by converting default imports to namespace imports; this may change module semantics.","severity":"gotcha","affected_versions":">=1.2.0"},{"fix":"Use namespace import directly.","message":"Deprecated pattern: import zod from 'zod' is auto-fixed to import * as zod from 'zod'.","severity":"deprecated","affected_versions":">=1.2.0"},{"fix":"Migrate to flat config or wrap plugin with compatibility layer.","message":"Plugin only works with ESLint flat config (eslint.config.js), not .eslintrc.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install -D eslint-plugin-import-zod and ensure ESLint is running in ESM mode.","cause":"Package not installed or module resolution fails in CJS","error":"Error: Cannot find module 'eslint-plugin-import-zod'"},{"fix":"Change to dynamic import: const importZod = (await import('eslint-plugin-import-zod')).default;","cause":"Using require() in CJS context","error":"TypeError: importZod is not a function or config"},{"fix":"Use flat config and import the plugin directly, not via string name.","cause":"ESLint cannot resolve plugin due to wrong config format","error":"Error: Failed to load plugin 'import-zod' declared in 'plugins': Cannot find module 'eslint-plugin-import-zod'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}