diff --git a/.changeset/breezy-cobras-joke.md b/.changeset/breezy-cobras-joke.md index 5f6d871f1..e1bda0a11 100644 --- a/.changeset/breezy-cobras-joke.md +++ b/.changeset/breezy-cobras-joke.md @@ -3,18 +3,3 @@ --- Add `validateAllManifests` option to `generate` function. You can use this option to run a custom validation function for all manifests. This function will be called after all manifests are resolved. - -```ts -generate(values, { - validateAllManifests(manifests) { - for (const manifest of manifests) { - if (!manifest.metadata.namespace) { - manifest.report({ - severity: "error", - message: "Namespace is required" - }); - } - } - } -}); -``` diff --git a/.changeset/famous-shirts-train.md b/.changeset/famous-shirts-train.md index 742617d12..977adc16b 100644 --- a/.changeset/famous-shirts-train.md +++ b/.changeset/famous-shirts-train.md @@ -2,4 +2,4 @@ "@kosko/require": minor --- -Add `resolveModule` function. +Add `resolveModule` function. This function supports both module name and path resolution. Unlike `resolvePath` function which only supports path resolution. diff --git a/.changeset/hot-ants-enjoy.md b/.changeset/hot-ants-enjoy.md index 66086ce05..1f3535599 100644 --- a/.changeset/hot-ants-enjoy.md +++ b/.changeset/hot-ants-enjoy.md @@ -4,13 +4,17 @@ Add `validateManifest` option to `generate` and `resolve` function. You can use this option to run a custom validation function for each manifest. This function will be called after the `transform` function and the `validate` method of a manifest. +The following example shows how to use this option to validate that a manifest has a namespace. + ```ts resolve(values, { validateManifest(manifest) { - manifest.report({ - severity: "error", - message: "This is an error message" - }); + if (!manifest.metadata.namespace) { + manifest.report({ + severity: "error", + message: "Namespace is required" + }); + } } }); ``` diff --git a/.changeset/sharp-oranges-relax.md b/.changeset/sharp-oranges-relax.md index fd116f68b..41a245957 100644 --- a/.changeset/sharp-oranges-relax.md +++ b/.changeset/sharp-oranges-relax.md @@ -2,4 +2,22 @@ "@kosko/generate": major --- -`path` and `index` properties are replaced by `position` property in `Manifest` type, `ResolveErrorOptions` type and `ResolveError` class. +`path` and `index` properties are replaced by `position` property in `Manifest` type, `ResolveErrorOptions` type and `ResolveError` class.' + +```ts +// Before +{ + path: string; + index: number[]; + data: unknown; +} + +// After +{ + position: { + path: string; + index: number[]; + }; + data: unknown; +} +```