1
0
mirror of https://github.com/sasjs/lint.git synced 2026-01-13 15:20:05 +00:00

feat: new rules noNestedMacros & hasMacroParentheses

This commit is contained in:
Saad Jutt
2021-04-06 19:45:42 +05:00
parent 3970f05dc9
commit 3530badf49
12 changed files with 221 additions and 38 deletions

19
src/utils/trimComments.ts Normal file
View File

@@ -0,0 +1,19 @@
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 > 1) {
return {
statement: (parts.pop() as string).trim(),
commentStarted: false
}
} else {
return { statement: '', commentStarted: true }
}
}
return { statement: trimmed, commentStarted: false }
}