mirror of
https://github.com/sasjs/lint.git
synced 2026-01-07 04:30:05 +00:00
chore: Code Refactor
This commit is contained in:
@@ -1,20 +1,7 @@
|
||||
import { LintConfig } from '../types/LintConfig'
|
||||
import { LintConfig, Macro } from '../types'
|
||||
import { LineEndings } from '../types/LineEndings'
|
||||
import { trimComments } from './trimComments'
|
||||
|
||||
interface Macro {
|
||||
name: string
|
||||
startLineNumbers: number[]
|
||||
endLineNumber: number | null
|
||||
declarationLines: string[]
|
||||
terminationLine: string
|
||||
declaration: string
|
||||
termination: string
|
||||
parentMacro: string
|
||||
hasMacroNameInMend: boolean
|
||||
mismatchedMendMacroName: string
|
||||
}
|
||||
|
||||
export const parseMacros = (text: string, config?: LintConfig): Macro[] => {
|
||||
const lineEnding = config?.lineEndings === LineEndings.CRLF ? '\r\n' : '\n'
|
||||
const lines: string[] = text ? text.split(lineEnding) : []
|
||||
@@ -39,6 +26,8 @@ export const parseMacros = (text: string, config?: LintConfig): Macro[] => {
|
||||
const statements: string[] = trimmedLine.split(';')
|
||||
|
||||
if (isReadingMacroDefinition) {
|
||||
// checking if code is split into statements based on `;` is a part of HTML Encoded Character
|
||||
// if it happened, merges two statements into one
|
||||
statements.forEach((statement, statementIndex) => {
|
||||
if (/&[^\s]{1,5}$/.test(statement)) {
|
||||
const next = statements[statementIndex]
|
||||
|
||||
Reference in New Issue
Block a user