mirror of
https://github.com/sasjs/lint.git
synced 2026-01-04 03:10:06 +00:00
feat: add a new config maxHeaderLineLength
This commit is contained in:
@@ -31,6 +31,17 @@ describe('LintConfig', () => {
|
||||
).toBeUndefined()
|
||||
})
|
||||
|
||||
it('should create an instance with the maxLineLength flag off', () => {
|
||||
const config = new LintConfig({ maxLineLength: 0 })
|
||||
|
||||
expect(config).toBeTruthy()
|
||||
expect(config.lineLintRules.length).toBeGreaterThan(0)
|
||||
expect(config.fileLintRules.length).toBeGreaterThan(0)
|
||||
expect(
|
||||
config.lineLintRules.find((rule) => rule.name === 'maxLineLength')
|
||||
).toBeUndefined()
|
||||
})
|
||||
|
||||
it('should create an instance with the hasDoxygenHeader flag off', () => {
|
||||
const config = new LintConfig({ hasDoxygenHeader: false })
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ export class LintConfig {
|
||||
readonly fileLintRules: FileLintRule[] = []
|
||||
readonly pathLintRules: PathLintRule[] = []
|
||||
readonly maxLineLength: number = 80
|
||||
readonly maxHeaderLineLength: number = 80
|
||||
readonly indentationMultiple: number = 2
|
||||
readonly lineEndings: LineEndings = LineEndings.LF
|
||||
readonly defaultHeader: string = getDefaultHeader()
|
||||
@@ -67,9 +68,16 @@ export class LintConfig {
|
||||
this.lineLintRules.pop()
|
||||
}
|
||||
|
||||
this.lineLintRules.push(maxLineLength)
|
||||
if (!isNaN(json?.maxLineLength)) {
|
||||
this.maxLineLength = json.maxLineLength
|
||||
if (json?.maxLineLength) {
|
||||
this.lineLintRules.push(maxLineLength)
|
||||
|
||||
if (!isNaN(json?.maxLineLength)) {
|
||||
this.maxLineLength = json.maxLineLength
|
||||
}
|
||||
|
||||
if (!isNaN(json?.maxHeaderLineLength)) {
|
||||
this.maxHeaderLineLength = json.maxHeaderLineLength
|
||||
}
|
||||
}
|
||||
|
||||
this.fileLintRules.push(lineEndings)
|
||||
|
||||
@@ -18,7 +18,12 @@ export interface LintRule {
|
||||
*/
|
||||
export interface LineLintRule extends LintRule {
|
||||
type: LintRuleType.Line
|
||||
test: (value: string, lineNumber: number, config?: LintConfig) => Diagnostic[]
|
||||
test: (
|
||||
value: string,
|
||||
lineNumber: number,
|
||||
config?: LintConfig,
|
||||
isHeaderLine?: boolean
|
||||
) => Diagnostic[]
|
||||
fix?: (value: string, config?: LintConfig) => string
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user