Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-m6web-i18n

Package Overview
Dependencies
Maintainers
7
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-m6web-i18n

eslint plugin for generic i18n

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
7
Created
Source

eslint-plugin-m6web-i18n

This is an eslint plugin for i18n in a react application.

Installation

yarn add -D eslint-plugin-m6web-i18n

Build

yarn build

Bump

To bump we use mvrsion.

example:

yarn mversion -- patch -m

Rules

  • i18n/no-unknown-key: Verify that all translation keys you use are present in your primary translation files.
  • i18n/no-unknown-key-secondary-langs: Same as the previous one. Allow you to have a different error level for secondary languages.
  • i18n/no-text-as-children: Verify that you have no text children in your react code.
  • i18n/interpolation-data: Checks for usage of keys containing string interpolation, if translate function is called without interpolation data it will show an error. Also if interpolation data is given and key doesn't contain interpolation it will also show an error. interpolationPattern option is required to match interpolation in your translation file.

Config

You have to add the following lines in your .eslintrc file to configure this plugin:

  // Declare the plugin
  "plugins": [
    "i18n"
  ],
  // Specify rules severity
  "rules": {
    "i18n/no-unknown-key": "error",
    "i18n/no-unknown-key-secondary-langs": "warn",
    "i18n/no-text-as-children": "error",
    "i18n/interpolation-data": ["error", { "interpolationPattern": "\\{\\.+\\}" }]
  },
  // The plugin needs jsx feature to be on for 'no-text-as-children' rule
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    }
  },
  // Settings of your translation
  "settings": {
    "i18n": {
      // Your principal languages used in 'no-unknown-key' rule
      "principalLangs": [
        {
          "name": "fr",
          "translationPath": "i18n/fr.json"
        }
      ],
      // Secondary languages used in 'no-unknown-key-secondary-langs' rule
      "secondaryLangs": [
        {
          "name": "en",
          "translationPath": "i18n/en.json"
        }
      ],
      // Name of your translate function
      "functionName": "t",
      // If you want to ignore specific files
      "ignoreFiles": "**/*.spec.js",
      // If you have pluralization
      "pluralizedKeys": ["one", "other"],
      // TTL of the translations file caching (defaults to 500ms)
      "translationsCacheTTL": 300
    }
  }

FAQs

Package last updated on 11 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc