Open GaryGiebler opened 1 year ago
Hi, thx for your issue, I'll try add it later, no time at all, or if u have enough time, please, make PR.
I tried to post the code in another branch to create a PR but it gave me permissions issues so I just posted the solution here.
If you set ignoreComments true, the app can skip entire sections of code and report translations unused which are actually used.
A single line comment using / and / will cause the app to skip every line of code up to the next comment.
The following is only true if the line begins with '*/' - the '^' character causes the statement to match the beginning of the line:
const isEndOfMultilineComment = (str: string): boolean => /^(*\/)/.test(str);
Even if you remove the '^' so the app catches the end of comments using '*/' it still skips code after single line comments.
This code in translations.ts sets skip true and skips subsequent lines of code:
The same statement causes the app to include the line containing '/*' in the case of multiline comments.
To fix these errors:
Remove the '^' in the isEndOfMultilineComment statement: const isEndOfMultilineComment = (str: string): boolean => /(*\/)/.test(str);
Add the following statement to handle single line comments before the above statement: if (isStartOfMultilineComment(_str) && isEndOfMultilineComment(_str)) { skip = false; return acc; }
Modify this statement to exclude the line with the end of a multiline comment '*/' : if (skip || isInlineComment(_str) || isHTMLComment(_str)) {
to be: if (skip || isInlineComment(_str) || isHTMLComment(_str) || isEndOfMultilineComment(_str)) {