Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(no-unlocalized-strings): ignore more cases #84

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

timofei-iatsenko
Copy link
Collaborator

  • ignore when there is no text, and only variables
  • apply ignore option to the JSX Text
  • improve default Regexp in the documentation

Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.49%. Comparing base (f10feb9) to head (2fc684c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #84   +/-   ##
=======================================
  Coverage   96.49%   96.49%           
=======================================
  Files          10       10           
  Lines         371      371           
  Branches      101      101           
=======================================
  Hits          358      358           
  Misses         13       13           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@ptmkenny
Copy link

These additions look good. I upgraded from 0.7 to 0.8 and used the recommended ignores in the docs plus the ignores I was already using with 0.7. In 0.7, I had no errors, but with the new configuration, several things that used to be ignored were now being flagged (in my app's case, incorrectly).

Since I just did this conversion, I made a list of the types of things I had to add additional ignores for. Here it is for reference.

Not an error in 0.7 but is an error in 0.8 with the recommended configuration

Strings that consist of variables and functions and spaces (prettier formatted it to look like this):

        errorMessage += ` ${firstError.message.toString()} ${JSON.stringify(firstError.params)}`;

Properties of variables like {selectOption.text}` here:

              {selectionOptions.map((selectOption) => (
                <IonSelectOption
                  value={selectOption.value}
                  key={selectOption.value}
                >
                  {selectOption.text}
                </IonSelectOption>
              ))}

Numbers that include percentages like 100% and 225%.

The whitespace in this:

              {/* Add a space between the toggle and the count. */ ' '}

Variables with punctuation (perhaps this should be flagged, even though it wasn't before):

  return <>{countDisplayLimit}+</>;

@timofei-iatsenko
Copy link
Collaborator Author

@ptmkenny thanks for your input. I also updated the plugin in my project and found some new strings flagged. Actually it is not always clear and straightforward what should be flagged and what's not.

return <>{countDisplayLimit}+</>;

For example this one should fall into "non word string" category, and should not be flagged. This is done to avoid thousands of strings for css and similar, such as height: "100%"

Next:

        errorMessage += ` ${firstError.message.toString()} ${JSON.stringify(firstError.params)}`;

This one for example also could be intuitive to be flagged for one and counterintuitive for others. Because there is something between variables to translates. Even order of variables placeholders might be a subject for translation. But i agree that in most of cases you rather want this one to be not flagged.

I will go throw your cases and will update this PR if I found this required.

@timofei-iatsenko timofei-iatsenko marked this pull request as draft November 24, 2024 09:54
- ignore when there is no text, and only variables
- apply `ignore` option to the JSX Text
- improve default Regexp in the documentation
@timofei-iatsenko
Copy link
Collaborator Author

@ptmkenny I tested every case you submitted, they all covered with changes from this PR. I added explicit test cases to the suite for them.

Note:

return <>{countDisplayLimit}+</>;

Still will not be flagged, as I mentioned above.

@ptmkenny
Copy link

Thank you, that's great!

@timofei-iatsenko timofei-iatsenko marked this pull request as ready for review November 25, 2024 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants