Giter Site home page Giter Site logo

[Formatting Bug]: not compatible with `trailingCommaPHP` nor `phpVersion` from `@prettier/plugin-php` about prettier-plugin-blade HOT 6 CLOSED

nelson6e65 avatar nelson6e65 commented on June 18, 2024
[Formatting Bug]: not compatible with `trailingCommaPHP` nor `phpVersion` from `@prettier/plugin-php`

from prettier-plugin-blade.

Comments (6)

shufo avatar shufo commented on June 18, 2024 1

Thanks @nelson6e65.
Maybe we should support trailingCommaPHP and respect phpVersion for compatibility.

from prettier-plugin-blade.

shufo avatar shufo commented on June 18, 2024 1

Added --trailing-comma-php option at https://github.com/shufo/prettier-plugin-blade/releases/tag/v1.12.0.
You can disable trailing comma by setting like

.prettierrc.json

"options": {
~~
  "trailingCommaPHP": false,
}

from prettier-plugin-blade.

shufo avatar shufo commented on June 18, 2024 1

@nelson6e65

And 1.13 with phpVersion?

Yes, this package will respect phpVersion option if exists.

from prettier-plugin-blade.

nelson6e65 avatar nelson6e65 commented on June 18, 2024

.prettierrc.json

{
  "printWidth": 120,
  "tabWidth": 2,
  "trailingComma": "es5",
  "semi": true,
  "singleQuote": true,
  "arrowParens": "always",

  "overrides": [
    {
      "files": ["*.php"],
      "options": {
        "phpVersion": "7.2",
        "tabWidth": 4,
        "printWidth": 120
      }
    },
    {
      "files": ["*.blade.php"],
      "options": {
        "phpVersion": "7.2",
        "trailingCommaPHP": false,
        "tabWidth": 2,
        "printWidth": 120,
        "parser": "blade",
        "sortHtmlAttributes": "vuejs",
        "wrapAttributes": "force-expand-multiline"
      }
    }
  ],
  "plugins": ["@prettier/plugin-php", "@shufo/prettier-plugin-blade"]
}

from prettier-plugin-blade.

nelson6e65 avatar nelson6e65 commented on June 18, 2024

It happens even in a @php directive:

      @php
        echo Form::select(
            'refundType',
            REFUND_TYPES,
            $data->refundType ?? null,
            [
                'class' => 'form-control refundType',
                'required' => 'required',
            ] + ($refundId ? ['disabled' => 'true'] : []),
        );
      @endphp

In a normal PHP file, the trailing comma it's removed:

    public function test()
    {
        $refundId = null;

        echo Form::select(
            'refundType',
            REFUND_TYPES,
            null,
            [
                'class' => 'form-control refundType',
                'required' => 'required',
            ] + ($refundId ? ['disabled' => 'true'] : [])
        );
    }

from prettier-plugin-blade.

nelson6e65 avatar nelson6e65 commented on June 18, 2024

Thanks a lot! 🎉

And 1.13 with phpVersion?

from prettier-plugin-blade.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.