Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Latest commit

 

History

History
53 lines (33 loc) · 1.01 KB

only-string-literal-argument.md

File metadata and controls

53 lines (33 loc) · 1.01 KB

only-string-literal-argument

Enforce using static strings as keys for localize functions which we use for translation

Rule Details

Examples of incorrect code for this rule:

localize(key);

localize(`some translation literal : ${key}`);

localize(some_new_variable + 'invalid use')

localize(some_new_variable + 'invalid use' + some_variable)

localize(`this is not allowed`);

localize('this is some text {{placeholder}}', {
  placeholder: 'some text here',
  extra_arg: 'this is not usable'
});

localize('this is some text {{ placeholder }}')

localize('this is some text {{placeholder}}', {
  irrelavant_prop: 'this is not usable'
})

localize('this is some text {{placeholder}}', 'second argument')

localize('this is some text {{placeholder}}', 'second argument', 'this is third')

Examples of correct code for this rule:

localize("key");

localize(also_a_valid_use);

localize('this is some {{placeholder}} text {{placeholder}}', {
  placeholder: 'some text here'
})

Options

...