-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add options to allow HTML entities and/or punctuation to be excluded …
…from translation check (#139)
- Loading branch information
Showing
8 changed files
with
212 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
test/rules/jsx-use-translation-function/allow-htmlentities/tslint.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"rules": { | ||
"jsx-use-translation-function": { | ||
"options": ["allow-htmlentities"] | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
test/rules/jsx-use-translation-function/allow-punctuation/test.tsx.lint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<div>Hello world!</div> | ||
~~~~~~~~~~~~ [0] | ||
|
||
<div>{'Hello world!'}</div> | ||
~~~~~~~~~~~~~~~~ [0] | ||
|
||
<div>{translate('hello-world')}</div> | ||
|
||
<input placeholder={translate('name')} /> | ||
<input placeholder="Name" /> | ||
~~~~~~ [1] | ||
|
||
<input placeholder={translate('name')} /> | ||
<input placeholder={"Name"} /> | ||
~~~~~~~~ [1] | ||
|
||
<div> | ||
<div>{translate('hi')}</div> | ||
</div> | ||
|
||
<div> | ||
<span>{translate('this')}</span>is bad<span> | ||
~~~~~~ [0] | ||
</div> | ||
|
||
<div>{`foo`}</div> | ||
~~~~~~~ [0] | ||
|
||
<div>{`foo ${1}`}</div> | ||
|
||
<ul> | ||
<li>{translate('one')}</li> | ||
Two | ||
~~~ | ||
<li>Three</li> | ||
~~~~ [0] | ||
~~~~~ [0] | ||
</ul> | ||
|
||
<div> - </div> | ||
|
||
<div>{' - '}</div> | ||
|
||
<input placeholder="-" /> | ||
|
||
<div> </div> | ||
~~~~~~ [0] | ||
|
||
<div>{' '}</div> | ||
~~~~~~~~~~ [0] | ||
|
||
<input placeholder=" " /> | ||
~~~~~~~~ [1] | ||
|
||
[0]: String literals are disallowed as JSX. Use a translation function | ||
[1]: String literal is not allowed for value of placeholder. Use a translation function |
7 changes: 7 additions & 0 deletions
7
test/rules/jsx-use-translation-function/allow-punctuation/tslint.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"rules": { | ||
"jsx-use-translation-function": { | ||
"options": ["allow-punctuation"] | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
test/rules/jsx-use-translation-function/default/test.tsx.lint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<div>Hello world!</div> | ||
~~~~~~~~~~~~ [0] | ||
|
||
<div>{'Hello world!'}</div> | ||
~~~~~~~~~~~~~~~~ [0] | ||
|
||
<div>{translate('hello-world')}</div> | ||
|
||
<input placeholder={translate('name')} /> | ||
<input placeholder="Name" /> | ||
~~~~~~ [1] | ||
|
||
<input placeholder={translate('name')} /> | ||
<input placeholder={"Name"} /> | ||
~~~~~~~~ [1] | ||
|
||
<div> | ||
<div>{translate('hi')}</div> | ||
</div> | ||
|
||
<div> | ||
<span>{translate('this')}</span>is bad<span> | ||
~~~~~~ [0] | ||
</div> | ||
|
||
<div>{`foo`}</div> | ||
~~~~~~~ [0] | ||
|
||
<div>{`foo ${1}`}</div> | ||
|
||
<ul> | ||
<li>{translate('one')}</li> | ||
Two | ||
~~~ | ||
<li>Three</li> | ||
~~~~ [0] | ||
~~~~~ [0] | ||
</ul> | ||
|
||
<div> - </div> | ||
~~ [0] | ||
|
||
<div>{' - '}</div> | ||
~~~~~~~ [0] | ||
|
||
<input placeholder="-" /> | ||
~~~ [1] | ||
|
||
<div> </div> | ||
~~~~~~ [0] | ||
|
||
<div>{' '}</div> | ||
~~~~~~~~~~ [0] | ||
|
||
<input placeholder=" " /> | ||
~~~~~~~~ [1] | ||
|
||
[0]: String literals are disallowed as JSX. Use a translation function | ||
[1]: String literal is not allowed for value of placeholder. Use a translation function |
File renamed without changes.