💼 This rule is enabled in the ✅ recommended
config.
🔧 This rule is automatically fixable by the --fix
CLI option.
Sanity does not require the use of "defineType()". Utilizing this helper function validates the schema while developing, and helps prevent runtime errors.
This rule requires Sanity schemas to be wrapped with the "defineType" helper function.
Examples of incorrect code for this rule:
/*eslint sanity-studio/define-type-helper: "error"*/
export const product = {
name: "product",
type: "document",
title: "Product",
fields: [
// ...
],
};
Examples of correct code for this rule:
/*eslint sanity-studio/define-type-helper: "error"*/
export const product = defineType({
name: "product",
type: "document",
title: "Product",
fields: [
// ...
],
});
If you deem using the "defineType" function unnessary. This rule can be used independently from "define-field-helper" and "define-array-member-helper".