1
0
mirror of https://github.com/sasjs/lint.git synced 2026-01-08 21:10:05 +00:00

fix(trimComments): handle case special comment case

This commit is contained in:
Saad Jutt
2021-05-21 18:05:22 +05:00
parent f793eb3a76
commit d391a4e8fc
2 changed files with 17 additions and 5 deletions

View File

@@ -6,7 +6,9 @@ export const trimComments = (
let trimmed = trimEnd ? (statement || '').trimEnd() : (statement || '').trim()
if (commentStarted || trimmed.startsWith('/*')) {
const parts = trimmed.split('*/')
const parts = trimmed.startsWith('/*')
? trimmed.slice(2).split('*/')
: trimmed.split('*/')
if (parts.length === 2) {
return {
statement: (parts.pop() as string).trim(),
@@ -20,10 +22,8 @@ export const trimComments = (
}
} else if (trimmed.includes('/*')) {
const statementBeforeCommentStarts = trimmed.slice(0, trimmed.indexOf('/*'))
const remainingStatement = trimmed.slice(
trimmed.indexOf('*/') + 2,
trimmed.length
)
trimmed = trimmed.slice(trimmed.indexOf('/*') + 2)
const remainingStatement = trimmed.slice(trimmed.indexOf('*/') + 2)
const result = trimComments(remainingStatement, false, true)
const completeStatement = statementBeforeCommentStarts + result.statement