File tree Expand file tree Collapse file tree 3 files changed +23
-15
lines changed Expand file tree Collapse file tree 3 files changed +23
-15
lines changed Original file line number Diff line number Diff line change @@ -19,17 +19,26 @@ import type {
19
19
} from '../types'
20
20
21
21
export async function formatter (
22
- options : OptionsFormatters = { } ,
22
+ options : OptionsFormatters | true = { } ,
23
23
prettierRules : PartialPrettierExtendedOptions = { } ,
24
24
) : Promise < FlatConfigItem [ ] > {
25
25
const {
26
26
css = true ,
27
- graphql,
27
+ graphql = false ,
28
28
html = true ,
29
- markdown,
30
- toml,
31
- yaml,
32
- } = options || { }
29
+ markdown = false ,
30
+ toml = false ,
31
+ yaml = false ,
32
+ } = typeof options === 'object'
33
+ ? options
34
+ : {
35
+ css : true ,
36
+ graphql : true ,
37
+ html : true ,
38
+ markdown : true ,
39
+ toml : true ,
40
+ yaml : true ,
41
+ }
33
42
34
43
const pluginPrettier = await interopDefault ( import ( 'eslint-plugin-prettier' ) )
35
44
@@ -38,7 +47,7 @@ export async function formatter(
38
47
parser : PrettierParser ,
39
48
plugins ?: string [ ] ,
40
49
) {
41
- const rules = {
50
+ const rules : PartialPrettierExtendedOptions = {
42
51
...prettierRules ,
43
52
parser,
44
53
}
Original file line number Diff line number Diff line change @@ -218,11 +218,11 @@ export async function defineConfig(
218
218
)
219
219
Object . assign ( prettierRules , prettierConfig )
220
220
}
221
+ configs . push ( prettier ( options . formatter ? prettierRules : { } ) )
221
222
222
- configs . push (
223
- prettier ( prettierRules ) ,
224
- formatter ( options . formatter , prettierRules ) ,
225
- )
223
+ if ( options . formatter ) {
224
+ configs . push ( formatter ( options . formatter , prettierRules ) )
225
+ }
226
226
227
227
// User can optionally pass a flat config item to the first argument
228
228
// We pick the known keys as ESLint would do schema validation
Original file line number Diff line number Diff line change @@ -218,9 +218,6 @@ export interface OptionsConfig extends OptionsComponentExts {
218
218
/**
219
219
* Use external formatters to format files.
220
220
*
221
- * Requires installing:
222
- * - `eslint-plugin-prettier`
223
- *
224
221
* @default
225
222
* {
226
223
* "html": true,
@@ -230,8 +227,10 @@ export interface OptionsConfig extends OptionsComponentExts {
230
227
* "yaml": false
231
228
* "toml": false
232
229
* }
230
+ *
231
+ * When set to `true`, it will enable all formatters.
233
232
*/
234
- formatter ?: OptionsFormatters
233
+ formatter ?: boolean | OptionsFormatters
235
234
236
235
/**
237
236
* Default prettier rules
You can’t perform that action at this time.
0 commit comments