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