View and translation rules¶
Both rules search your project for references, so both are off by default: they cost time to run, and a reference the scan cannot see looks exactly like one that was never written.
Unused view¶
laravel.unusedView · option rules.unusedView · off by default
Finds views in your application that are never used.
NOTE: Due to the nature of static analysis, this rule can produce false positives. It cannot find every usage of a view, so it is possible that a view is reported as unused when it is actually used. This is why it's an optional rule.
Configuration¶
Blade files under resources/views are scanned by default. Use
viewDirectories for views kept
elsewhere:
parameters:
laravel:
rules:
unusedView: true
viewDirectories:
- domainA/resources/views
- a/path/to/views
Supported View Usages¶
viewhelper function.$this->markdownand$this->viewmethods in Mailables.Illuminate\View\Factory::makemethod.Illuminate\Support\Facades\View::makemethod.Illuminate\Support\Facades\Route::viewmethod.@extendsBlade directive.@includeBlade directive.@includeIfBlade directive.@includeUnlessBlade directive.@includeWhenBlade directive.@includeFirstBlade directive.
Missing translation¶
laravel.missingTranslation · option rules.missingTranslation · off by default
Finds untranslated strings in your application. It is primarily meant for applications that make use of the dot syntax like messages.greet. If you're using translation strings as keys, this rule may be unnecessary. Enabling this rule may decrease performance as it will scan the available views and translations.
Translations from vendors like vendor::key will not be checked.
NOTE: If you store your translations in a database, this rule will not be able to detect them. You should leave this rule disabled in such cases.
Examples¶
For the following code:
This extension may report the following error:
Configuration¶
resources/lang is scanned by default. If your translations live elsewhere,
register every path with
translationDirectories: