tighten / tlint

Tighten linter for Laravel conventions.
MIT License
521 stars 32 forks source link

Possible to report syntax errors? #341

Closed daronspence closed 10 months ago

daronspence commented 1 year ago

I'm using tlint with the VScode extension. I know the extension is not managed by Tighten, but I'm curious if this could be an upstream change.

When linting a blade file, if there is a syntax error, the linter fails entirely. This is good! But I'm curious if there is a way to pass this information downstream so extensions can show better errors?

Say you have the following command and file:

tlint lint --json  ./test.blade.php
<div
    @class(['my thing here', 'another one', syntax!error])
>
    @if(config('tlint.spacing.error'))
        <h1>Hello world</h1>
    @endif
</div>

This will throw the following error in cli

Lints for ./test.blade.php
============
! Syntax error, unexpected T_STRING, expecting ',' or ']' or ')'
2 : `    class="<?php echo \Illuminate\Support\Arr::toCssClasses(['my thing here', 'another one', syntax!error]) ?>"`

What would be nice is if we could get something like this:

{"errors":[{"line":2,"message":"Syntax Error", "source":"Syntax"}]}

This would block checking the rest of the file, but I think it would be amazing to have as an option for IDEs. In CI, I think throwing the original error makes a lot of sense, but for people not using linting in CI, this would help. I'm honestly surprised that none of the VS Code extensions I have tried for Blade files actually include proper syntax checking, so having this as option I think would be really helpful.

Maybe another flag?

tlint lint --json --with-syntax-errors ./test.blade.php`

Thanks for making a great tool!

daronspence commented 1 year ago

Bump? If someone can confirm that this feature is desirable, I can try to take a stab at submitting a PR.

Cheers :)

driftingly commented 1 year ago

@daronspence it would help to have some idea how much would be required to get this working. I think it would be fairly simple. If it doesn't require too much overhead/maintenance it will get merged.

driftingly commented 10 months ago

@daronspence We are open to contributions. If it's simple and easy to maintain, it is likely to be merged in. I'm closing for now. You can reopen if you start working on a PR and have any questions. Thank you for your feedback and interest.