-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathgetFilePaths.ts
More file actions
25 lines (21 loc) · 901 Bytes
/
getFilePaths.ts
File metadata and controls
25 lines (21 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { isFileStrictByPath } from '../../common/isFileStrictByPath';
import { getAbsolutePath } from '../../common/getAbsolutePath';
import { findStrictErrors } from '../findStrictErrors';
export const getFilePathsWithErrors = async (allFilePaths: string[]) => {
const errors = await findStrictErrors(allFilePaths);
const getFilePathFromErrorMessage = (error: string) => {
const match = error.match(/^(.*?)(?=\(\d+,\d+\))/);
const beforePattern = match ? match[1] : error;
return getAbsolutePath(process.cwd(), beforePattern);
};
return [...new Set(errors.map(getFilePathFromErrorMessage))];
};
export const getFilePathsOnPathWithoutErrors = (
allFilePaths: string[],
filePathsWithErrors: string[],
configPaths?: string[],
) =>
allFilePaths.filter(
(filePath) =>
isFileStrictByPath({ filePath, configPaths }) && !filePathsWithErrors.includes(filePath),
);