-
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.
Fixes for translation lint where punctuation and HTML entities are si…
…de by side (#142) This case came up running lint across our larger code base, where strings like "{var1}: {var2}" were incorrectly flagged when both punctuation and HTML entities were allowed.
- Loading branch information
Showing
5 changed files
with
110 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
66 changes: 66 additions & 0 deletions
66
test/rules/jsx-use-translation-function/allow-both/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,66 @@ | ||
<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> | ||
|
||
<div>: </div> | ||
|
||
<div>: </div> | ||
~~~~~~ [0] | ||
|
||
<div>{' - '}</div> | ||
|
||
<input placeholder="-" /> | ||
|
||
<div> </div> | ||
|
||
<div>{' '}</div> | ||
|
||
<input placeholder=" " /> | ||
|
||
<div>hello - world</div> | ||
~~~~~~~~~~~~~ [0] | ||
|
||
<div>hello world</div> | ||
~~~~~~~~~~~~~~~~ [0] | ||
|
||
[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-both/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", "allow-htmlentities"] | ||
} | ||
} | ||
} |
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