mirror of
https://github.com/sasjs/lint.git
synced 2025-12-11 01:44:36 +00:00
chore(*): add fallback to default config
This commit is contained in:
@@ -3,12 +3,22 @@ import { LintConfig } from '../types/LintConfig'
|
||||
import { readFile } from '@sasjs/utils/file'
|
||||
import { getProjectRoot } from './getProjectRoot'
|
||||
|
||||
const defaultConfiguration = {
|
||||
noTrailingSpaces: true,
|
||||
noEncodedPasswords: true,
|
||||
hasDoxygenHeader: true
|
||||
}
|
||||
/**
|
||||
* Fetches the config from the .sasjslint file and creates a LintConfig object.
|
||||
* @returns {Promise<LintConfig>} resolves with an object representing the current lint configuration.
|
||||
*/
|
||||
export async function getLintConfig(): Promise<LintConfig> {
|
||||
const projectRoot = await getProjectRoot()
|
||||
const configuration = await readFile(path.join(projectRoot, '.sasjslint'))
|
||||
const configuration = await readFile(
|
||||
path.join(projectRoot, '.sasjslint')
|
||||
).catch((e) => {
|
||||
console.error('Error reading .sasjslint file', e)
|
||||
return JSON.stringify(defaultConfiguration)
|
||||
})
|
||||
return new LintConfig(JSON.parse(configuration))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user