-
Notifications
You must be signed in to change notification settings - Fork 20
/
precise-formatter.ts
50 lines (49 loc) · 1.45 KB
/
precise-formatter.ts
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { CharacterRange } from './utils';
/**
* Any registered precise-formatters must implement this interface
*/
export interface PreciseFormatter<FormatterConfig> {
/**
* Resolve the formatter config which is relevant for the given file path.
*/
resolveConfig(modifiedFilePath: string): FormatterConfig | null;
/**
* Return true if the file contents are already formatted in accordance
* with the given config.
*/
isAlreadyFormatted(
fileContents: string,
formatterConfig: FormatterConfig | null,
): boolean;
/**
* Check the formatting of the file contents, using the given config
* and character range info.
*/
checkFormattingOfRanges(
fileContents: string,
config: FormatterConfig | null,
characterRanges: CharacterRange[],
): boolean;
/**
* Run the formatter on the file contents, using the given config and
* character range info.
*/
formatRanges(
fileContents: string,
config: FormatterConfig | null,
characterRanges: CharacterRange[],
): string;
/**
* Function which creates a callback function which will be
* used as a predicate when filtering the modified files returned
* from the git analysis.
*/
generateIgnoreFilePredicate(
workingDirectory: string,
): (filename: string) => boolean;
/**
* Return true if the given filename has a file extension which is
* supported by the formatter.
*/
hasSupportedFileExtension(filename: string): boolean;
}