Skip to content

Commit

Permalink
Added support for experimentalTernaries option (#3503)
Browse files Browse the repository at this point in the history
  • Loading branch information
ntotten authored Aug 14, 2024
1 parent 2d57752 commit 3712ee7
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ All notable changes to the "prettier-vscode" extension will be documented in thi

## [Unreleased]

- Prevent `.editorconfig` from satisfying the `requireConfig` setting
- [BREAKING CHANGE] Prevent `.editorconfig` from satisfying the `requireConfig` setting
- Fix issue where formatting multiple files in a workspace with multiple instances of Prettier could result in files being overwritten with the contents of other files (#3423, #3040)
- Add support for `experimentalTernaries` option

## [10.5.0]

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ prettier.trailingComma
prettier.useTabs
prettier.vueIndentScriptAndStyle
prettier.embeddedLanguageFormatting
prettier.experimentalTernaries
```

### Extension Settings
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,12 @@
"default": "auto",
"markdownDescription": "%ext.config.embeddedLanguageFormatting%",
"scope": "language-overridable"
},
"prettier.experimentalTernaries": {
"type": "boolean",
"default": false,
"markdownDescription": "%ext.config.experimentalTernaries%",
"scope": "language-overridable"
}
}
},
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@
"ext.config.embeddedLanguageFormatting": "Control whether Prettier formats quoted code embedded in the file.",
"ext.config.enable": "Controls whether Prettier is enabled or not. Reload required.",
"ext.config.enableDebugLogs": "Enable debug logs for troubleshooting.",
"ext.config.experimentalTernaries": "Try prettier's [new ternary formatting](https://github.com/prettier/prettier/pull/13183) before it becomes the default behavior.",
"ext.capabilities.untrustedWorkspaces.description": "Only the built-in version of Prettier will be used when running in untrusted mode."
}
3 changes: 2 additions & 1 deletion src/PrettierEditService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { getParserFromLanguageId } from "./languageFilters";
import { LoggingService } from "./LoggingService";
import { RESTART_TO_ENABLE } from "./message";
import { PrettierEditProvider } from "./PrettierEditProvider";
import { PrettierInstance } from "./PrettierInstance";
import { FormatterStatus, StatusBar } from "./StatusBar";
import {
ExtensionFormattingOptions,
Expand All @@ -26,7 +27,6 @@ import {
RangeFormattingOptions,
} from "./types";
import { getConfig, isAboveV3 } from "./util";
import { PrettierInstance } from "./PrettierInstance";

interface ISelectors {
rangeLanguageSelector: ReadonlyArray<DocumentFilter>;
Expand Down Expand Up @@ -551,6 +551,7 @@ export default class PrettierEditService implements Disposable {
vsOpts.embeddedLanguageFormatting =
vsCodeConfig.embeddedLanguageFormatting;
vsOpts.vueIndentScriptAndStyle = vsCodeConfig.vueIndentScriptAndStyle;
vsOpts.experimentalTernaries = vsCodeConfig.experimentalTernaries;
}

this.loggingService.logInfo(
Expand Down
2 changes: 1 addition & 1 deletion src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type PrettierFileInfoResult = {
};
type PrettierBuiltInParserName = string;
type PrettierResolveConfigOptions = prettier.ResolveConfigOptions;
type PrettierOptions = prettier.Options;
type PrettierOptions = prettier.Options & { experimentalTernaries?: boolean };
type PrettierFileInfoOptions = prettier.FileInfoOptions;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type PrettierPlugin = prettier.Plugin<any>;
Expand Down

0 comments on commit 3712ee7

Please sign in to comment.