-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Plugin stopped formatting blade files after upgrading prettier to 3.0.0 #213
Comments
@Jeto143 Repro: $ ./node_modules/.bin/prettier --version
3.0.0
$ yarn list | grep @shufo/prettier-plugin-blade
warning package.json: No license field
warning No license field
├─ @shufo/prettier-plugin-blade@1.9.2
$ cat .prettierrc.json
{
"plugins": [
"@shufo/prettier-plugin-blade"
],
"overrides": [
{
"files": [
"*.blade.php"
],
"options": {
"parser": "blade",
"sortTailwindcssClasses": true,
"wrapAttributes": "aligned-multiple"
}
}
]
}
$ cat test2.blade.php
<div class="test absolute m-2 block h-4 w-4" id="test">
@if (true)
test
@endif
</div>
$ ./node_modules/.bin/prettier test2.blade.php
<div class="test absolute m-2 block h-4 w-4" id="test">
@if (true)
test
@endif
</div>
$ cat tailwind.config.js
/** @type {import('tailwindcss').Config} */
export default {
content: [],
theme: {
extend: {},
},
plugins: [],
}; You may find the problem by modifying the tailwind config or making backup for config and delete it. Environment
|
Let me know if you solves the problem (or still failed). |
Hey @shufo, Thank you for the prompt reply! I just changed my tailwind.config.js file to the one in your comment, but it didn't make any difference.
|
So here's a minimal reproducible example. One folder containing only the following files: package.json {
"devDependencies": {
"@shufo/prettier-plugin-blade": "1.9.2",
"prettier": "3.0.0"
}
} .prettierrc.json {
"plugins": ["@shufo/prettier-plugin-blade"],
"overrides": [
{
"files": ["*.blade.php"],
"options": {
"parser": "blade"
}
}
]
} view.blade.php <div>Hello world</div> From that folder, run the following: yarn install Then run the following: ./node_modules/.bin/prettier --write . I get the following output:
(Ignoring view.blade.php) |
@Jeto143 It seems that the behaviour of the 2.8.8./node_modules/.bin/prettier --write . will matches everything prettier can format. $ ./node_modules/.bin/prettier --write .
.prettierrc.json 41ms
package.json 6ms
test.blade.php 484ms
test1.blade.php 42ms
test10.blade.php 26ms 3.0.0./node_modules/.bin/prettier --write . will matches everything except .prettierrc.json 48ms
package.json 2ms It might be better to use glob pattern for prettier target explicitly on 3.0.0 for now. $ ./node_modules/.bin/prettier -w "**/*.blade.php"
home.blade.php 252ms
subdirectory/test4.blade.php 148ms
test.blade.php 12ms Or it might be a bug that the this package missing prettier's change in 3.0.0, so I'll look into it. |
Ah good idea, I could use that flag in the mean time. Can't test right now, but would using |
$ yarn run prettier '**/*.*' -w
yarn run v1.22.19
warning package.json: No license field
$ /home/shuhei/develop/prettier-plugin-blade-test3/node_modules/.bin/prettier '**/*.*' -w
.prettierrc.js 43ms
home.blade.php 121ms
package-lock.json 89ms
package.json 10ms
subdirectory/test4.blade.php 67ms
tailwind.config.js 4ms
test.blade.php 13ms
test.js 9ms
test10.blade.php 12ms
It would be better to use |
Yes, that's what I've been using and it's working nicely, thanks! I'm just wondering if this is expected behavior (I feel like it would be more logical for prettier to include declared plugins' extensions by default). But if it were the case, it would be likely to be a prettier issue rather than a bug with your plugin (edit: might have found the corresponding issue in their repository, see below). How about adding a little notice to your README, just in case? Anyway, feel free to close this issue now. Thank you very much for looking into this! |
Description
Using version 1.9.2 (was 1.8.13 before) and prettier 3.0.0 (was 2.8.8 before), no Blade files are being checked nor fixed anymore.
It seems more related to the prettier upgrade (unlikely to be a bug on its side, though), as rolling back this plugin to 1.8.13 doesn't make any difference.
Expected Behavior
The Blade files are checked or fixed as they used to be.
Actual Behavior
No Blade files are even being considered. Nothing is reported nor logged either, it's like they don't exist.
Additional Context
package.json
.prettierrc.json
.prettierignore
(None)
The text was updated successfully, but these errors were encountered: