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

intl-msgs-defaults

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intl-msgs-defaults

Automatically applies `defaultMessage` prop and property for `formatMessage({ id: "...", })` and `<FormattedMessage id="..." />` calls from a source file.

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

intl-msgs-defaults

Automatically applies defaultMessage prop and property for formatMessage({ id: "...", }) and <FormattedMessage id="..." /> calls from a source file.

Install

npm install --save-dev intl-msgs-defaults

Introduction

Consider this source code:

// someModule.js
import { FormattedMessage, intl } from "react-intl";

export const TestComponent = () => {
  return <FormattedMessage id="test.string" />;
};

export const TestFunc = () => {
  return intl.formatMessage({
    id: "test.string",
  });
};
// source.json
{
  "test.string": "I like being inserted!"
}

Running intl-msgs-defaults -s "./source.json" -t "someModule.js" will update someModule.js to the following:

// someModule.js
import { FormattedMessage, intl } from "react-intl";

export const TestComponent = () => {
  return (
    <FormattedMessage
      id="test.string"
      defaultMessage="I like being inserted!"
    />
  );
};

export const TestFunc = () => {
  return intl.formatMessage({
    id: "test.string",
    defaultMessage: "I like being inserted!",
  });
};

Usage Options

Usage: intl-msgs-defaults [options]

Options:
  -V, --version                 output the version number
  -s, --source <file>           .json file with the default messages
  -t, --target <glob>           glob pattern for target files
  -np, --no-prettify            do not prettify output
  -pc, --prettify-cfg <config>  custom prettier config file (defaults to auto-resolve near target files)
  -h, --help                    display help for command

Behaviour

  • When there already is a defaultMessage, it will not be overwritten
  • When no data for the key is found in the source file, no defaultMessage is added

FAQs

Package last updated on 20 Apr 2021

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