eslint-config-sanity
raw JSON → 7.1.4 verified Sat Apr 25 auth: no javascript
Shared ESLint configuration for Sanity.io projects. Version 7.1.4 is the current stable release, actively maintained. Provides base, React, and TypeScript config presets that extend recommended defaults. Differentiators: minimal ruleset optimized for Sanity's codebase, automatic handling of React props and TypeScript integration, and support for ESLint 8 and 9. Updated regularly to align with latest ESLint and TypeScript-ESLint versions. Ideal for Sanity plugin development or any project using Sanity's style conventions.
Common errors
error Error: Cannot find module 'eslint-plugin-import' ↓
cause Missing required peer dependency eslint-plugin-import.
fix
Run: npm install --save-dev eslint-plugin-import
error Error: Cannot read config file: .../eslintrc.json Error: Unexpected key 'sanity-extends' ↓
cause Using incorrect extends name (e.g., 'sanity-extends' instead of 'sanity').
fix
Use 'extends': ['sanity'] (for base) or 'extends': ['sanity/react'], etc.
error Parsing error: Cannot read file 'tsconfig.json' ↓
cause Missing tsconfig.json when using @typescript-eslint parser.
fix
Create a tsconfig.json in project root or set parserOptions.project to null if not using type-aware rules.
error ESLint: TypeError: this.getScope is not a function ↓
cause Incompatible version of @typescript-eslint/parser (e.g., v5 with eslint-config-sanity v7).
fix
Update @typescript-eslint/parser to v6 or later: npm install --save-dev @typescript-eslint/parser@^6.0.0
Warnings
breaking Version 7.0.0 changed base config to extend ESLint recommended defaults, which may enable new rules. Review your codebase for potential lint errors. ↓
fix Run 'eslint --fix' and adjust any new violations. If you relied on previous lenient rules, consider overriding rules in your config.
gotcha Order of extends matters: for React+TypeScript, must extend 'sanity/react' before 'sanity/typescript'. ↓
fix Set 'extends' as ['sanity/react', 'sanity/typescript'].
gotcha Missing peer dependencies will cause ESLint to fail. For TypeScript, need @typescript-eslint/parser and @typescript-eslint/eslint-plugin. For React, need eslint-plugin-react and eslint-plugin-react-hooks. ↓
fix Install the required peer deps per the README.
deprecated Rules 'react/prop-types' were removed in v7.1.2. Overrides for that rule will be ignored. ↓
fix Remove any overrides for 'react/prop-types' from your ESLint config.
breaking Support for @typescript-eslint v6 and v7 added, but not v5. Ensure your project uses v6 or newer. ↓
fix Update @typescript-eslint/parser and @typescript-eslint/eslint-plugin to v6, v7, or v8.
gotcha Do not use literal package name in 'extends'. Use 'sanity', 'sanity/react', 'sanity/typescript'. ↓
fix Use 'sanity' instead of 'eslint-config-sanity'.
breaking Version 8 of eslint-config-sanity is not yet released; do not install future v8.x expecting compatibility with v7 API. ↓
fix Continue using v7 until official v8 migration guide is published.
Install
npm install eslint-config-sanity yarn add eslint-config-sanity pnpm add eslint-config-sanity Imports
- eslint-config-sanity wrong
extends: ['eslint-config-sanity']correctextends: ['sanity'] - eslint-config-sanity/react wrong
extends: ['sanity', 'sanity/react']correctextends: ['sanity/react'] - eslint-config-sanity/typescript wrong
extends: ['sanity', 'sanity/typescript']correctextends: ['sanity/typescript']
Quickstart
// .eslintrc.json
{
"env": { "browser": true, "es2021": true },
"extends": ["sanity"]
}
// package.json
{
"devDependencies": {
"eslint": "^9.0.0",
"eslint-config-sanity": "^7.1.4",
"eslint-plugin-import": "^2.28.1"
}
}