Skip to content
This repository was archived by the owner on Jan 12, 2022. It is now read-only.

Commit e917049

Browse files
committed
BREAKING CHANGE:: prettier v2
1 parent 498bfe2 commit e917049

32 files changed

+6336
-6319
lines changed

Diff for: .vscode/launch.json

+13
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@
1717
],
1818
"outFiles": ["${workspaceFolder}/packages/extension/dist/**/*.js"],
1919
"preLaunchTask": "${defaultBuildTask}"
20+
},
21+
{
22+
"name": "Run Extension (TypeScript)",
23+
"type": "extensionHost",
24+
"request": "launch",
25+
"runtimeExecutable": "${execPath}",
26+
"args": [
27+
"--extensionDevelopmentPath=${workspaceFolder}/packages/extension",
28+
"--disable-extensions",
29+
"/tmp/TypeScript"
30+
],
31+
"outFiles": ["${workspaceFolder}/packages/extension/dist/**/*.js"],
32+
"preLaunchTask": "${defaultBuildTask}"
2033
}
2134
]
2235
}

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
| Version | Date | Changelog |
44
| ------- | -------- | ---------------------------------------------------------------------- |
5+
| 2.0.0 | 21.04.20 | Breaking Change: Upgrade to Prettier v2. |
56
| 1.1.21 | 02.03.20 | Fix: Don't exclude node_modules from formatting |
67
| 1.1.20 | 02.03.20 | Fix: Format based on languageId, not file extension |
78
| 1.1.17 | 18.02.20 | Fix: Multiroot workspace support |

Diff for: Issues.md

+2
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ import { a } from 'a'
3838
<!-- TODO test if it works when changing prettierrc -->
3939

4040
<!-- TODO support virtual file systems, e.g. memfs -->
41+
42+
<!-- TODO remove language server because it is unnecessary when there is a worker thread -->

Diff for: README.md

+5-47
Original file line numberDiff line numberDiff line change
@@ -18,53 +18,11 @@ For best editing experience, the following settings are recommended:
1818
<br>
1919
<br>
2020

21-
## Differences to the official prettier extension
21+
## Supported languages
2222

23-
| | This extension | [Official Prettier Extension](https://github.com/prettier/prettier-vscode) |
24-
| -------------------------------------------------------------------------------------------------------------------------------- | -------------- | -------------------------------------------------------------------------- |
25-
| Out of the box support for JavaScript, TypeScript, Flow, JSX, JSON, CSS, SCSS, Less, HTML, Vue, Angular, GraphQL, Markdown, YAML |||
26-
| Out of the box support for C#, Elm, Java, Svelte, Twig, XML || |
27-
| Works without `npm install` || |
28-
| Activates lazily || |
29-
| Implemented as a language server so that it never slows down VSCode || |
30-
| More configuration options | ||
31-
| Less configuration options, more opinionated || |
32-
| Plugin support | not yet ||
23+
JavaScript, TypeScript, Flow, JSX, JSON, CSS, SCSS, Less, HTML, Vue, Angular, GraphQL, Markdown, YAML, C#, Elm, Java, , Twig, XML,
3324

34-
<br>
35-
36-
<!--
37-
## Settings
38-
39-
| Property | Default |
40-
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
41-
| prettier.enabledLanguageIds | `["csharp", "css", "elm", "flow", "graphql", "html", "java","javascript", "javascriptreact", "json", "jsonc", "less", "markdown", "mdx", "php", "postcss", "ruby", "scss", "solidity", "svelte", "typescript", "typescriptreact", "twig", "vue", "xml", "yaml"]` |
42-
43-
-->
44-
<!--
45-
## Supported Languages
25+
## Todo
4626

47-
- Angular
48-
- C#
49-
- CSS
50-
- Elm
51-
- Flow
52-
- GraphQL
53-
- HTML
54-
- Java
55-
- JavaScript / JSX
56-
- JSON / JSONC
57-
- LESS
58-
- Markdown
59-
- MDX
60-
- Php
61-
- PostCSS
62-
- Ruby
63-
- SCSS
64-
- Solidity
65-
- Svelte
66-
- TypeScript / TSX
67-
- Twig
68-
- Vue
69-
- XML
70-
- YAML -->
27+
- Svelte (currently not working with Prettier v2)
28+
- Php (currently not working with Prettier v2)

Diff for: package.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"clean": "rimraf dist tmp",
88
"bundle:client": "webpack --mode production --config ./webpack/client.webpack.config.js",
99
"bundle:server": "webpack --mode production --config ./webpack/server.webpack.config.js",
10-
"package": "npm run clean && npm run bundle:client && npm run bundle:server && node scripts/package.js && npm run bundlesize",
10+
"bundle:worker": "webpack --mode production --config ./webpack/worker.webpack.config.js",
11+
"package": "npm run clean && npm run bundle:client && npm run bundle:server && npm run bundle:worker && node scripts/package.js && npm run bundlesize",
1112
"publish": "npm run package && cd dist && npx semantic-release",
1213
"prettier": "prettier --config package.json --write \"packages/*/src/**/*.ts\"",
1314
"bundlesize": "bundlesize"
@@ -50,6 +51,11 @@
5051
"path": "./dist/packages/server/dist/serverMain.js",
5152
"maxSize": "11 kB",
5253
"compression": "none"
54+
},
55+
{
56+
"path": "./dist/packages/server/dist/worker.js",
57+
"maxSize": "7 kB",
58+
"compression": "none"
5359
}
5460
],
5561
"prettier": {

Diff for: packages/extension-test/src/extensionTestMain.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as path from 'path'
33
import { downloadAndUnzipVSCode, runTests } from 'vscode-test'
44

55
const root = path.join(__dirname, '../../../')
6-
const vscodeVersion = '1.43.1'
6+
const vscodeVersion = '1.44.2'
77
const extensionDevelopmentPath = path.join(root, 'packages/extension')
88

99
interface Test {

Diff for: packages/extension/package-lock.json

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: packages/extension/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,13 @@
228228
}
229229
},
230230
"devDependencies": {
231+
"@types/node": "^13.13.1",
232+
"@types/prettier": "^2.0.0",
231233
"@types/vscode": "^1.43.0",
232234
"typescript": "^3.8.3"
233235
},
234236
"dependencies": {
237+
"prettier": "^2.0.5",
235238
"source-map-support": "^0.5.16",
236239
"vscode-languageclient": "^6.1.3"
237240
}

Diff for: packages/extension/src/extensionMain.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
import 'source-map-support/register'
22
import * as vscode from 'vscode'
3-
import { localPluginEnableFormatOnSave } from './local-plugins/local-plugin-enable-format-on-save/localPluginEnableFormatOnSave'
43
import { localPluginFormatting } from './local-plugins/local-plugin-formatting/localPluginFormatting'
5-
import { LocalPlugin } from './local-plugins/pluginApi'
6-
7-
const LOCAL_PLUGINS: LocalPlugin[] = [
8-
localPluginFormatting,
9-
// localPluginEnableFormatOnSave,
10-
]
114

125
export const activate: (
136
context: vscode.ExtensionContext
14-
) => Promise<void> = async context => {
15-
await Promise.all([LOCAL_PLUGINS.map(localPlugin => localPlugin(context))])
7+
) => Promise<void> = async (context) => {
8+
localPluginFormatting(context)
169
}

Diff for: packages/extension/src/local-plugins/local-plugin-enable-format-on-save/localPluginEnableFormatOnSave.ts

-44
This file was deleted.

Diff for: packages/extension/src/local-plugins/local-plugin-formatting/localPluginFormatting.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ const getDocumentSelector: () => DocumentSelector = () => {
4343
.get<string[]>('enabledLanguageIds', DEFAULT_ENABLED_LANGUAGE_IDS)
4444
const schemes: string[] = ['file', 'untitled']
4545
const documentSelector: DocumentSelector = enabledLanguageIds.flatMap(
46-
languageId =>
47-
schemes.map(scheme => ({
46+
(languageId) =>
47+
schemes.map((scheme) => ({
4848
scheme,
4949
language: languageId,
5050
}))
@@ -55,7 +55,6 @@ const getDocumentSelector: () => DocumentSelector = () => {
5555
const getLanguageClientOptions: () => LanguageClientOptions = () => {
5656
const languageClientOptions: LanguageClientOptions = {
5757
documentSelector: getDocumentSelector(),
58-
// synchronize
5958
}
6059
return languageClientOptions
6160
}
@@ -72,15 +71,15 @@ const PRETTIER_CONFIG_FILES = [
7271
'.prettierignore',
7372
]
7473

75-
export const localPluginFormatting: LocalPlugin = async context => {
74+
export const localPluginFormatting: LocalPlugin = async (context) => {
7675
const languageClientProxy = await createLanguageClientProxy(
7776
context,
7877
'prettier',
7978
'Prettier',
8079
getLanguageClientOptions()
8180
)
8281
context.subscriptions.push(
83-
vscode.workspace.onDidChangeConfiguration(event => {
82+
vscode.workspace.onDidChangeConfiguration((event) => {
8483
if (!event.affectsConfiguration('prettier.enabledLanguageIds')) {
8584
return
8685
}

Diff for: packages/server/package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: packages/server/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"dependencies": {
99
"@babel/code-frame": "^7.8.3",
1010
"service": "^1.0.0-dev",
11-
"source-map-support": "^0.5.16",
11+
"source-map-support": "^0.5.18",
1212
"vscode-languageserver": "^6.1.1",
1313
"vscode-languageserver-textdocument": "^1.0.1",
1414
"vscode-uri": "^2.1.1"

Diff for: packages/server/src/documentFormatting.ts

-96
This file was deleted.

Diff for: packages/server/src/documents.ts

-4
This file was deleted.

0 commit comments

Comments
 (0)