Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ All notable changes to the "prettier-vscode" extension will be documented in thi
- Fixed parser detection for custom file extensions with config overrides
- Fixed parser detection fallback when using plugins with Prettier v3
- Added new Prettier v3 options: `objectWrap`, `experimentalOperatorPosition`
- Added support for TypeScript config files (`.prettierrc.ts`, `.prettierrc.cts`, `.prettierrc.mts`, `prettier.config.ts`, etc.) introduced in Prettier 3.5.0 - Thanks to [@dr2009](https://github.com/dr2009)

## [11.0.0]

Expand Down
6 changes: 6 additions & 0 deletions src/PrettierEditService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@ const PRETTIER_CONFIG_FILES = [
".prettierrc.js",
".prettierrc.cjs",
".prettierrc.mjs",
".prettierrc.ts",
".prettierrc.cts",
".prettierrc.mts",
"package.json",
"prettier.config.js",
"prettier.config.cjs",
"prettier.config.mjs",
"prettier.config.ts",
"prettier.config.cts",
"prettier.config.mts",
".editorconfig",
];

Expand Down
16 changes: 16 additions & 0 deletions src/test/suite/ts-config.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import * as assert from "node:assert";
import { format, getText } from "./format.test";

describe("TypeScript Config File Support", () => {
// This test validates TypeScript config file support added in Prettier 3.5.0
// Should use Prettier to read TypeScript config files like prettier.config.ts
it("it formats with TypeScript prettier.config.ts", async () => {
const { actual } = await format(
"ts-config",
"index.js",
/* shouldRetry */ true,
);
const expected = await getText("ts-config", "index.result.js");
assert.equal(actual, expected);
});
});
3 changes: 3 additions & 0 deletions test-fixtures/test.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
},
{
"path": "esm-config"
},
{
"path": "ts-config"
}
],
"settings": {
Expand Down
6 changes: 6 additions & 0 deletions test-fixtures/ts-config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Test file for TypeScript config
const example = {foo: "bar", baz: 123, qux: true};
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable example.

Suggested change
const example = {foo: "bar", baz: 123, qux: true};

Copilot uses AI. Check for mistakes.

function hello(name) {
return "Hello, " + name + "!";
}
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused function hello.

Suggested change
}
}
// Use the hello function to avoid unused function warning
console.log(hello("world"));

Copilot uses AI. Check for mistakes.
6 changes: 6 additions & 0 deletions test-fixtures/ts-config/index.result.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Test file for TypeScript config
const example = { foo: 'bar', baz: 123, qux: true };
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable example.

Suggested change
const example = { foo: 'bar', baz: 123, qux: true };

Copilot uses AI. Check for mistakes.

function hello(name) {
return 'Hello, ' + name + '!';
}
Comment on lines +4 to +6
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused function hello.

Suggested change
function hello(name) {
return 'Hello, ' + name + '!';
}

Copilot uses AI. Check for mistakes.
16 changes: 16 additions & 0 deletions test-fixtures/ts-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "ts-config",
"version": "1.0.0",
"description": "Test folder for TypeScript config files (Prettier 3.5.0+)",
"type": "module",
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Prettier",
"license": "MIT",
"devDependencies": {
"prettier": "^3.5.0"
},
"dependencies": {}
Comment on lines +14 to +15
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The empty dependencies object is unnecessary and can be removed. While this pattern also exists in the v3 test fixture (test-fixtures/v3/package.json:14), other fixtures like esm-config and v2-explicit omit this empty object entirely. Consider removing it to keep the package.json minimal and consistent with fixtures that don't use it.

Suggested change
},
"dependencies": {}
}

Copilot uses AI. Check for mistakes.
}
10 changes: 10 additions & 0 deletions test-fixtures/ts-config/prettier.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// TypeScript config file - requires Prettier 3.5.0+ to parse
import type { Config } from "prettier";

const config: Config = {
tabWidth: 4,
singleQuote: true,
trailingComma: "es5",
};

export default config;