Skip to content
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]: Recommended configuration for using plugin-blade together with plugin-php? #198

Closed
vinkla opened this issue May 10, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@vinkla
Copy link

vinkla commented May 10, 2023

Description

It appears that prettier-plugin-blade is being utilized instead of plugin-php for PHP files. Could you please advise on the recommended approach for using @shufo/prettier-plugin-blade in conjunction with @prettier/plugin-php to ensure proper formatting of both PHP and Blade files?

Expected Behavior

It should only format PHP files using plugin-php and Blade files using plugin-blade.

Actual Behavior

It formats PHP files using plugin-blade.

Additional Context

// prettier.config.js
module.exports = {
  singleQuote: true,
  plugins: [require('@prettier/plugin-php'), require('@shufo/prettier-plugin-blade')],
  overrides: [
    {
      files: ['*.php'],
      options: {
        parser: 'php',
      },
    },
    {
      files: ['*.blade.php'],
      options: {
        tabWidth: 4,
        parser: 'blade',
      },
    },
  ],
};
// package.json
{
  "private": true,
  "type": "module",
  "dependencies": {
    "@prettier/plugin-php": "^0.19.4",
    "@shufo/prettier-plugin-blade": "^1.8.12",
    "prettier": "^2.8.8"
  }
}
// .vscode/settings.json
{
  "[blade][php]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "prettier.documentSelectors": ["**/*.php"]
}
@vinkla vinkla added the bug Something isn't working label May 10, 2023
@izham
Copy link

izham commented May 24, 2023

files: ['*.php', '!*.blade.php'],

should fix it

@vinkla
Copy link
Author

vinkla commented May 24, 2023

Thank you @izham for your assistance! Modifying the setting did not resolve my issue.

// prettier.config.js
module.exports = {
  singleQuote: true,
  plugins: [require('@prettier/plugin-php'), require('@shufo/prettier-plugin-blade')],
  overrides: [
    {
      files: ['*.php', '!*.blade.php'],
      options: {
        parser: 'php',
      },
    },
    {
      files: ['*.blade.php'],
      options: {
        tabWidth: 4,
        parser: 'blade',
      },
    },
  ],
};

@vinkla
Copy link
Author

vinkla commented Jun 21, 2023

The issue was resolved by replacing @shufo/prettier-plugin-blade with prettier-plugin-blade.

@vinkla vinkla closed this as completed Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants