mirror of
https://github.com/sasjs/lint.git
synced 2026-01-18 17:50:05 +00:00
fix: comments within/outside the statement
This commit is contained in:
@@ -7,6 +7,15 @@ describe('trimComments', () => {
|
|||||||
/* some comment */ some code;
|
/* some comment */ some code;
|
||||||
`)
|
`)
|
||||||
).toEqual({ statement: 'some code;', commentStarted: false })
|
).toEqual({ statement: 'some code;', commentStarted: false })
|
||||||
|
|
||||||
|
expect(
|
||||||
|
trimComments(`/* some comment */
|
||||||
|
/* some comment */ CODE_Keyword1 /* some comment */ CODE_Keyword2/* some comment */;/* some comment */
|
||||||
|
/* some comment */`)
|
||||||
|
).toEqual({
|
||||||
|
statement: 'CODE_Keyword1 CODE_Keyword2;',
|
||||||
|
commentStarted: false
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return statment, having multi-line comment', () => {
|
it('should return statment, having multi-line comment', () => {
|
||||||
|
|||||||
@@ -17,6 +17,18 @@ export const trimComments = (
|
|||||||
} else {
|
} else {
|
||||||
return { statement: '', commentStarted: true }
|
return { statement: '', commentStarted: true }
|
||||||
}
|
}
|
||||||
|
} else if (trimmed.includes('/*')) {
|
||||||
|
const statementBeforeCommentStarts = trimmed.slice(0, trimmed.indexOf('/*'))
|
||||||
|
const remainingStatement = trimmed.slice(
|
||||||
|
trimmed.indexOf('/*'),
|
||||||
|
trimmed.length
|
||||||
|
)
|
||||||
|
|
||||||
|
const result = trimComments(remainingStatement, false)
|
||||||
|
return {
|
||||||
|
statement: statementBeforeCommentStarts + result.statement,
|
||||||
|
commentStarted: result.commentStarted
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return { statement: trimmed, commentStarted: false }
|
return { statement: trimmed, commentStarted: false }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user