1
0
mirror of https://github.com/sasjs/lint.git synced 2025-12-11 01:44:36 +00:00

fix(hasMacroParentheses): added additional test also

This commit is contained in:
Saad Jutt
2021-04-21 16:44:20 +05:00
parent db2dbb1c69
commit cd90b0850a
2 changed files with 19 additions and 2 deletions

View File

@@ -44,6 +44,21 @@ describe('hasMacroParentheses', () => {
])
})
it('should return an array with a single diagnostic when macro defined without name ( single line code )', () => {
const content = `
%macro (); %put &sysmacroname; %mend;`
expect(hasMacroParentheses.test(content)).toEqual([
{
message: 'Macro definition missing name',
lineNumber: 2,
startColumnNumber: 3,
endColumnNumber: 12,
severity: Severity.Warning
}
])
})
it('should return an array with a single diagnostic when macro defined without name and parentheses', () => {
const content = `
%macro ;
@@ -55,7 +70,7 @@ describe('hasMacroParentheses', () => {
message: 'Macro definition missing name',
lineNumber: 2,
startColumnNumber: 3,
endColumnNumber: 10,
endColumnNumber: 9,
severity: Severity.Warning
}
])

View File

@@ -18,7 +18,9 @@ const test = (value: string, config?: LintConfig) => {
message: 'Macro definition missing name',
lineNumber: macro.startLineNumber!,
startColumnNumber: getColumnNumber(macro.declaration, '%macro'),
endColumnNumber: macro.declaration.length,
endColumnNumber:
getColumnNumber(macro.declaration, '%macro') +
macro.declarationTrimmedStatement.length,
severity: Severity.Warning
})
} else if (!macro.declaration.includes('(')) {