mirror of
https://github.com/sasjs/lint.git
synced 2026-01-07 12:40:05 +00:00
fix(strictMacroDefinition): updated logic for getting options
This commit is contained in:
@@ -37,6 +37,10 @@ describe('strictMacroDefinition', () => {
|
|||||||
|
|
||||||
const content11 = '`%macro macroName() /* / store source */;'
|
const content11 = '`%macro macroName() /* / store source */;'
|
||||||
expect(strictMacroDefinition.test(content11)).toEqual([])
|
expect(strictMacroDefinition.test(content11)).toEqual([])
|
||||||
|
|
||||||
|
const content12 =
|
||||||
|
'%macro macroName()/ /* some comment */ store des="some description";'
|
||||||
|
expect(strictMacroDefinition.test(content12)).toEqual([])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return an array with a single diagnostic when Macro definition has space in param', () => {
|
it('should return an array with a single diagnostic when Macro definition has space in param', () => {
|
||||||
|
|||||||
@@ -101,9 +101,23 @@ const test = (value: string, config?: LintConfig) => {
|
|||||||
_declaration = declaration.split(`(${paramsPresent})`)[1]
|
_declaration = declaration.split(`(${paramsPresent})`)[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
const optionsPresent = _declaration.split('/')?.[1]?.trim().split(' ')
|
let optionsPresent = _declaration.split('/')?.[1]?.trim()
|
||||||
|
|
||||||
|
if (optionsPresent) {
|
||||||
|
const regex = new RegExp(/="(.*?)"/, 'g')
|
||||||
|
|
||||||
|
let result = regex.exec(optionsPresent)
|
||||||
|
|
||||||
|
while (result) {
|
||||||
|
optionsPresent =
|
||||||
|
optionsPresent.slice(0, result.index) +
|
||||||
|
optionsPresent.slice(result.index + result[0].length)
|
||||||
|
|
||||||
|
result = regex.exec(optionsPresent)
|
||||||
|
}
|
||||||
|
|
||||||
optionsPresent
|
optionsPresent
|
||||||
|
.split(' ')
|
||||||
?.filter((o) => !!o)
|
?.filter((o) => !!o)
|
||||||
.forEach((option) => {
|
.forEach((option) => {
|
||||||
const trimmedOption = option.trim()
|
const trimmedOption = option.trim()
|
||||||
@@ -123,6 +137,7 @@ const test = (value: string, config?: LintConfig) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return diagnostics
|
return diagnostics
|
||||||
|
|||||||
Reference in New Issue
Block a user