Skip to content

An ESLint configuration to help with localizing Sanity Studios

License

Notifications You must be signed in to change notification settings

sanity-io/eslint-config-i18n

Repository files navigation

@sanity/eslint-config-i18n

An ESLint configuration to help with localizing Sanity Studios.

This ESLint config provides rules to enforce specific code standards in internationalization practices, particularly focusing on strings literals in JSX. It aims to improve code quality and maintainability in projects with internationalization concerns.

This package utilizes @rushstack/eslint-patch to include plugins as dependencies. This making installation easier and allows us to manage those dependencies for you.

Depends on:

Installation

Install

yarn add eslint @sanity/eslint-config-i18n --dev

or

npm install eslint @sanity/eslint-config-i18n --save-dev

Update the configuration

Update your .eslintrc to include "@sanity/eslint-config-i18n"

{
  "extends": [
    "@sanity/eslint-config-studio",
    "@sanity/eslint-config-i18n"
  ]
}

Optionally: If you wish to configure @sanity/eslint-plugin-i18n:

{
  "extends": ["@sanity/eslint-config-studio", "@sanity/eslint-config-i18n"],
  "rules": {
    "@sanity/i18n/no-attribute-string-literals": [
      "error",
      // See https://github.com/sanity-io/eslint-plugin-i18n#rule-options
      {
        "ignores": {},
        "only": {},
        "mode": "extend"
      }
    ],
    "@sanity/i18n/no-attribute-template-literals": [
      "error",
      // See https://github.com/sanity-io/eslint-plugin-i18n#rule-options
      {
        "ignores": {},
        "only": {},
        "mode": "extend"
      }
    ]
  },
  "overrides": [
    // turn off these rules for your tests
    {
      "files": [
        "**/*/test/**/*",
        "**/*/__tests__/**/*",
        "**/*.test.{js,ts,tsx}"
      ],
      "rules": {
        "i18next/no-literal-string": "off",
        "@sanity/i18n/no-attribute-string-literals": "off",
        "@sanity/i18n/no-attribute-template-literals": "off"
      }
    }
  ]
}

Release new version

Run "CI & Release" workflow. Make sure to select the main branch and check "Release new version".

Semantic release will only release on configured branches, so it is safe to run release on any branch.

About

An ESLint configuration to help with localizing Sanity Studios

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •