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 {
1919} from '../types'
2020
2121export async function formatter (
22- options : OptionsFormatters = { } ,
22+ options : OptionsFormatters | true = { } ,
2323 prettierRules : PartialPrettierExtendedOptions = { } ,
2424) : Promise < FlatConfigItem [ ] > {
2525 const {
2626 css = true ,
27- graphql,
27+ graphql = false ,
2828 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+ }
3342
3443 const pluginPrettier = await interopDefault ( import ( 'eslint-plugin-prettier' ) )
3544
@@ -38,7 +47,7 @@ export async function formatter(
3847 parser : PrettierParser ,
3948 plugins ?: string [ ] ,
4049 ) {
41- const rules = {
50+ const rules : PartialPrettierExtendedOptions = {
4251 ...prettierRules ,
4352 parser,
4453 }
Original file line number Diff line number Diff line change @@ -218,11 +218,11 @@ export async function defineConfig(
218218 )
219219 Object . assign ( prettierRules , prettierConfig )
220220 }
221+ configs . push ( prettier ( options . formatter ? prettierRules : { } ) )
221222
222- configs . push (
223- prettier ( prettierRules ) ,
224- formatter ( options . formatter , prettierRules ) ,
225- )
223+ if ( options . formatter ) {
224+ configs . push ( formatter ( options . formatter , prettierRules ) )
225+ }
226226
227227 // User can optionally pass a flat config item to the first argument
228228 // 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 {
218218 /**
219219 * Use external formatters to format files.
220220 *
221- * Requires installing:
222- * - `eslint-plugin-prettier`
223- *
224221 * @default
225222 * {
226223 * "html": true,
@@ -230,8 +227,10 @@ export interface OptionsConfig extends OptionsComponentExts {
230227 * "yaml": false
231228 * "toml": false
232229 * }
230+ *
231+ * When set to `true`, it will enable all formatters.
233232 */
234- formatter ?: OptionsFormatters
233+ formatter ?: boolean | OptionsFormatters
235234
236235 /**
237236 * Default prettier rules
You can’t perform that action at this time.
0 commit comments