Skip to content

Commit

Permalink
feat(prettier): add curly support
Browse files Browse the repository at this point in the history
  • Loading branch information
ModyQyW committed Nov 15, 2024
1 parent 980df9b commit 17a9e7a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/prettier/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ export function prettier(
options: Options = {},
userConfig: Config = {},
): Config {
const { jsdoc } = parseOptions(options);
const { curly, jsdoc } = parseOptions(options);

const plugins = [];
if (jsdoc) plugins.push("prettier-plugin-jsdoc");
if (jsdoc) {
plugins.push("prettier-plugin-jsdoc");
}
if (curly) {
plugins.push("prettier-plugin-curly");
}

return {
plugins,
Expand Down
7 changes: 7 additions & 0 deletions src/prettier/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import type { Config as PrettierConfig } from "prettier";
export type Config = PrettierConfig & Record<string, any>;

export interface Options {
/**
* Format curly braces.
*
* @default true
*/
curly?: boolean;

/**
* Format JSDoc and TSDoc comments. Use prettier-plugin-jsdoc.
*
Expand Down
1 change: 1 addition & 0 deletions src/prettier/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Options } from "./types.ts";

export function parseOptions(options: Options = {}): Required<Options> {
return {
curly: options.curly ?? true,
jsdoc: options.jsdoc ?? true,
};
}

0 comments on commit 17a9e7a

Please sign in to comment.