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

feat(*): add line endings rule, add automatic formatting for fixable violations

This commit is contained in:
Krishna Acondy
2021-04-19 20:06:45 +01:00
parent 031a323839
commit 33a57c3163
32 changed files with 930 additions and 318 deletions

View File

@@ -2,7 +2,8 @@ import {
hasDoxygenHeader,
hasMacroNameInMend,
noNestedMacros,
hasMacroParentheses
hasMacroParentheses,
lineEndings
} from '../rules/file'
import {
indentationMultiple,
@@ -12,6 +13,7 @@ import {
noTrailingSpaces
} from '../rules/line'
import { lowerCaseFileNames, noSpacesInFileNames } from '../rules/path'
import { LineEndings } from './LineEndings'
import { FileLintRule, LineLintRule, PathLintRule } from './LintRule'
/**
@@ -27,6 +29,7 @@ export class LintConfig {
readonly pathLintRules: PathLintRule[] = []
readonly maxLineLength: number = 80
readonly indentationMultiple: number = 2
readonly lineEndings: LineEndings = LineEndings.LF
constructor(json?: any) {
if (json?.noTrailingSpaces) {
@@ -46,6 +49,19 @@ export class LintConfig {
this.lineLintRules.push(maxLineLength)
}
if (json?.lineEndings) {
if (
json.lineEndings !== LineEndings.LF &&
json.lineEndings !== LineEndings.CRLF
) {
throw new Error(
`Invalid value for lineEndings: can be ${LineEndings.LF} or ${LineEndings.CRLF}`
)
}
this.lineEndings = json.lineEndings
this.fileLintRules.push(lineEndings)
}
if (!isNaN(json?.indentationMultiple)) {
this.indentationMultiple = json.indentationMultiple as number
this.lineLintRules.push(indentationMultiple)