1
0
mirror of https://github.com/sasjs/lint.git synced 2025-12-11 01:44:36 +00:00

Merge pull request #180 from sasjs/quick-fix

feat: add configuration as an optional argument for formatText
This commit is contained in:
Allan Bowe
2022-11-08 14:48:44 +00:00
committed by GitHub
3 changed files with 14 additions and 7 deletions

View File

@@ -7,6 +7,7 @@
"default": { "default": {
"noEncodedPasswords": true, "noEncodedPasswords": true,
"hasDoxygenHeader": true, "hasDoxygenHeader": true,
"defaultHeader": "/**{lineEnding} @file{lineEnding} @brief <Your brief here>{lineEnding} <h4> SAS Macros </h4>{lineEnding}**/",
"hasMacroNameInMend": false, "hasMacroNameInMend": false,
"hasMacroParentheses": true, "hasMacroParentheses": true,
"indentationMultiple": 2, "indentationMultiple": 2,
@@ -18,10 +19,7 @@
"noTrailingSpaces": true, "noTrailingSpaces": true,
"lineEndings": "lf", "lineEndings": "lf",
"strictMacroDefinition": true, "strictMacroDefinition": true,
"ignoreList": [ "ignoreList": ["sajsbuild", "sasjsresults"]
"sajsbuild",
"sasjsresults"
]
}, },
"examples": [ "examples": [
{ {
@@ -58,6 +56,14 @@
"default": true, "default": true,
"examples": [true, false] "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 <Your brief here>{lineEnding} <h4> SAS Macros </h4>{lineEnding}**/",
"examples": []
},
"hasMacroNameInMend": { "hasMacroNameInMend": {
"$id": "#/properties/hasMacroNameInMend", "$id": "#/properties/hasMacroNameInMend",
"type": "boolean", "type": "boolean",

View File

@@ -1,7 +1,8 @@
import { LintConfig } from '../types'
import { getLintConfig } from '../utils' import { getLintConfig } from '../utils'
import { processText } from './shared' import { processText } from './shared'
export const formatText = async (text: string) => { export const formatText = async (text: string, configuration?: LintConfig) => {
const config = await getLintConfig() const config = configuration || (await getLintConfig())
return processText(text, config) return processText(text, config)
} }

View File

@@ -30,7 +30,7 @@ export const processLine = (config: LintConfig, line: string): string => {
config.lineLintRules config.lineLintRules
.filter((r) => !!r.fix) .filter((r) => !!r.fix)
.forEach((rule) => { .forEach((rule) => {
processedLine = rule.fix!(line) processedLine = rule.fix!(line, config)
}) })
return processedLine return processedLine