mirror of
https://github.com/sasjs/lint.git
synced 2025-12-10 17:34:36 +00:00
chore(*): rename macro properties
This commit is contained in:
@@ -24,8 +24,7 @@ const test = (value: string, config?: LintConfig) => {
|
||||
lineNumber: macro.endLineNumber,
|
||||
startColumnNumber: getColumnNumber(endLine, '%mend'),
|
||||
endColumnNumber:
|
||||
getColumnNumber(endLine, '%mend') +
|
||||
macro.terminationTrimmedStatement.length,
|
||||
getColumnNumber(endLine, '%mend') + macro.termination.length,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
} else if (macro.endLineNumber === null && macro.startLineNumber !== null) {
|
||||
@@ -79,8 +78,7 @@ const fix = (value: string, config?: LintConfig): string => {
|
||||
const endLine = lines[macro.endLineNumber - 1]
|
||||
const startColumnNumber = getColumnNumber(endLine, '%mend')
|
||||
const endColumnNumber =
|
||||
getColumnNumber(endLine, '%mend') +
|
||||
macro.terminationTrimmedStatement.length
|
||||
getColumnNumber(endLine, '%mend') + macro.termination.length
|
||||
|
||||
const beforeStatement = endLine.slice(0, startColumnNumber - 1)
|
||||
const afterStatement = endLine.slice(endColumnNumber)
|
||||
|
||||
@@ -17,19 +17,19 @@ const test = (value: string, config?: LintConfig) => {
|
||||
diagnostics.push({
|
||||
message: 'Macro definition missing name',
|
||||
lineNumber: macro.startLineNumber!,
|
||||
startColumnNumber: getColumnNumber(macro.declaration, '%macro'),
|
||||
startColumnNumber: getColumnNumber(macro.declarationLine, '%macro'),
|
||||
endColumnNumber:
|
||||
getColumnNumber(macro.declaration, '%macro') +
|
||||
macro.declarationTrimmedStatement.length,
|
||||
getColumnNumber(macro.declarationLine, '%macro') +
|
||||
macro.declaration.length,
|
||||
severity: Severity.Warning
|
||||
})
|
||||
} else if (!macro.declaration.includes('(')) {
|
||||
} else if (!macro.declarationLine.includes('(')) {
|
||||
diagnostics.push({
|
||||
message,
|
||||
lineNumber: macro.startLineNumber!,
|
||||
startColumnNumber: getColumnNumber(macro.declaration, macro.name),
|
||||
startColumnNumber: getColumnNumber(macro.declarationLine, macro.name),
|
||||
endColumnNumber:
|
||||
getColumnNumber(macro.declaration, macro.name) +
|
||||
getColumnNumber(macro.declarationLine, macro.name) +
|
||||
macro.name.length -
|
||||
1,
|
||||
severity: Severity.Warning
|
||||
@@ -38,9 +38,9 @@ const test = (value: string, config?: LintConfig) => {
|
||||
diagnostics.push({
|
||||
message: 'Macro definition contains space(s)',
|
||||
lineNumber: macro.startLineNumber!,
|
||||
startColumnNumber: getColumnNumber(macro.declaration, macro.name),
|
||||
startColumnNumber: getColumnNumber(macro.declarationLine, macro.name),
|
||||
endColumnNumber:
|
||||
getColumnNumber(macro.declaration, macro.name) +
|
||||
getColumnNumber(macro.declarationLine, macro.name) +
|
||||
macro.name.length -
|
||||
1 +
|
||||
`()`.length,
|
||||
|
||||
@@ -12,10 +12,10 @@ describe('parseMacros', () => {
|
||||
expect(macros.length).toEqual(1)
|
||||
expect(macros).toContainEqual({
|
||||
name: 'test',
|
||||
declaration: '%macro test;',
|
||||
declarationLine: '%macro test;',
|
||||
terminationLine: '%mend',
|
||||
declaration: '%macro test',
|
||||
termination: '%mend',
|
||||
declarationTrimmedStatement: '%macro test',
|
||||
terminationTrimmedStatement: '%mend',
|
||||
startLineNumber: 1,
|
||||
endLineNumber: 3,
|
||||
parentMacro: '',
|
||||
@@ -38,10 +38,10 @@ describe('parseMacros', () => {
|
||||
expect(macros.length).toEqual(2)
|
||||
expect(macros).toContainEqual({
|
||||
name: 'foo',
|
||||
declaration: '%macro foo;',
|
||||
termination: '%mend;',
|
||||
declarationTrimmedStatement: '%macro foo',
|
||||
terminationTrimmedStatement: '%mend',
|
||||
declarationLine: '%macro foo;',
|
||||
terminationLine: '%mend;',
|
||||
declaration: '%macro foo',
|
||||
termination: '%mend',
|
||||
startLineNumber: 1,
|
||||
endLineNumber: 3,
|
||||
parentMacro: '',
|
||||
@@ -51,10 +51,10 @@ describe('parseMacros', () => {
|
||||
})
|
||||
expect(macros).toContainEqual({
|
||||
name: 'bar',
|
||||
declaration: '%macro bar();',
|
||||
termination: '%mend bar;',
|
||||
declarationTrimmedStatement: '%macro bar()',
|
||||
terminationTrimmedStatement: '%mend bar',
|
||||
declarationLine: '%macro bar();',
|
||||
terminationLine: '%mend bar;',
|
||||
declaration: '%macro bar()',
|
||||
termination: '%mend bar',
|
||||
startLineNumber: 4,
|
||||
endLineNumber: 6,
|
||||
parentMacro: '',
|
||||
@@ -77,10 +77,10 @@ describe('parseMacros', () => {
|
||||
expect(macros.length).toEqual(2)
|
||||
expect(macros).toContainEqual({
|
||||
name: 'test',
|
||||
declarationLine: '%macro test()',
|
||||
terminationLine: '%mend test',
|
||||
declaration: '%macro test()',
|
||||
termination: '%mend test',
|
||||
declarationTrimmedStatement: '%macro test()',
|
||||
terminationTrimmedStatement: '%mend test',
|
||||
startLineNumber: 1,
|
||||
endLineNumber: 6,
|
||||
parentMacro: '',
|
||||
@@ -90,10 +90,10 @@ describe('parseMacros', () => {
|
||||
})
|
||||
expect(macros).toContainEqual({
|
||||
name: 'test2',
|
||||
declaration: ' %macro test2',
|
||||
termination: ' %mend',
|
||||
declarationTrimmedStatement: '%macro test2',
|
||||
terminationTrimmedStatement: '%mend',
|
||||
declarationLine: ' %macro test2',
|
||||
terminationLine: ' %mend',
|
||||
declaration: '%macro test2',
|
||||
termination: '%mend',
|
||||
startLineNumber: 3,
|
||||
endLineNumber: 5,
|
||||
parentMacro: 'test',
|
||||
|
||||
@@ -6,10 +6,10 @@ interface Macro {
|
||||
name: string
|
||||
startLineNumber: number | null
|
||||
endLineNumber: number | null
|
||||
declarationLine: string
|
||||
terminationLine: string
|
||||
declaration: string
|
||||
termination: string
|
||||
declarationTrimmedStatement: string
|
||||
terminationTrimmedStatement: string
|
||||
parentMacro: string
|
||||
hasMacroNameInMend: boolean
|
||||
hasParentheses: boolean
|
||||
@@ -54,10 +54,10 @@ export const parseMacros = (text: string, config?: LintConfig): Macro[] => {
|
||||
hasParentheses: trimmedStatement.endsWith('()'),
|
||||
hasMacroNameInMend: false,
|
||||
mismatchedMendMacroName: '',
|
||||
declaration: line,
|
||||
termination: '',
|
||||
declarationTrimmedStatement: trimmedStatement,
|
||||
terminationTrimmedStatement: ''
|
||||
declarationLine: line,
|
||||
terminationLine: '',
|
||||
declaration: trimmedStatement,
|
||||
termination: ''
|
||||
})
|
||||
} else if (trimmedStatement.startsWith('%mend')) {
|
||||
if (macroStack.length) {
|
||||
@@ -69,8 +69,8 @@ export const parseMacros = (text: string, config?: LintConfig): Macro[] => {
|
||||
macro.mismatchedMendMacroName = macro.hasMacroNameInMend
|
||||
? ''
|
||||
: mendMacroName
|
||||
macro.termination = line
|
||||
macro.terminationTrimmedStatement = trimmedStatement
|
||||
macro.terminationLine = line
|
||||
macro.termination = trimmedStatement
|
||||
macros.push(macro)
|
||||
} else {
|
||||
macros.push({
|
||||
@@ -81,10 +81,10 @@ export const parseMacros = (text: string, config?: LintConfig): Macro[] => {
|
||||
hasParentheses: false,
|
||||
hasMacroNameInMend: false,
|
||||
mismatchedMendMacroName: '',
|
||||
declarationLine: '',
|
||||
terminationLine: line,
|
||||
declaration: '',
|
||||
termination: line,
|
||||
declarationTrimmedStatement: '',
|
||||
terminationTrimmedStatement: trimmedStatement
|
||||
termination: trimmedStatement
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user