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

feat: add new config maxDataLineLength

This commit is contained in:
2023-01-11 19:51:07 +05:00
parent 985ed41a4b
commit 7a46e9857e
10 changed files with 251 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
import { LintConfig } from '../../types'
import { LineLintRule } from '../../types/LintRule'
import { LineLintRule, LineLintRuleOptions } from '../../types/LintRule'
import { LintRuleType } from '../../types/LintRuleType'
import { Severity } from '../../types/Severity'
import { DefaultLintConfiguration } from '../../utils'
@@ -12,15 +12,19 @@ const test = (
value: string,
lineNumber: number,
config?: LintConfig,
isHeaderLine?: boolean
options?: LineLintRuleOptions
) => {
const severity = config?.severityLevel[name] || Severity.Warning
let maxLineLength = config
? config.maxLineLength
: DefaultLintConfiguration.maxLineLength
let maxLineLength = DefaultLintConfiguration.maxLineLength
if (isHeaderLine && config) {
maxLineLength = Math.max(config.maxLineLength, config.maxHeaderLineLength)
if (config) {
if (options?.isHeaderLine) {
maxLineLength = Math.max(config.maxLineLength, config.maxHeaderLineLength)
} else if (options?.isDataLine) {
maxLineLength = Math.max(config.maxLineLength, config.maxDataLineLength)
} else {
maxLineLength = config.maxLineLength
}
}
if (value.length <= maxLineLength) return []