mirror of
https://github.com/sasjs/lint.git
synced 2025-12-11 01:44:36 +00:00
fix(strictMacroDefinition): updated logic for getting params
This commit is contained in:
@@ -114,6 +114,11 @@ describe('strictMacroDefinition', () => {
|
||||
})
|
||||
|
||||
describe('multi-content macro declarations', () => {
|
||||
it('should return an empty array when the content has correct macro definition syntax', () => {
|
||||
const content = `%macro mp_ds2cards(base_ds=, tgt_ds=\n ,cards_file="%sysfunc(pathname(work))/cardgen.sas"\n ,maxobs=max\n ,random_sample=NO\n ,showlog=YES\n ,outencoding=\n ,append=NO\n)/*/STORE SOURCE*/;`
|
||||
expect(strictMacroDefinition.test(content)).toEqual([])
|
||||
})
|
||||
|
||||
it('should return an array with a single diagnostic when Macro definition has space in param', () => {
|
||||
const content = `%macro
|
||||
somemacro(va r1);`
|
||||
|
||||
@@ -32,12 +32,12 @@ const test = (value: string, config?: LintConfig) => {
|
||||
macros.forEach((macro) => {
|
||||
const declaration = macro.declaration
|
||||
|
||||
const regExpParams = new RegExp(/\((.*?)\)/)
|
||||
const regExpParams = new RegExp(/(?<=\().*(?=\))/)
|
||||
const regExpParamsResult = regExpParams.exec(declaration)
|
||||
|
||||
let _declaration = declaration
|
||||
if (regExpParamsResult) {
|
||||
const paramsPresent = regExpParamsResult[1]
|
||||
const paramsPresent = regExpParamsResult[0]
|
||||
|
||||
const paramsTrimmed = paramsPresent.trim()
|
||||
const params = paramsTrimmed.split(',')
|
||||
|
||||
Reference in New Issue
Block a user