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:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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[]
|
||||
}
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
*/
|
||||
export enum LintRuleType {
|
||||
Line,
|
||||
File
|
||||
File,
|
||||
Path
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user