Volver al ranking

shufo/vscode-blade-formatter

TypeScriptmarketplace.visualstudio.com/items

An opinionated Blade file formatter for VSCode

laravelvscodevscode-extensionformatter
Crecimiento de estrellas
Estrellas
5.2k
Forks
44
Crecimiento semanal
Issues
7
2k4k
jul 2020jul 2022jul 2024jul 2026
Artefactosnpmnpm install vscode-blade-formatter
README

CI Visual Studio Marketplace Installs Visual Studio Marketplace Downloads Visual Studio Marketplace Version Visual Studio Marketplace Rating

vscode-blade-formatter

An opinionated Blade file formatter for VSCode. Marketplace page is here.

You can also format programmatically with the same syntax using the blade-formatter that this extension relies on.

Features

  • Automatically indent markup inside directives
  • Automatically add spacing to blade template markers
  • PHP 8 support (null safe operator, named arguments) 🐘
  • PSR-2 support (format inside directives)
  • Automatically sort Tailwind CSS classes with respect of tailwind.config.js

Screencast

Screencast

Extension Settings

setting description default
Blade Formatter: format Enabled Whether it enables or not true
Blade Formatter: format Indent Size An indent size 4
Blade Formatter: format Wrap Line Length The length of line wrap size 120
Blade Formatter: format Wrap Attributes The way to wrap attributes. [auto|force|force-aligned|force-expand-multiline|aligned-multiple|preserve|preserve-aligned] auto
Blade Formatter: format Wrap Attributes Min Attrs Minimum number of html tag attributes for force wrap attribute options. Wrap the first attribute only if force-expand-multiline is specified in wrap attributes 2
Blade Formatter: format Sort Tailwind Css Classes Sort Tailwind CSS classes automatically false
Blade Formatter: format Sort HTML Attributes Sort HTML Attributes in the specified order. [none | alphabetical | code-guide | idiomatic | vuejs] none
Blade Formatter: format Indent Inner Html Indent <head> and <body> sections in html. false
Blade Formatter: format use Tabs Use tab as indentation character false
Blade Formatter: format Custom Html Attributes Order Comma separated custom HTML attributes order. e.g. id, data-.+, class, name. To enable this you must specify sort html attributes option as custom. You can use regex for attribute names. none
Blade Formatter: format No Multiple Empty Lines Collapses multiple blank lines into a single blank line. false
Blade Formatter: format No PHP Syntax Check Disable PHP Syntax check. Enabling this will suppress syntax error reporing. ""
Blade Formatter: format No Single Quote Use double quotes instead of single quotes for php expression. false
Blade Formatter: format No Trailing Comma Php If set to true, no trailing commas are printed for php expression. false
Blade Formatter: format Component Prefix Specify custom prefixes for component names separated by comma. e.g. x-,livewire. This changes the format rules applied to custom components e.g. preserve style in attributes. x-,livewire
Blade Formatter: format PHP Version A php version using for syntax compatibility. 8.4
Blade Formatter: Dont Show New Version Message If set to 'true', the new version message won't be shown anymore. false

Configuration file: .bladeformatterrc.json or .bladeformatterrc

To configure settings per project, put .bladeformatterrc.json or .bladeformatterrc to your project root will vscode-blade-formatter treat it as setting files.

Configuration file will like below:

{
    "indentSize": 4,
    "wrapAttributes": "auto",
    "wrapAttributesMinAttrs": 2,
    "wrapLineLength": 120,
    "endWithNewLine": true,
    "noMultipleEmptyLines": false,
    "useTabs": false,
    "sortTailwindcssClasses": true,
    "sortHtmlAttributes": "none",
    "noPhpSyntaxCheck": false,
    "noSingleQuote": false,
    "noTrailingCommaPhp": false,
    "componentPrefix": ["x-", "livewire:"],
    "phpVersion": "8.4"
}

Ignoring Files: .bladeignore

To exclude files from formatting, create a .bladeignore file in the root of your project. .bladeignore uses gitignore syntax

# Ignore email templates
resources/views/email/**

Disabling format in file

To disable formatting in your file, you can use blade comments in the following format:

{{-- blade-formatter-disable --}}
    {{ $foo }}
    {{ $bar }}
{{-- blade-formatter-enable --}}

To disable formatting on a specific line, you can use comment in the following format:

{{-- blade-formatter-disable-next-line --}}
    {{ $foo }}

To disable formatting for an entire file, put a {{-- blade-formatter-disable --}} comment at the beginning of the file:

{{-- blade-formatter-disable --}}

{{ $foo }}

TODO

  • Add more option for HTML formatting rules
  • Add option for PHP formatting rules
  • Automate package publishing flow
  • Integration test

Release Notes

see CHANGELOG.md

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Development

$ yarn install
$ cp .env.example .env # set your app insight key
$ yarn run watch # watch changes

Testing

$ yarn install
$ cp .env.example .env # set your app insight key
$ yarn run compile
$ yarn run test

Sponsors

Contributors

shufo
Shuhei Hayashibara
slovenianGooner
SlovenianGooner
snyk-bot
Snyk Bot
yaegassy
Yaegassy
dianfishekqi
dianfishekqi
1cbyc
Isaac Emmanuel
j3j5
Julio J. Foulquie

LICENSE

MIT

Data and telemetry

This extension collects usage data and sends it to Azure Application Insight to improve extension. This extension respects the telemetry.enableTelemetry setting.

To opt out, please set the telemetry.enableTelemetry setting to false. Learn more in FAQ.

Repositorios relacionados
shadcn-ui/ui

A set of beautifully-designed, accessible components and a code distribution platform. Works with your favorite frameworks. Open Source. Open Code.

TypeScriptnpmMIT Licensecomponentsnextjs
ui.shadcn.com
119.4k9.5k
laravel/laravel

Laravel is a web application framework with expressive, elegant syntax. We’ve already laid the foundation for your next big idea — freeing you to create without sweating the small things.

Bladephpframework
laravel.com
84.6k24.8k
coollabsio/coolify

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 280+ one-click services on your own servers.

PHPPackagistApache License 2.0nodejsmysql
coolify.io
59.1k5.1k
laravel/framework

Laravel is a web application framework with expressive, elegant syntax.

PHPPackagistMIT Licensephpframework
laravel.com
34.8k11.9k
filamentphp/filament

A powerful open-source UI framework for Laravel • Build and ship apps & admin panels fast with Livewire

PHPPackagistMIT Licenselaraveltailwind-css
filamentphp.com
31.5k4.2k
bagisto/bagisto

Free and open source laravel eCommerce platform

PHPPackagistMIT Licenseecommerce-frameworklaravel
bagisto.com
27.8k3.2k
monicahq/monica

Personal CRM. Remember everything about your friends, family and business relationships.

PHPPackagistGNU Affero General Public License v3.0laravelcrm
beta.monicahq.com
24.9k2.6k
krayin/laravel-crm

Free & Opensource Laravel CRM solution for SMEs and Enterprises for complete customer lifecycle management.

BladeMIT Licensephplaravel
krayincrm.com
23.4k1.5k
fruitcake/laravel-debugbar

Debugbar for Laravel (Integrates PHP Debug Bar)

PHPPackagistMIT Licenselaraveldebugbar
laraveldebugbar.com
19.3k1.6k
BookStackApp/BookStack

NOW MANAGED ON CODEBERG

PHPPackagistMIT Licensebookstacklaravel
codeberg.org/bookstack/bookstack
18.9k2.4k
barryvdh/laravel-debugbar

Debugbar for Laravel (Integrates PHP Debug Bar)

PHPPackagistMIT Licenselaraveldebugbar
laraveldebugbar.com
18k1.6k
koel/koel

Music streaming solution that works.

PHPPackagistMIT Licenselaravelvue
koel.dev
17.2k2.1k