-
After completing the tutorial, I took a stab at creating types for a Prettier configuration file. What i've run into is that, Prettier allows you to define a base config (what I've got in ☝️ that gist), and overrides. Each override can accept all the same options as the base config (minus additional overrides). How could I structure something like that? I could create an |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I'd probably do something like this: open module io.prettier.Options
/// Print semicolons at the ends of statements.
///
/// Valid options:
/// true - Add a semicolon at the end of every statement.
/// false - Only add semicolons at the beginning of lines that may introduce ASI failures.
semi: Boolean?
/// "all" - Trailing commas wherever possible (including function parameters and calls). To run, JavaScript code formatted this way needs an engine that supports ES2017 (Node.js 8+ or a modern browser) or downlevel compilation. This also enables trailing commas in type parameters in TypeScript (supported since TypeScript 2.7 released in January 2018).
/// "es5" - Trailing commas where valid in ES5 (objects, arrays, etc.). Trailing commas in type parameters in TypeScript and Flow.
/// "none" - No trailing commas.
trailingComma: Boolean?
// etc module io.prettier.PrettierRC
extends "Options.pkl"
/// Overrides let you have different configuration for certain file extensions, folders and specific files.
overrides: Listing<Override>?
class Override {
files: *Listing<String>|String
excludeFiles: (*Listing<String>|String)?
options: Options
} Basically, you define two separate modules, and the root Also: it's better to make these types nullable, because that's how they're represented in Prettier's actual format. Rather than setting defaults explicitly, it's better to leave a doc comment about what Prettier uses if the value is Also: the asterisk on
Instead of:
|
Beta Was this translation helpful? Give feedback.
Also, you might want to add this to your module, because Prettierrc produces JSON. This means that you don't need to provide
-f json
when rendering using the CLI.