Skip to content

Commit dfc4f64

Browse files
Remove support for @prettier/plugin-php (#152)
* Remove support for `@prettier/plugin-php` * Update changelog
1 parent df84d8f commit dfc4f64

File tree

5 files changed

+3
-49
lines changed

5 files changed

+3
-49
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
### Fixed
11+
12+
- Remove support for `@prettier/plugin-php` ([#152](https://github.com/tailwindlabs/prettier-plugin-tailwindcss/pull/152))
1113

1214
## [0.2.7] - 2023-04-05
1315

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ If a local configuration file cannot be found the plugin will fallback to the de
4242

4343
This plugin uses Prettier APIs that can only be used by one plugin at a time, making it incompatible with other Prettier plugins implemented the same way. To solve this we've added explicit per-plugin workarounds that enable compatibility with the following Prettier plugins:
4444

45-
- `@prettier/plugin-php`
4645
- `@prettier/plugin-pug`
4746
- `@shopify/prettier-plugin-liquid`
4847
- `@ianvs/prettier-plugin-sort-imports`

package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
},
2929
"devDependencies": {
3030
"@ianvs/prettier-plugin-sort-imports": "^3.7.0",
31-
"@prettier/plugin-php": "^0.19.2",
3231
"@prettier/plugin-pug": "^2.3.0",
3332
"@shopify/prettier-plugin-liquid": "^1.0.3",
3433
"@shufo/prettier-plugin-blade": "^1.8.4",
@@ -61,7 +60,6 @@
6160
},
6261
"peerDependencies": {
6362
"@ianvs/prettier-plugin-sort-imports": "*",
64-
"@prettier/plugin-php": "*",
6563
"@prettier/plugin-pug": "*",
6664
"@shopify/prettier-plugin-liquid": "*",
6765
"@shufo/prettier-plugin-blade": "*",
@@ -81,9 +79,6 @@
8179
"@ianvs/prettier-plugin-sort-imports": {
8280
"optional": true
8381
},
84-
"@prettier/plugin-php": {
85-
"optional": true
86-
},
8782
"@prettier/plugin-pug": {
8883
"optional": true
8984
},

src/index.js

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,6 @@ export const parsers = {
652652
...(base.parsers.astro
653653
? { astro: createParser('astro', transformAstro) }
654654
: {}),
655-
...(base.parsers.php ? { php: createParser('php', transformPHP) } : {}),
656655
...(base.parsers.melody
657656
? { melody: createParser('melody', transformMelody) }
658657
: {}),
@@ -687,33 +686,6 @@ function transformAstro(ast, { env, changes }) {
687686
}
688687
}
689688

690-
function transformPHP(ast, { env, changes }) {
691-
if (ast.kind === 'inline') {
692-
let leading = ast.raw.match(/^\s*/)[0]
693-
let trailing = ast.raw.match(/\s*$/)[0]
694-
695-
// If the inline block is just whitespace then we don't need to format
696-
if (ast.raw === leading) {
697-
return
698-
}
699-
700-
// We have to parse this as HTML with prettier
701-
let parsed = prettier.format(ast.raw, {
702-
...env.options,
703-
parser: 'html',
704-
})
705-
706-
let formatted = `${leading}${parsed.trimEnd()}${trailing}`
707-
708-
ast.raw = formatted
709-
ast.value = formatted
710-
}
711-
712-
for (let child of ast.children ?? []) {
713-
transformPHP(child, { env, changes })
714-
}
715-
}
716-
717689
/*
718690
function transformBlade(ast, { env, changes }) {
719691
// Blade gets formatted on parse
@@ -908,7 +880,6 @@ function getBasePlugins() {
908880
// And we are not bundling it with the main Prettier plugin
909881
let astro = loadIfExists('prettier-plugin-astro')
910882
let svelte = loadIfExists('prettier-plugin-svelte')
911-
let php = loadIfExists('@prettier/plugin-php')
912883
let melody = loadIfExists('prettier-plugin-twig-melody')
913884
let pug = loadIfExists('@prettier/plugin-pug')
914885
let liquid = loadIfExists('@shopify/prettier-plugin-liquid')
@@ -935,7 +906,6 @@ function getBasePlugins() {
935906

936907
...(svelte?.parsers ?? {}),
937908
...(astro?.parsers ?? {}),
938-
...(php?.parsers ?? {}),
939909
...(melody?.parsers ?? {}),
940910
...(pug?.parsers ?? {}),
941911
...(liquid?.parsers ?? {}),
@@ -961,7 +931,6 @@ function getCompatibleParser(parserFormat, options) {
961931
'@ianvs/prettier-plugin-sort-imports',
962932
'@trivago/prettier-plugin-sort-imports',
963933
'prettier-plugin-organize-imports',
964-
'@prettier/plugin-php',
965934
'@prettier/plugin-pug',
966935
'@shopify/prettier-plugin-liquid',
967936
'@shufo/prettier-plugin-blade',

tests/plugins.test.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,6 @@ let tests = [
144144
],
145145
},
146146
},
147-
{
148-
plugins: ['@prettier/plugin-php'],
149-
tests: {
150-
php: [
151-
[
152-
`<?php $test = function($a,$b){}\n ?>\n <div class="sm:p-0 p-4">Example</div>\n <?php $test = function($c,$d)use($e) {}`,
153-
`<?php $test = function ($a, $b) {}; ?>\n <div class="p-4 sm:p-0">Example</div>\n <?php $test = function ($c, $d) use ($e) {};`,
154-
],
155-
],
156-
},
157-
},
158147
{
159148
plugins: ['prettier-plugin-import-sort'],
160149
tests: {

0 commit comments

Comments
 (0)