From c210699954d0638deffda24b2d7f86617b66aa14 Mon Sep 17 00:00:00 2001 From: Sabir Hassan Date: Tue, 8 Nov 2022 19:33:21 +0500 Subject: [PATCH 1/2] feat: add configuration as an optional argument for formatText --- src/format/formatText.ts | 5 +++-- src/format/shared.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/format/formatText.ts b/src/format/formatText.ts index b33807e..2b666cf 100644 --- a/src/format/formatText.ts +++ b/src/format/formatText.ts @@ -1,7 +1,8 @@ +import { LintConfig } from '../types' import { getLintConfig } from '../utils' import { processText } from './shared' -export const formatText = async (text: string) => { - const config = await getLintConfig() +export const formatText = async (text: string, configuration?: LintConfig) => { + const config = configuration || (await getLintConfig()) return processText(text, config) } diff --git a/src/format/shared.ts b/src/format/shared.ts index 3918987..76702f1 100644 --- a/src/format/shared.ts +++ b/src/format/shared.ts @@ -30,7 +30,7 @@ export const processLine = (config: LintConfig, line: string): string => { config.lineLintRules .filter((r) => !!r.fix) .forEach((rule) => { - processedLine = rule.fix!(line) + processedLine = rule.fix!(line, config) }) return processedLine From debeff79297a6dde83999e5ab0bec505a4810181 Mon Sep 17 00:00:00 2001 From: Sabir Hassan Date: Tue, 8 Nov 2022 19:43:18 +0500 Subject: [PATCH 2/2] fix: updated sasjslint-schema.json --- sasjslint-schema.json | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sasjslint-schema.json b/sasjslint-schema.json index d52669f..f5cac94 100644 --- a/sasjslint-schema.json +++ b/sasjslint-schema.json @@ -7,6 +7,7 @@ "default": { "noEncodedPasswords": true, "hasDoxygenHeader": true, + "defaultHeader": "/**{lineEnding} @file{lineEnding} @brief {lineEnding}

SAS Macros

{lineEnding}**/", "hasMacroNameInMend": false, "hasMacroParentheses": true, "indentationMultiple": 2, @@ -18,10 +19,7 @@ "noTrailingSpaces": true, "lineEndings": "lf", "strictMacroDefinition": true, - "ignoreList": [ - "sajsbuild", - "sasjsresults" - ] + "ignoreList": ["sajsbuild", "sasjsresults"] }, "examples": [ { @@ -58,6 +56,14 @@ "default": true, "examples": [true, false] }, + "defaultHeader": { + "$id": "#/properties/defaultHeader", + "type": "boolean", + "title": "defaultHeader", + "description": "This sets the default program header - applies when a SAS program does NOT begin with `/**`.", + "default": "/**{lineEnding} @file{lineEnding} @brief {lineEnding}

SAS Macros

{lineEnding}**/", + "examples": [] + }, "hasMacroNameInMend": { "$id": "#/properties/hasMacroNameInMend", "type": "boolean",