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

Commit

Permalink
fix: support for php again
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSiefke committed May 25, 2020
1 parent 78d8e0e commit a457213
Show file tree
Hide file tree
Showing 37 changed files with 129 additions and 88 deletions.
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,4 @@ For best editing experience, the following settings are recommended:

## Supported languages

JavaScript, TypeScript, Flow, JSX, JSON, CSS, SCSS, Less, HTML, Vue, Angular, GraphQL, Markdown, YAML, C#, Elm, Java, Twig, XML, Svelte

## Important

Because of breaking changes with Prettier v2, the following languages are currently not supported:

- Php

You can downgrade this extension to version 1.1.22 which still supports those languages.
JavaScript, TypeScript, Flow, JSX, JSON, CSS, SCSS, Less, HTML, Vue, Angular, GraphQL, Markdown, YAML, C#, Elm, Java, Twig, XML, Svelte, Php
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"semantic-release": "^17.0.7",
"semantic-release-vsce": "^3.0.1",
"ts-loader": "^7.0.1",
"typescript": "^3.8.3",
"typescript": "^3.9.3",
"webpack": "^5.0.0-beta.13",
"webpack-bundle-analyzer": "^3.7.0",
"webpack-cli": "^3.3.11"
Expand Down Expand Up @@ -54,7 +54,7 @@
},
{
"path": "./dist/packages/server/dist/worker.js",
"maxSize": "7 kB",
"maxSize": "8 kB",
"compression": "none"
}
],
Expand Down
24 changes: 12 additions & 12 deletions packages/extension-test/src/basic/format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,18 +238,18 @@ class HelloWorld {
})
})

// test('php', async () => {
// await createTestFile('index.php')
// const testCases: TestCase[] = [
// {
// input: `<?php echo '<p>Hello World</p>' ; ?>`,
// expect: `<?php echo '<p>Hello World</p>'; ?>\n`,
// },
// ]
// await run(testCases, {
// afterCommands,
// })
// })
test('php', async () => {
await createTestFile('index.php')
const testCases: TestCase[] = [
{
input: `<?php echo '<p>Hello World</p>' ; ?>`,
expect: `<?php echo '<p>Hello World</p>'; ?>\n`,
},
]
await run(testCases, {
afterCommands,
})
})

test('postcss', async () => {
await createTestFile('index2.css')
Expand Down
6 changes: 3 additions & 3 deletions packages/server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"devDependencies": {
"@types/babel__code-frame": "^7.0.1",
"@types/source-map-support": "^0.5.1",
"typescript": "^3.8.3"
"typescript": "^3.9.3"
}
}
49 changes: 49 additions & 0 deletions packages/service/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"vscode-languageserver": "^6.1.1"
},
"dependencies": {
"@prettier/plugin-php": "^0.14.1",
"@prettier/plugin-pug": "^1.2.0",
"@prettier/plugin-ruby": "^0.18.1",
"@prettier/plugin-xml": "^0.7.2",
Expand Down
6 changes: 0 additions & 6 deletions packages/service/src/disabled-plugins/php/php.ts

This file was deleted.

8 changes: 4 additions & 4 deletions packages/service/src/formatDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ const FORMATTING_MAP: { [key: string]: () => Promise<Formatter> } = {
const { formatMdx } = await import('./plugins/mdx/mdx')
return formatMdx
},
// async php() {
// const { formatPhp } = await import('./plugins/php/php')
// return formatPhp
// },
async php() {
const { formatPhp } = await import('./plugins/php/php')
return formatPhp
},
async postcss() {
const { formatPostcss } = await import('./plugins/postcss/postcss')
return formatPostcss
Expand Down
4 changes: 2 additions & 2 deletions packages/service/src/plugins/csharp/csharp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as csharp from 'prettier-plugin-csharp'
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatCsharp: Formatter = format => (text, options) =>
export const formatCsharp: Formatter = (format) => (text, options) =>
format(text, { ...options, plugins: [csharp] })
4 changes: 2 additions & 2 deletions packages/service/src/plugins/css/css.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatCss: Formatter = format => (text, options) =>
export const formatCss: Formatter = (format) => (text, options) =>
format(text, options)
4 changes: 2 additions & 2 deletions packages/service/src/plugins/elm/elm.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as elm from 'prettier-plugin-elm'
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatElm: Formatter = format => (text, options) =>
export const formatElm: Formatter = (format) => (text, options) =>
format(text, { ...options, plugins: [elm] })
4 changes: 2 additions & 2 deletions packages/service/src/plugins/flow/flow.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatFlow: Formatter = format => (text, options) =>
export const formatFlow: Formatter = (format) => (text, options) =>
format(text, options)
4 changes: 2 additions & 2 deletions packages/service/src/plugins/graphql/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatGraphql: Formatter = format => (text, options) =>
export const formatGraphql: Formatter = (format) => (text, options) =>
format(text, options)
4 changes: 2 additions & 2 deletions packages/service/src/plugins/handlebars/handlebars.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatHandlebars: Formatter = format => (text, options) =>
export const formatHandlebars: Formatter = (format) => (text, options) =>
// @ts-ignore
format(text, { ...options, parser: 'glimmer' })
4 changes: 2 additions & 2 deletions packages/service/src/plugins/html/html.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatHtml: Formatter = format => (text, options) =>
export const formatHtml: Formatter = (format) => (text, options) =>
format(text, options)
4 changes: 2 additions & 2 deletions packages/service/src/plugins/java/java.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as java from 'prettier-plugin-java'
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatJava: Formatter = format => (text, options) =>
export const formatJava: Formatter = (format) => (text, options) =>
format(text, { ...options, plugins: [java] })
4 changes: 2 additions & 2 deletions packages/service/src/plugins/javascript/javascript.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatJavascript: Formatter = format => (text, options) =>
export const formatJavascript: Formatter = (format) => (text, options) =>
format(text, options)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatJavascriptReact: Formatter = format => (text, options) =>
export const formatJavascriptReact: Formatter = (format) => (text, options) =>
format(text, options)
4 changes: 2 additions & 2 deletions packages/service/src/plugins/json/json.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatJson: Formatter = format => (text, options) =>
export const formatJson: Formatter = (format) => (text, options) =>
format(text, options)
4 changes: 2 additions & 2 deletions packages/service/src/plugins/jsonc/jsonc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatJsonc: Formatter = format => (text, options) =>
export const formatJsonc: Formatter = (format) => (text, options) =>
format(text, options)
4 changes: 2 additions & 2 deletions packages/service/src/plugins/less/less.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatLess: Formatter = format => (text, options) =>
export const formatLess: Formatter = (format) => (text, options) =>
format(text, options)
4 changes: 2 additions & 2 deletions packages/service/src/plugins/markdown/markdown.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatMarkdown: Formatter = format => (text, options) =>
export const formatMarkdown: Formatter = (format) => (text, options) =>
format(text, options)
4 changes: 2 additions & 2 deletions packages/service/src/plugins/mdx/mdx.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatMdx: Formatter = format => (text, options) =>
export const formatMdx: Formatter = (format) => (text, options) =>
format(text, options)
5 changes: 5 additions & 0 deletions packages/service/src/plugins/php/php.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as php from '@prettier/plugin-php'
import type { Formatter } from '../pluginApi'

export const formatPhp: Formatter = (format) => (text, options) =>
format(text, { ...options, plugins: [php] })
2 changes: 1 addition & 1 deletion packages/service/src/plugins/pluginApi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Options } from 'prettier'
import type { Options } from 'prettier'

type Prettier = typeof import('prettier')

Expand Down
4 changes: 2 additions & 2 deletions packages/service/src/plugins/postcss/postcss.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatPostcss: Formatter = format => (text, options) =>
export const formatPostcss: Formatter = (format) => (text, options) =>
format(text, options)
4 changes: 2 additions & 2 deletions packages/service/src/plugins/scss/scss.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatScss: Formatter = format => (text, options) =>
export const formatScss: Formatter = (format) => (text, options) =>
format(text, options)
2 changes: 1 addition & 1 deletion packages/service/src/plugins/svelte/svelte.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as svelte from 'prettier-plugin-svelte'
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

// TODO this has an implicit dependency on svelte, might be difficult to bundle
export const formatSvelte: Formatter = (format) => (text, options) =>
Expand Down
4 changes: 2 additions & 2 deletions packages/service/src/plugins/twig/twig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as twig from 'prettier-plugin-twig-melody'
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatTwig: Formatter = format => (text, options) =>
export const formatTwig: Formatter = (format) => (text, options) =>
format(text, { ...options, plugins: [twig] })
4 changes: 2 additions & 2 deletions packages/service/src/plugins/typescript/typescript.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatTypescript: Formatter = format => (text, options) =>
export const formatTypescript: Formatter = (format) => (text, options) =>
format(text, options)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatTypescriptreact: Formatter = format => (text, options) =>
export const formatTypescriptreact: Formatter = (format) => (text, options) =>
format(text, options)
4 changes: 2 additions & 2 deletions packages/service/src/plugins/vue/vue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatVue: Formatter = format => (text, options) =>
export const formatVue: Formatter = (format) => (text, options) =>
format(text, options)
4 changes: 2 additions & 2 deletions packages/service/src/plugins/xml/xml.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as xml from '@prettier/plugin-xml'
import { Formatter } from '../pluginApi'
import type { Formatter } from '../pluginApi'

export const formatXml: Formatter = format => (text, options) =>
export const formatXml: Formatter = (format) => (text, options) =>
format(text, { ...options, plugins: [xml] })
Loading

0 comments on commit a457213

Please sign in to comment.