Skip to content

Commit

Permalink
refactor: 💡 add union type BladeFormatterOption
Browse files Browse the repository at this point in the history
  • Loading branch information
shufo committed Oct 9, 2022
1 parent 21834e4 commit e1e0dac
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ import {
} from './runtimeConfig';
import FormatError from './errors/formatError';

export interface CLIOption {
export type CLIOption = {
write?: boolean;
diff?: boolean;
checkFormatted?: boolean;
progress?: boolean;
ignoreFilePath?: string;
runtimeConfigPath?: string;
}
};

export interface FormatterOption {
export type FormatterOption = {
indentSize?: number;
wrapLineLength?: number;
wrapAttributes?: WrapAttributes;
Expand All @@ -40,7 +40,9 @@ export interface FormatterOption {
tailwindcssConfig?: TailwindConfig;
sortHtmlAttributes?: SortHtmlAttributes;
noMultipleEmptyLines?: boolean;
}
};

export type BladeFormatterOption = CLIOption & FormatterOption;

class BladeFormatter {
diffs: any;
Expand Down Expand Up @@ -69,7 +71,7 @@ class BladeFormatter {

runtimeConfigCache: RuntimeConfig;

constructor(options: FormatterOption & CLIOption = {}, paths: any = []) {
constructor(options: BladeFormatterOption = {}, paths: any = []) {
this.currentTargetPath = '.';
this.paths = paths;
this.options = options;
Expand All @@ -85,7 +87,7 @@ class BladeFormatter {
this.runtimeConfigCache = {};
}

async format(content: any, opts = {}) {
async format(content: any, opts: BladeFormatterOption = {}) {
this.options = this.options || opts;
const target = nodepath.resolve(process.cwd(), 'target');
await this.readIgnoreFile(target);
Expand Down

0 comments on commit e1e0dac

Please sign in to comment.