mirror of
https://github.com/sasjs/lint.git
synced 2026-01-15 16:20:05 +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 { readFile } from '@sasjs/utils/file'
|
||||||
import { getProjectRoot } from './getProjectRoot'
|
import { getProjectRoot } from './getProjectRoot'
|
||||||
|
|
||||||
|
const defaultConfiguration = {
|
||||||
|
noTrailingSpaces: true,
|
||||||
|
noEncodedPasswords: true,
|
||||||
|
hasDoxygenHeader: true
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Fetches the config from the .sasjslint file and creates a LintConfig object.
|
* Fetches the config from the .sasjslint file and creates a LintConfig object.
|
||||||
* @returns {Promise<LintConfig>} resolves with an object representing the current lint configuration.
|
* @returns {Promise<LintConfig>} resolves with an object representing the current lint configuration.
|
||||||
*/
|
*/
|
||||||
export async function getLintConfig(): Promise<LintConfig> {
|
export async function getLintConfig(): Promise<LintConfig> {
|
||||||
const projectRoot = await getProjectRoot()
|
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))
|
return new LintConfig(JSON.parse(configuration))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user