Ensures that $localize tagged messages contain helpful metadata to aid with translations.
- Type: suggestion
The rule accepts an options object with the following properties:
interface Options {
requireDescription?: boolean;
requireMeaning?: boolean;
}
The following examples are generated automatically from the actual unit tests within the plugin, so you can be assured that their behavior is accurate based on the current commit.
❌ - Toggle examples of incorrect code for this rule
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error",
{
"requireDescription": true
}
]
}
}
const localizedText = $localize`Hello i18n!`;
~~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error",
{
"requireDescription": true
}
]
}
}
const localizedTexts = {
helloI18n: $localize`:An introduction header for this sample:Hello i18n!`
};
localizedTexts.helloI18n = $localize`Hello i18n!`;
~~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error",
{
"requireDescription": true
}
]
}
}
return $localize`Hello i18n!`;
~~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error",
{
"requireDescription": true
}
]
}
}
someFunction($localize`Hello i18n!`);
~~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error",
{
"requireDescription": true
}
]
}
}
const localizedText = $localize`:site header|:Hello i18n!`;
~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error",
{
"requireDescription": true
}
]
}
}
const localizedText = $localize`:@@custom_id:Hello i18n!`;
~~~~~~~~~~~~~~~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error",
{
"requireDescription": true
}
]
}
}
const localizedText = $localize`:site header|@@custom_id:Hello i18n!`;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error",
{
"requireMeaning": true
}
]
}
}
const localizedText = $localize`Hello i18n!`;
~~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error",
{
"requireDescription": true,
"requireMeaning": true
}
]
}
}
const localizedText = $localize`:An introduction header for this sample:Hello i18n!`;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error",
{
"requireMeaning": true
}
]
}
}
const localizedText = $localize`:|An introduction header for this sample:Hello i18n!`;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error",
{
"requireDescription": true,
"requireMeaning": true
}
]
}
}
const localizedText = $localize`:Hello i18n!`;
~~~~~~~~~~~~~~
✅ - Toggle examples of correct code for this rule
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error"
]
}
}
const localizedText = $localize`Hello i18n!`;
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error"
]
}
}
const localizedText = $localize`:site header|:Hello i18n!`;
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error"
]
}
}
const localizedText = $localize`:@@custom_id:Hello i18n!`;
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error"
]
}
}
const localizedText = $localize`:site header|@@custom_id:Hello i18n!`;
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error",
{
"requireDescription": true
}
]
}
}
let localizedText = $localize\`:An introduction header for this sample:Hello i18n!\`;
localizedText = $localize\`:An introduction header for this sample modified:Hello i18n modified!\`;
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error",
{
"requireDescription": true
}
]
}
}
const localizedTexts = {
helloI18n: $localize\`:An introduction header for this sample:Hello i18n!\`
};
localizedTexts.helloI18n = $localize\`:An introduction header for this sample modified:Hello i18n modified!\`;
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error",
{
"requireDescription": true
}
]
}
}
return $localize\`:An introduction header for this sample:Hello i18n!\`;
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error",
{
"requireDescription": true
}
]
}
}
someFunction($localize\`:An introduction header for this sample:Hello i18n!\`);
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error",
{
"requireDescription": true
}
]
}
}
const localizedText = \`Hello i18n!\`;
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error",
{
"requireMeaning": true
}
]
}
}
const localizedText = $localize\`:site header|:Hello i18n!\`;
{
"rules": {
"@angular-eslint/require-localize-metadata": [
"error",
{
"requireDescription": true,
"requireMeaning": true
}
]
}
}
const localizedText = $localize\`:site header|An introduction header for this sample:Hello i18n!\`;