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 debug warning in case of trailing comma in function #97

Merged
merged 1 commit into from
Sep 28, 2018

Conversation

garthenweb
Copy link
Contributor

When using trailing comma in a function within the t function the scanner throws an error because an empty string is passed to the esprima parser.

This PR includes a test case as well as the fix. Please let me know if you have a better idea on how to fix it or how to implement the test case.

The script is still working as expected without the fix, because the error is catched, but the it logs an error in debug mode which is first annoying and second reduces trust into the library.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 90.87% when pulling 4770abf on garthenweb:bugfix/trailing-comma into 41165bb on i18next:master.

@TylerK
Copy link

TylerK commented Sep 6, 2018

@garthenweb Great find, I'm having this exact issue right now with our application. Prettier will format long strings as function params as such:

Before Prettier formatting:

const longString = t('lorem ipsum...');

After Prettier formatting:

const longString = t(
  'lorem ipsum...',
);

@garthenweb
Copy link
Contributor Author

@TylerK Happy to hear that it's helpful!
@cheton Any objections on this?

@cheton cheton merged commit 0147560 into i18next:master Sep 28, 2018
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.

4 participants