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

chore(*): organise rules into folders by type

This commit is contained in:
Krishna Acondy
2021-04-07 16:34:33 +01:00
parent cc33ebb6e6
commit c9b6c3af95
26 changed files with 80 additions and 66 deletions

View File

@@ -0,0 +1,32 @@
import { LintConfig } from '../../types'
import { LineLintRule } from '../../types/LintRule'
import { LintRuleType } from '../../types/LintRuleType'
import { Severity } from '../../types/Severity'
const name = 'maxLineLength'
const description = 'Restrict lines to the specified length.'
const message = 'Line exceeds maximum length'
const test = (value: string, lineNumber: number, config?: LintConfig) => {
const maxLineLength = config?.maxLineLength || 80
if (value.length <= maxLineLength) return []
return [
{
message: `${message} by ${value.length - maxLineLength} characters`,
lineNumber,
startColumnNumber: 1,
endColumnNumber: 1,
severity: Severity.Warning
}
]
}
/**
* Lint rule that checks if a line has exceeded the configured maximum length.
*/
export const maxLineLength: LineLintRule = {
type: LintRuleType.Line,
name,
description,
message,
test
}