Skip to content

Rule to enforce importing from astro/zod over zod / zod/*? #558

Description

@JoshuaKGoldberg

Motivation

https://docs.astro.build/en/reference/modules/astro-zod/#imports-from-astrozod says:

The astro/zod module exposes a re-export of Zod that gives you access to all the features of Zod v4. By using this module, you do not need to install Zod yourself. This also ensures that your project uses the same API versions as Astro when using features such as Content Collections or Actions.

This means to me that Astro has a preference for importing from astro/zod and not any other path for Zod, right?

Description

It'd be nice to have:

  • Reporting on incorrect Zod imports, especially for folks updating from older versions of Astro
  • Auto-fixes to make that transition easier

Examples

// GOOD
import { z } from 'astro/zod';
// BAD
import { z } from 'zod';

Additional comments

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions