Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

eslint-config-sanity

sanity-io37.2kMIT7.1.4

Shared eslint configs for sanity-io

sanity, cms, headless, realtime, content, eslint-config-sanity, eslint, eslintconfig

readme

eslint-config-sanity

Shared eslint rules for official Sanity.io projects

Installing

npm install --save-dev eslint-config-sanity

Usage

Create an .eslintrc in the root of your project (or an eslintConfig entry in package.json) and extend the sanity config:

{
  "env": {"node": true, "browser": true},
  "extends": ["sanity"]
}

Adjust env according to your use case, obviously.

Usage: React

ESLint requires plugins to be peer dependencies (they resolve relative to the end-user project), as such you need to install an additional dependency if you're using React:

npm install --save-dev eslint-plugin-react eslint-plugin-react-hooks

Then, make sure to extend sanity/react in your .eslintrc:

{
  "extends": ["sanity/react"]
}

Note: It's not necessary to extend both sanity and sanity/react - extending sanity/react will implicitly extend sanity first.

Note: If you're using TypeScript and React, make sure you extend sanity/react before sanity/typescript:

{
  "extends": ["sanity/react", "sanity/typescript"]
}

Usage: Typescript

ESLint requires plugins to be peer dependencies (they resolve relative to the end-user project), as such you need to install a few more dependencies if you're using typescript:

npm install --save-dev \
  typescript \
  @typescript-eslint/parser \
  @typescript-eslint/eslint-plugin

Then, make sure to extend sanity/typescript in your .eslintrc:

{
  "extends": ["sanity/typescript"]
}

Note: It's not necessary to extend both sanity and sanity/typescript - extending sanity/typescript will implicitly extend sanity first.

Note: If you're using TypeScript and React, make sure you extend sanity/react before sanity/typescript:

{
  "extends": ["sanity/react", "sanity/typescript"]
}

License

MIT © Sanity.io

changelog

Changelog

7.1.4 (2025-01-20)

Bug Fixes

7.1.3 (2024-10-14)

Bug Fixes

7.1.2 (2024-03-18)

Bug Fixes

  • remove react/prop-types rule (89b18d4)

7.1.1 (2024-02-27)

Bug Fixes

  • better typescript defaults (b3f47c4)

7.1.0 (2024-02-26)

Features

  • add support for react hooks (7a3034f)

Bug Fixes

  • add support for simple-import-sort (30b6b50)

7.0.3 (2024-02-26)

Bug Fixes

  • remove deprecated rules (5b4477a)
  • remove more deprecated rules (bd823f4)

7.0.2 (2024-02-21)

Bug Fixes

7.0.1 (2023-10-10)

Bug Fixes

7.0.0 (2023-10-10)

⚠ BREAKING CHANGES

  • extend recommended defaults (#53)

Features

Bug Fixes