💼 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 "defineField()", even when the schema is enclosed in "defineType()". Utilizing this helper function validates the schema while developing, and helps prevent runtime errors.
This rule requires Sanity schema fields to be wrapped with the "defineField" helper function.
Examples of incorrect code for this rule:
/*eslint sanity-studio/define-field-helper: "error"*/
export const product = {
name: "product",
type: "document",
title: "Product",
fields: [
{
name: "productName",
type: "string",
title: "Product name",
},
// ...
],
};
Examples of correct code for this rule:
/*eslint sanity-studio/define-field-helper: "error"*/
export const product = {
name: "product",
type: "document",
title: "Product",
fields: [
defineField({
name: "productName",
type: "string",
title: "Product name",
}),
// ...
],
};
If you deem using the "defineField" function unnessary. This rule can be used independently from "define-type-helper" and "define-array-member-helper".