1
0
mirror of https://github.com/sasjs/lint.git synced 2026-01-04 03:10:06 +00:00

feat(path-lint): add support for linting file names, add lint config schema

This commit is contained in:
Krishna Acondy
2021-03-24 19:37:51 +00:00
parent c88aa8b3f6
commit c92630a8f9
13 changed files with 237 additions and 18 deletions

View File

@@ -1,7 +1,8 @@
import { hasDoxygenHeader } from '../rules/hasDoxygenHeader'
import { noEncodedPasswords } from '../rules/noEncodedPasswords'
import { noSpacesInFileNames } from '../rules/noSpacesInFileNames'
import { noTrailingSpaces } from '../rules/noTrailingSpaces'
import { FileLintRule, LineLintRule } from './LintRule'
import { FileLintRule, LineLintRule, PathLintRule } from './LintRule'
/**
* LintConfig is the logical representation of the .sasjslint file.
@@ -13,6 +14,7 @@ import { FileLintRule, LineLintRule } from './LintRule'
export class LintConfig {
readonly lineLintRules: LineLintRule[] = []
readonly fileLintRules: FileLintRule[] = []
readonly pathLintRules: PathLintRule[] = []
constructor(json?: any) {
if (json?.noTrailingSpaces) {
@@ -26,5 +28,9 @@ export class LintConfig {
if (json?.hasDoxygenHeader) {
this.fileLintRules.push(hasDoxygenHeader)
}
if (json?.noSpacesInFileNames) {
this.pathLintRules.push(noSpacesInFileNames)
}
}
}

View File

@@ -10,7 +10,6 @@ export interface LintRule {
name: string
description: string
message: string
test: (value: string, lineNumber: number) => Diagnostic[]
}
/**
@@ -18,6 +17,7 @@ export interface LintRule {
*/
export interface LineLintRule extends LintRule {
type: LintRuleType.Line
test: (value: string, lineNumber: number) => Diagnostic[]
}
/**
@@ -27,3 +27,11 @@ export interface FileLintRule extends LintRule {
type: LintRuleType.File
test: (value: string) => Diagnostic[]
}
/**
* A PathLintRule is run once per file.
*/
export interface PathLintRule extends LintRule {
type: LintRuleType.Path
test: (value: string) => Diagnostic[]
}

View File

@@ -4,5 +4,6 @@
*/
export enum LintRuleType {
Line,
File
File,
Path
}