mirror of
https://github.com/sasjs/lint.git
synced 2026-01-05 03:30:06 +00:00
feat(lint): add rules for lowercase file names, max line length and no tab indentation
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { hasDoxygenHeader } from '../rules/hasDoxygenHeader'
|
||||
import { lowerCaseFileNames } from '../rules/lowerCaseFileNames'
|
||||
import { maxLineLength } from '../rules/maxLineLength'
|
||||
import { noEncodedPasswords } from '../rules/noEncodedPasswords'
|
||||
import { noSpacesInFileNames } from '../rules/noSpacesInFileNames'
|
||||
import { noTabIndentation } from '../rules/noTabIndentation'
|
||||
import { noTrailingSpaces } from '../rules/noTrailingSpaces'
|
||||
import { FileLintRule, LineLintRule, PathLintRule } from './LintRule'
|
||||
|
||||
@@ -15,6 +18,7 @@ export class LintConfig {
|
||||
readonly lineLintRules: LineLintRule[] = []
|
||||
readonly fileLintRules: FileLintRule[] = []
|
||||
readonly pathLintRules: PathLintRule[] = []
|
||||
readonly maxLineLength = 80
|
||||
|
||||
constructor(json?: any) {
|
||||
if (json?.noTrailingSpaces) {
|
||||
@@ -25,6 +29,15 @@ export class LintConfig {
|
||||
this.lineLintRules.push(noEncodedPasswords)
|
||||
}
|
||||
|
||||
if (json?.noTabIndentation) {
|
||||
this.lineLintRules.push(noTabIndentation)
|
||||
}
|
||||
|
||||
if (json?.maxLineLength) {
|
||||
this.maxLineLength = json.maxLineLength
|
||||
this.lineLintRules.push(maxLineLength)
|
||||
}
|
||||
|
||||
if (json?.hasDoxygenHeader) {
|
||||
this.fileLintRules.push(hasDoxygenHeader)
|
||||
}
|
||||
@@ -32,5 +45,9 @@ export class LintConfig {
|
||||
if (json?.noSpacesInFileNames) {
|
||||
this.pathLintRules.push(noSpacesInFileNames)
|
||||
}
|
||||
|
||||
if (json?.lowerCaseFileNames) {
|
||||
this.pathLintRules.push(lowerCaseFileNames)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Diagnostic } from './Diagnostic'
|
||||
import { LintConfig } from './LintConfig'
|
||||
import { LintRuleType } from './LintRuleType'
|
||||
|
||||
/**
|
||||
@@ -17,7 +18,7 @@ export interface LintRule {
|
||||
*/
|
||||
export interface LineLintRule extends LintRule {
|
||||
type: LintRuleType.Line
|
||||
test: (value: string, lineNumber: number) => Diagnostic[]
|
||||
test: (value: string, lineNumber: number, config?: LintConfig) => Diagnostic[]
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user