Blade Template - Linting?

Published 5 days ago by monahajt

I can't really find a dependable way to lint the blade templates. I work with a fairly large team, and it would be tremendously helpful if something like this existed!

Has anyone discovered a way to do this dependably?

Best Answer (As Selected By monahajt)
bobbybouwmann

Yeah there is a package for it: https://github.com/Magentron/laravel-blade-lint

You can even add this as a pre-commit hook or add it in your CI ;)

bobbybouwmann

Yeah there is a package for it: https://github.com/Magentron/laravel-blade-lint

You can even add this as a pre-commit hook or add it in your CI ;)

monahajt

@bobbybouwmann

having some trouble with this package. I've done a composer require, composer install, dump-autoload, and still getting this error:

There are no commands defined in the "blade" namespace.

using laravel 5.6

it is definitely in my composer.json and composer.lock. If I run a composer show it shows up there as well. Completely baffled by why it doesn't work. I've also tried the fix for laravel version < 5.5 (adding to providers array in config/app.php) and it can't seem to find the path.

any tips to getting this working?

bobbybouwmann
bobbybouwmann
1 day ago (1,163,105 XP)

Did you register the service provider in the config/app.php file?

It seems that the README says that it supports auto discovery of packages, however I don't see that feature in the composer.json file. In that case you need to register the service provider yourself as well!

monahajt

@bobbybouwmann yup, tried that - I put exactly as they had it in the README. Is there some other way to access what is in the vendor folder?

bobbybouwmann
bobbybouwmann
1 day ago (1,163,105 XP)

You need to register the command in Laravel otherwise you can't run it from the command line.

You can copy the command class to your own project and then run it from there? Not ideal but it should work!

monahajt

ended up just copying it into my project, and well ... it didn't really do anything. I just got the "blade files are okay" message but it didn't seem to catch syntax errors, or improper indentation, or well - anything. It definitely was looking at the correct files, as I fiddled with it for a little while. Haven't really seen anybody talking about this package. I don't know if anyone is actually using it.

I'm honestly surprised there aren't more blade linters out there.

Please sign in or create an account to participate in this conversation.