mirror of
https://github.com/sasjs/lint.git
synced 2025-12-10 17:34:36 +00:00
23 lines
645 B
TypeScript
23 lines
645 B
TypeScript
export const trimComments = (
|
|
statement: string,
|
|
commentStarted: boolean = false
|
|
): { statement: string; commentStarted: boolean } => {
|
|
let trimmed = (statement || '').trim()
|
|
|
|
if (commentStarted || trimmed.startsWith('/*')) {
|
|
const parts = trimmed.split('*/')
|
|
if (parts.length === 2) {
|
|
return {
|
|
statement: (parts.pop() as string).trim(),
|
|
commentStarted: false
|
|
}
|
|
} else if (parts.length > 2) {
|
|
parts.shift()
|
|
return trimComments(parts.join('*/'), false)
|
|
} else {
|
|
return { statement: '', commentStarted: true }
|
|
}
|
|
}
|
|
return { statement: trimmed, commentStarted: false }
|
|
}
|