Skip to content

Commit

Permalink
reverted attempt to resolve config defaults based on prettier version
Browse files Browse the repository at this point in the history
  • Loading branch information
ntotten committed Apr 14, 2020
1 parent 82b74c3 commit 44c6aad
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to the "prettier-vscode" extension will be documented in thi

<!-- Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. -->

## [4.4.0]

- Reverted change that attempts to resolve config based on prettier version.

## [4.3.0]

- Removed AppInsights telemetry as its no longer needed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ Disable format on save so this extension doesn't run and enable code actions to

All prettier options can be configured directly in this extension. These settings are used as a fallback when no configuration file is present in your project, see the [configuration](#configuration) section of this document for more details. For reference on the options see the [prettier documentation](https://prettier.io/docs/en/options.html).

> The default values of these configurations are set to their Prettier 2.0 defaults. However, if this extension detects you have a version of prettier less than 2.0 installed, it will use the prettier 1.x default config values.
> The default values of these configurations are always to their Prettier 2.0 defaults. In order to use defaults from ealier versions of prettier you must set them manually using your VS Code settings or local project configurations.
```
prettier.arrowParens
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "prettier-vscode",
"displayName": "Prettier - Code formatter",
"description": "Code formatter using prettier",
"version": "4.3.0",
"version": "4.4.0",
"publisher": "esbenp",
"author": "Prettier <@prettiercode>",
"galleryBanner": {
Expand Down
16 changes: 3 additions & 13 deletions src/ConfigResolver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as prettier from "prettier";
import * as semver from "semver";
import { LoggingService } from "./LoggingService";

interface IResolveConfigResult {
Expand All @@ -19,7 +18,6 @@ export class ConfigResolver {
fileName: string,
parser: prettier.BuiltInParserName,
vsCodeConfig: prettier.Options,
prettierVersion: string,
resolveConfigOptions: prettier.ResolveConfigOptions,
rangeFormattingOptions?: RangeFormattingOptions
): Promise<{ options?: Partial<prettier.Options>; error?: Error }> {
Expand All @@ -36,16 +34,10 @@ export class ConfigResolver {

const fallbackToVSCodeConfig = configOptions === null;

const usePrettierV2Defaults = semver.gte(prettierVersion, "2.0.0");

if (fallbackToVSCodeConfig) {
vsOpts.arrowParens = usePrettierV2Defaults
? vsCodeConfig.arrowParens
: "avoid";
vsOpts.arrowParens = vsCodeConfig.arrowParens;
vsOpts.bracketSpacing = vsCodeConfig.bracketSpacing;
vsOpts.endOfLine = usePrettierV2Defaults
? vsCodeConfig.endOfLine
: "auto";
vsOpts.endOfLine = vsCodeConfig.endOfLine;
vsOpts.htmlWhitespaceSensitivity = vsCodeConfig.htmlWhitespaceSensitivity;
vsOpts.insertPragma = vsCodeConfig.insertPragma;
vsOpts.jsxBracketSameLine = vsCodeConfig.jsxBracketSameLine;
Expand All @@ -57,9 +49,7 @@ export class ConfigResolver {
vsOpts.semi = vsCodeConfig.semi;
vsOpts.singleQuote = vsCodeConfig.singleQuote;
vsOpts.tabWidth = vsCodeConfig.tabWidth;
vsOpts.trailingComma = usePrettierV2Defaults
? vsCodeConfig.trailingComma
: "none";
vsOpts.trailingComma = vsCodeConfig.trailingComma;
vsOpts.useTabs = vsCodeConfig.useTabs;
vsOpts.vueIndentScriptAndStyle = vsCodeConfig.vueIndentScriptAndStyle;
}
Expand Down
1 change: 0 additions & 1 deletion src/PrettierEditService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ export default class PrettierEditService implements Disposable {
fileName,
parser as prettier.BuiltInParserName,
vscodeConfig,
prettierInstance.version,
{
config: vscodeConfig.configPath
? getWorkspaceRelativePath(fileName, vscodeConfig.configPath)
Expand Down

0 comments on commit 44c6aad

Please sign in to comment.