-
-
Notifications
You must be signed in to change notification settings - Fork 171
/
index.d.ts
95 lines (90 loc) · 3.54 KB
/
index.d.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Type definitions for prettier-eslint 12.0
// Project: https://github.com/prettier/prettier-eslint
import * as eslint from "eslint";
import * as prettier from "prettier";
declare namespace format {
/**
* Logging level for the traceback of the synchronous formatting process.
*/
type LogLevel = "error" | "warn" | "info" | "debug" | "trace";
/**
* Options to format text with Prettier and ESLint.
*/
interface Options {
/**
* The config to use for formatting with ESLint.
*/
eslintConfig?: eslint.Linter.Config;
/**
* The path to the eslint module to use.
* Will default to require.resolve('eslint')
*/
eslintPath?: string;
/**
* The options to pass for formatting with `prettier` if the given
* option is not inferrable from the `eslintConfig`.
*/
fallbackPrettierOptions?: prettier.Options;
/**
* The path of the file being formatted can be used in lieu of
* `eslintConfig` (eslint will be used to find the relevant
* config for the file). Will also be used to load the `text` if
* `text` is not provided.
*/
filePath?: string;
/**
* The level for the logs (`error`, `warn`, `info`, `debug`, `trace`).
*/
logLevel?: LogLevel;
/**
* The options to pass for formatting with `prettier`. If not provided,
* prettier-eslint will attempt to create the options based on the
* `eslintConfig` value.
*/
prettierOptions?: prettier.Options;
/**
* The path to the `prettier` module.
* Will default to require.resovlve('prettier')
*/
prettierPath?: string;
/**
* Run Prettier last.
*/
prettierLast?: boolean;
/**
* The text (JavaScript code) to format.
*/
text: string;
}
}
/**
* Formats the text with Prettier and then ESLint while obeying the user's
* configuration.
*
* @param options Options to format text with Prettier and Eslint.
* @param options.eslintConfig The config to use for formatting
* with ESLint.
* @param options.eslintPath The path to the eslint module to use.
* Will default to require.resolve('eslint')
* @param options.fallbackPrettierOptions The options to pass for
* formatting with `prettier` if the given option is not inferrable from the
* eslintConfig.
* @param options.filePath The path of the file being formatted
* can be used in lieu of `eslintConfig` (eslint will be used to find the
* relevant config for the file). Will also be used to load the `text` if
* `text` is not provided.
* @param options.prettierOptions The options to pass for
* formatting with `prettier`. If not provided, prettier-eslint will attempt
* to create the options based on the `eslintConfig` value.
* @param options.prettierLast Run Prettier last.
* @param options.prettierPath The path to the prettier module.
* Will default to require.resovlve('prettier')
* @param options.logLevel The level for the logs (`error`, `warn`,
* `info`, `debug`, `trace`).
* @param options.text The text (JavaScript code) to format.
* @return Auto-formatted text that is mostly compliant with the
* supplied configuration. The auto-formatting is limited to the issues that
* Prettier and ESLint can automatically fix.
*/
declare function format(options: format.Options): string;
export = format;