[Bug] Formatting not applying outside of node root
まだ誰も着手していません。
評価
調査の方向性
buildchain にある .prettierignore ファイルと .prettierrc.json ファイルから始め、../cms/app.php と app.php に対して記録されたコマンドを比較します。記載された Node、Prettier、PHP プラグインのバージョンで差異を再現します。完了の条件は、Node のルート外にある PHP ファイルが、設定されたプラグインとフォーマットオプションを一貫して受け取ることです。
索引モデルが issue の本文から書いたものです。
説明
My projects separates the PHP and Node apps like so
/
├── cms/
│ └── composer.json
│ └── vendor/
│ └── etc...
├── buildchain/
│ └── package.json
│ └── node_modules/
│ └── .prettierrc.json
│ └── .prettierignore
│ └── .tsconfig
│ └── src/
│ └── ts/
│ └── css/
│ └── etc...
└─── .editorconfig
I want to format files in cms using cd buildchain && npx prettier -w .. which I managed to get working using this .prettierignore
package.json
package-lock.json
../*
!../cms
../cms/*
!../cms/**/*.php
!../cms/**/*.twig
!../cms/**/*.ts # For demonstration
../cms/vendor
This works fine with typescript files eg.
/var/www/html/buildchain$ npx prettier -c ../cms/app.ts --config .prettierrc.json --log-level debug
[debug] normalized argv: {"":["../cms/app.ts"],"cache":false,"color":true,"editorconfig":true,"config":".prettierrc.json","logLevel":"debug","configPrecedence":"cli-override","debugRepeat":0,"ignorePath":[".gitignore",".prettierignore"],"plugins":[],"check":true,"_":["../cms/app.ts"],"__raw":{"_":["../cms/app.ts"],"cache":false,"c":true,"color":true,"editorconfig":true,"config":".prettierrc.json","log-level":"debug","config-precedence":"cli-override","debug-repeat":0,"ignore-path":[".gitignore",".prettierignore"],"plugin":[]}}
Checking formatting...
[debug] load config file from '.prettierrc.json'
[debug] loaded options `{"useTabs":false,"tabWidth":2,"endOfLine":"lf","plugins":["@prettier/plugin-php"],"singleQuote":true,"printWidth":100}`
[debug] applied config-precedence (cli-override): {"singleQuote":true,"endOfLine":"lf","plugins":["@prettier/plugin-php"],"printWidth":100,"tabWidth":2,"useTabs":false}
[warn] ../cms/app.ts
[warn] Code style issues found in the above file. Run Prettier with --write to fix.
It doesn't work for PHP files though
/var/www/html/buildchain$ npx prettier -c ../cms/app.php --config .prettierrc.json --log-level debug
[debug] normalized argv: {"":["../cms/app.php"],"cache":false,"color":true,"editorconfig":true,"config":".prettierrc.json","logLevel":"debug","configPrecedence":"cli-override","debugRepeat":0,"ignorePath":[".gitignore",".prettierignore"],"plugins":[],"check":true,"_":["../cms/app.php"],"__raw":{"_":["../cms/app.php"],"cache":false,"c":true,"color":true,"editorconfig":true,"config":".prettierrc.json","log-level":"debug","config-precedence":"cli-override","debug-repeat":0,"ignore-path":[".gitignore",".prettierignore"],"plugin":[]}}
Checking formatting...
All matched files use Prettier code style!
It does however work fine when the same file is located in buildchain
/var/www/html/buildchain$ npx prettier -c app.php --config .prettierrc.json --log-level debug
[debug] normalized argv: {"":["app.php"],"cache":false,"color":true,"editorconfig":true,"config":".prettierrc.json","logLevel":"debug","configPrecedence":"cli-override","debugRepeat":0,"ignorePath":[".gitignore",".prettierignore"],"plugins":[],"check":true,"_":["app.php"],"__raw":{"_":["app.php"],"cache":false,"c":true,"color":true,"editorconfig":true,"config":".prettierrc.json","log-level":"debug","config-precedence":"cli-override","debug-repeat":0,"ignore-path":[".gitignore",".prettierignore"],"plugin":[]}}
Checking formatting...
[debug] load config file from '.prettierrc.json'
[debug] loaded options `{"useTabs":false,"tabWidth":4,"endOfLine":"lf","plugins":["@prettier/plugin-php"],"singleQuote":true,"printWidth":100}`
[debug] applied config-precedence (cli-override): {"singleQuote":true,"endOfLine":"lf","plugins":["@prettier/plugin-php"],"printWidth":100,"tabWidth":4,"useTabs":false}
[warn] app.php
[warn] Code style issues found in the above file. Run Prettier with --write to fix.
Versions
- node
20.15.0 - prettier
3.4.2 - @prettier/plugin-php
0.22.2
Thanks
- 主要言語
- PHP
- スター
- 1.9k
- フォーク
- 139
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
prettier/plugin-php のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
prettier/plugin-php#2416 · コメント 2 件 · リアクション 6 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 64/100
prettier/plugin-php#2498 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
prettier/plugin-php#2495 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
prettier/plugin-php#2494 · コメント 1 件 ·
-
strange format issue オープン
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
prettier/plugin-php#2490 ·
prettier/plugin-php の issue をすべて見る
似ている issue
-
jira-created
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 70/100
nunomaduro/phpinsights#745 ·
-
status/awaiting_triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
WordPress/plugin-check#1486 ·
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
az-digital/az_quickstart#6019 ·