This plugin lints Sanity schemas to enforce helper functions.
💼 Configurations enabled in.
✅ Set in the recommended configuration.
🔧 Automatically fixable by the --fix CLI option.
| Name | Description | 💼 | 🔧 |
|---|---|---|---|
| define-array-member-helper | Enforce "defineArrayMember" helper functions for Sanity schema arrays. | ✅ | 🔧 |
| define-field-helper | Enforce "defineField" helper functions for Sanity schema fields. | ✅ | 🔧 |
| define-type-helper | Enforce "defineType" helper functions for Sanity schemas. | ✅ | 🔧 |
You'll first need to install ESLint:
npm install eslint --save-dev
yarn add eslint --dev
pnpm add eslint --save-devNext, install eslint-plugin-sanity-studio:
npm install eslint-plugin-sanity-studio --save-dev
yarn add eslint-plugin-sanity-studio --dev
pnpm add eslint-plugin-sanity-studio --save-devAdd sanity-studio to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:
{
"plugins": ["sanity-studio"]
}Then configure the rules you want to use under the rules section.
{
"rules": {
"sanity-studio/rule-name": "error"
}
}Alternatively, use the recommended configuration by extending plugin:sanity-studio/recommended.
{
"extends": [
"eslint:recommended",
// Currently errors for all missing helper functions.
"plugin:sanity-studio/recommended"
]
}