File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import type { FmtConfig , ResolvedFmtConfig } from './types.ts' ;
2+
3+ /** Splits a flat config into project-level formatting options and rules. */
4+ const normalizeFmtConfig = ( config : FmtConfig | undefined , rootPath : string ) : ResolvedFmtConfig => {
5+ const { ignorePatterns = [ ] , overrides = [ ] , ...baseOptions } = config ?? { } ;
6+
7+ return {
8+ rootPath,
9+ baseOptions,
10+ overrides,
11+ ignorePatterns,
12+ } ;
13+ } ;
14+
15+ export { normalizeFmtConfig } ;
Original file line number Diff line number Diff line change 1- import type { Config as PrettierConfig } from 'prettier' ;
1+ import type { Config as PrettierConfig , Options as PrettierOptions } from 'prettier' ;
22
33interface FmtConfig extends PrettierConfig {
44 /** Gitignore-compatible patterns relative to the Rstack config root. */
@@ -7,4 +7,16 @@ interface FmtConfig extends PrettierConfig {
77
88type FmtConfigDefinition = FmtConfig | ( ( ) => FmtConfig | Promise < FmtConfig > ) ;
99
10- export type { FmtConfig , FmtConfigDefinition } ;
10+ /** Internal project config before per-file rules are applied. */
11+ interface ResolvedFmtConfig {
12+ /** Root for relative patterns and plugin paths. */
13+ rootPath : string ;
14+ /** Shared Prettier options before per-file overrides. */
15+ baseOptions : PrettierOptions ;
16+ /** Per-file override rules. */
17+ overrides : NonNullable < PrettierConfig [ 'overrides' ] > ;
18+ /** Root-relative ignore patterns. */
19+ ignorePatterns : string [ ] ;
20+ }
21+
22+ export type { FmtConfig , FmtConfigDefinition , ResolvedFmtConfig } ;
You can’t perform that action at this time.
0 commit comments