Skip to content

alexanderl19/eslint-plugin-sanity-studio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

85f0e00 Β· Jan 1, 2024

History

31 Commits
Jun 24, 2023
Jan 1, 2024
Jun 29, 2023
Jun 27, 2023
Jun 28, 2023
Jun 22, 2023
Aug 21, 2023
Jan 1, 2024
Jan 1, 2024
Jan 1, 2024

Repository files navigation

eslint-plugin-sanity-studio

npm GitHub Workflow Status (with event)

This plugin lints Sanity schemas to enforce helper functions.

Rules

πŸ’Ό 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. βœ… πŸ”§

Installation

You'll first need to install ESLint:

npm install eslint --save-dev
yarn add eslint --dev
pnpm add eslint --save-dev

Next, 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-dev

Usage

Add 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"
  ]
}