mirror of
https://github.com/sasjs/lint.git
synced 2026-04-11 00:13:14 +00:00
feat(lint): add lintFolder and lintProject APIs
This commit is contained in:
8
src/utils/asyncForEach.ts
Normal file
8
src/utils/asyncForEach.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export async function asyncForEach(
|
||||
array: any[],
|
||||
callback: (item: any, index: number, originalArray: any[]) => any
|
||||
) {
|
||||
for (let index = 0; index < array.length; index++) {
|
||||
await callback(array[index], index, array)
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ export async function getLintConfig(): Promise<LintConfig> {
|
||||
const configuration = await readFile(
|
||||
path.join(projectRoot, '.sasjslint')
|
||||
).catch((_) => {
|
||||
console.warn('Unable to load .sasjslint file. Using default configuration.')
|
||||
return JSON.stringify(DefaultLintConfiguration)
|
||||
})
|
||||
return new LintConfig(JSON.parse(configuration))
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from './getLintConfig'
|
||||
export * from './getProjectRoot'
|
||||
export * from './listSasFiles'
|
||||
|
||||
6
src/utils/listSasFiles.ts
Normal file
6
src/utils/listSasFiles.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { listFilesInFolder } from '@sasjs/utils/file'
|
||||
|
||||
export const listSasFiles = async (folderPath: string): Promise<string[]> => {
|
||||
const files = await listFilesInFolder(folderPath)
|
||||
return files.filter((f) => f.endsWith('.sas'))
|
||||
}
|
||||
Reference in New Issue
Block a user