1
0
mirror of https://github.com/sasjs/lint.git synced 2026-01-16 16:50:05 +00:00

chore: quick fix

This commit is contained in:
2022-12-29 00:47:54 +05:00
parent c0fdfc6ac9
commit 5c44ec400d
3 changed files with 14 additions and 4 deletions

View File

@@ -30,7 +30,7 @@ export const processLine = (config: LintConfig, line: string): string => {
config.lineLintRules config.lineLintRules
.filter((r) => !!r.fix) .filter((r) => !!r.fix)
.forEach((rule) => { .forEach((rule) => {
processedLine = rule.fix!(line, config) processedLine = rule.fix!(processedLine, config)
}) })
return processedLine return processedLine

View File

@@ -22,6 +22,7 @@ export const DefaultLintConfiguration = {
noNestedMacros: true, noNestedMacros: true,
hasMacroParentheses: true, hasMacroParentheses: true,
strictMacroDefinition: true, strictMacroDefinition: true,
noGremlins: true,
defaultHeader: getDefaultHeader() defaultHeader: getDefaultHeader()
} }

View File

@@ -8,10 +8,19 @@ import { LineEndings } from '../types/LineEndings'
*/ */
export const splitText = (text: string, config: LintConfig): string[] => { export const splitText = (text: string, config: LintConfig): string[] => {
if (!text) return [] if (!text) return []
const expectedLineEndings = const expectedLineEndings =
config.lineEndings === LineEndings.LF ? '\n' : '\r\n' config.lineEndings === LineEndings.LF ? '\n' : '\r\n'
const incorrectLineEndings = expectedLineEndings === '\n' ? '\r\n' : '\n' const incorrectLineEndings = expectedLineEndings === '\n' ? '\r\n' : '\n'
return text
.replace(new RegExp(incorrectLineEndings, 'g'), expectedLineEndings) text = text.replace(
.split(expectedLineEndings) new RegExp(incorrectLineEndings, 'g'),
expectedLineEndings
)
// splitting text on '\r\n' was causing some problem
// as it was retaining carriage return at the end of each line
// so, removed the carriage returns from text and splitted on line feed (lf)
return text.replace(/\r/g, '').split(/\n/)
} }