From e1bcf5b06b71c1a3b95e8f0455e4271821ed3223 Mon Sep 17 00:00:00 2001 From: Sabir Hassan Date: Fri, 12 Aug 2022 15:48:35 +0500 Subject: [PATCH] feat: add a new attribute ignoreList to .sasjslint (LintConfig) --- sasjslint-schema.json | 8 ++++++++ src/types/LintConfig.ts | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/sasjslint-schema.json b/sasjslint-schema.json index d56960a..8858cdc 100644 --- a/sasjslint-schema.json +++ b/sasjslint-schema.json @@ -140,6 +140,14 @@ "description": "Enforces Macro Definition syntax. Shows a warning when incorrect syntax is used.", "default": true, "examples": [true, false] + }, + "ignoreList": { + "$id": "#/properties/ignoreList", + "type": "object", + "title": "ignoreList", + "description": "An array of paths or path patterns to ignore matching resources from linting. Files or folders matching patterns in .gitignore will always be ignored.", + "default": ["sasjsbuild/", "sasjsresults/"], + "examples": ["sasjs/services", "appinit.sas"] } } } diff --git a/src/types/LintConfig.ts b/src/types/LintConfig.ts index f8fe2d3..e2fce14 100644 --- a/src/types/LintConfig.ts +++ b/src/types/LintConfig.ts @@ -25,6 +25,7 @@ import { FileLintRule, LineLintRule, PathLintRule } from './LintRule' * More types of rules, when available, will be added here. */ export class LintConfig { + readonly ignoreList: string[] = [] readonly lineLintRules: LineLintRule[] = [] readonly fileLintRules: FileLintRule[] = [] readonly pathLintRules: PathLintRule[] = [] @@ -33,6 +34,20 @@ export class LintConfig { readonly lineEndings: LineEndings = LineEndings.LF constructor(json?: any) { + if (json?.ignoreList) { + if (Array.isArray(json.ignoreList)) { + json.ignoreList.forEach((item: any) => { + if (typeof item === 'string') this.ignoreList.push(item) + else + throw new Error( + `Property "ignoreList" has invalid type of values. It can contain only strings.` + ) + }) + } else { + throw new Error(`Property "ignoreList" can only be an array of strings`) + } + } + if (json?.noTrailingSpaces) { this.lineLintRules.push(noTrailingSpaces) }